make aphids spawn honeydew and make anthill spawn a start ant
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://c70vx0utm5knp"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://c70vx0utm5knp"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/units/unit.gd" id="1_ulhs6"]
|
||||
[ext_resource type="Material" uid="uid://f0nlf4tdpvbd" path="res://resources/materials/indicators/hover_indicator_mat.tres" id="2_uk1jy"]
|
||||
[ext_resource type="Script" path="res://scripts/audio_stream_player_polyphonic.gd" id="3_wl62h"]
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_igohi"]
|
||||
material = ExtResource("2_uk1jy")
|
||||
@@ -43,3 +44,6 @@ aabb = AABB(-0.25, 0, -0.25, 0.5, 0.5, 0.5)
|
||||
transform = Transform3D(0.438547, 0, 0, 0, 0.438547, 0, 0, 0, 0.438547, 0, 0.906638, 0)
|
||||
visible = false
|
||||
mesh = SubResource("BoxMesh_hvf81")
|
||||
|
||||
[node name="AudioStreamPlayerPolyphonic" type="AudioStreamPlayer3D" parent="."]
|
||||
script = ExtResource("3_wl62h")
|
||||
|
||||
@@ -37,7 +37,7 @@ callback_mode_process = 1
|
||||
|
||||
[node name="Gathering" parent="." index="8" instance=ExtResource("3_7b5q8")]
|
||||
|
||||
[node name="NearbyItemsSearch" parent="Gathering" index="1"]
|
||||
[node name="NearbyItemsSearch" parent="Gathering" index="0"]
|
||||
shape = SubResource("SphereShape3D_f7l1n")
|
||||
|
||||
[node name="GatheringRadius" parent="Gathering/NearbyItemsSearch" index="0"]
|
||||
|
||||
@@ -10,30 +10,12 @@ radius = 4.0
|
||||
[node name="AntNitwit" instance=ExtResource("1_w0xhf")]
|
||||
script = ExtResource("2_rfn2k")
|
||||
|
||||
[node name="Skeleton3D" parent="AntModel/Armature" index="0"]
|
||||
bones/4/rotation = Quaternion(0.587858, -5.43255e-07, -3.94772e-07, 0.808964)
|
||||
bones/6/rotation = Quaternion(0.330686, -3.0116e-14, -4.44141e-07, 0.943741)
|
||||
bones/9/rotation = Quaternion(0.587858, 5.43255e-07, 3.94772e-07, 0.808964)
|
||||
bones/11/rotation = Quaternion(0.330686, 3.0116e-14, 4.44141e-07, 0.943741)
|
||||
bones/14/rotation = Quaternion(4.60304e-08, 0.0294697, 0.999566, -5.43234e-07)
|
||||
bones/15/rotation = Quaternion(4.55913e-08, 0.0294697, 0.999566, -4.34329e-07)
|
||||
bones/16/rotation = Quaternion(4.55913e-08, 0.0294697, 0.999566, -4.34329e-07)
|
||||
bones/26/rotation = Quaternion(-0.221628, 0.221633, -0.671475, 0.671477)
|
||||
bones/27/rotation = Quaternion(0.583948, -8.29882e-08, 2.36539e-06, 0.811791)
|
||||
bones/28/rotation = Quaternion(-0.84146, 6.60837e-08, -6.26108e-06, 0.54032)
|
||||
bones/30/rotation = Quaternion(0.583949, -2.24752e-07, 2.46641e-06, 0.811791)
|
||||
bones/31/rotation = Quaternion(-0.84146, 1.69298e-07, -6.42962e-06, 0.54032)
|
||||
bones/34/rotation = Quaternion(-0.841459, 1.31575e-07, -6.3826e-06, 0.540321)
|
||||
bones/35/rotation = Quaternion(-0.221628, -0.221633, 0.671475, 0.671477)
|
||||
bones/36/rotation = Quaternion(0.583948, 8.29882e-08, -2.36539e-06, 0.811791)
|
||||
bones/37/rotation = Quaternion(-0.84146, -6.60837e-08, 6.26108e-06, 0.54032)
|
||||
bones/39/rotation = Quaternion(0.583949, 2.24752e-07, -2.46641e-06, 0.811791)
|
||||
bones/40/rotation = Quaternion(-0.84146, -1.69298e-07, 6.42962e-06, 0.54032)
|
||||
bones/43/rotation = Quaternion(-0.841459, -1.31575e-07, 6.3826e-06, 0.540321)
|
||||
[node name="NitwitMesh" parent="AntModel/Armature/Skeleton3D" index="1"]
|
||||
visible = true
|
||||
|
||||
[node name="Gathering" parent="." index="8" instance=ExtResource("4_k3phm")]
|
||||
|
||||
[node name="NearbyItemsSearch" parent="Gathering" index="1"]
|
||||
[node name="NearbyItemsSearch" parent="Gathering" index="0"]
|
||||
shape = SubResource("SphereShape3D_dwl4o")
|
||||
|
||||
[node name="GatheringRadius" parent="Gathering/NearbyItemsSearch" index="0"]
|
||||
|
||||
@@ -191,12 +191,11 @@ script = ExtResource("3_vkmt5")
|
||||
|
||||
[node name="Honeydew" type="Node" parent="Bunches"]
|
||||
|
||||
[node name="HoneydewBunch" type="Marker3D" parent="Bunches/Honeydew"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -46.4312, 0, -61.2736)
|
||||
gizmo_extents = 4.8
|
||||
[node name="BunchSpawner" type="Marker3D" parent="Bunches/Honeydew"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -43.2604, -7.62939e-06, -58.6667)
|
||||
gizmo_extents = 4.7
|
||||
script = ExtResource("3_vkmt5")
|
||||
what = 1
|
||||
amount = 50
|
||||
|
||||
[node name="UI" type="Node" parent="."]
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ class_name Anthill
|
||||
const SPAWN_RADIUS: float = 1
|
||||
const DEFAULT_MAX_HONEYDEW: int = 120
|
||||
|
||||
var honeydew: int = 20
|
||||
var honeydew: int = 0
|
||||
var max_honeydew: int = DEFAULT_MAX_HONEYDEW
|
||||
|
||||
var ant_nitwit := preload("res://scenes/units/ant_nitwit.tscn")
|
||||
@@ -19,6 +19,8 @@ func _ready() -> void:
|
||||
assert(ui_origin != null, "ui_origin missing!")
|
||||
assert(nitwits_holder != null, "nitwits_holder missing!")
|
||||
super._ready()
|
||||
honeydew += AntNitwit.get_cost()
|
||||
spawn_nitwit()
|
||||
|
||||
|
||||
func space_left() -> int:
|
||||
@@ -38,9 +40,11 @@ func deposit_honeydew(amount: int) -> int:
|
||||
|
||||
|
||||
func spawn_nitwit() -> void:
|
||||
print('spawn!')
|
||||
var new_unit := _create_unit(ant_nitwit, AntNitwit.get_cost())
|
||||
if new_unit == null:
|
||||
return
|
||||
print('add!')
|
||||
nitwits_holder.add_child(new_unit)
|
||||
|
||||
|
||||
@@ -57,6 +61,7 @@ func _click() -> void:
|
||||
|
||||
func _create_unit(unit_scene: PackedScene, cost: int) -> ControlledUnit:
|
||||
var new_honeydew_amount := honeydew - cost
|
||||
print(new_honeydew_amount)
|
||||
if new_honeydew_amount < 0:
|
||||
return null
|
||||
honeydew = new_honeydew_amount
|
||||
|
||||
@@ -12,6 +12,8 @@ var move_to: Vector3
|
||||
var move_from: Vector3
|
||||
var moving_timer: float = 0
|
||||
|
||||
var from_aphid: Aphid
|
||||
|
||||
@onready var collision_shape: CollisionShape3D = $CollisionShape3D
|
||||
|
||||
|
||||
@@ -39,6 +41,16 @@ func _process(delta: float) -> void:
|
||||
hover_indicator.visible = false
|
||||
|
||||
|
||||
func set_aphid(from: Aphid) -> void:
|
||||
from_aphid = from
|
||||
|
||||
|
||||
func remove_from_spawner() -> void:
|
||||
if from_aphid == null:
|
||||
return
|
||||
from_aphid.erase_honeydew(self)
|
||||
|
||||
|
||||
func set_carried(on: bool) -> void:
|
||||
carried = on
|
||||
can_interact = not carried
|
||||
|
||||
@@ -5,12 +5,38 @@ enum AphidState {
|
||||
WANDERING,
|
||||
}
|
||||
|
||||
const HONEYDEW_INTERVAL_MIN: float = 5
|
||||
const HONEYDEW_INTERVAL_MAX: float = 60
|
||||
const HONEYDEW_SPAWN_SPREAD: float = 0.5
|
||||
const HONEYDEWS_MAX: int = 5
|
||||
|
||||
var state: AphidState = AphidState.WANDERING
|
||||
var honeydew_spawn_timer: float = 0
|
||||
var spawned_honeydews: Dictionary = {}
|
||||
|
||||
var honeydew_scene := preload("res://scenes/items/honeydew.tscn")
|
||||
|
||||
@onready var holder: Node = $/root/World/Items/Honeydew
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
assert(holder != null, "holder missing!")
|
||||
super._ready()
|
||||
_set_spawn_timer()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
super._process(delta)
|
||||
_handle_wandering(delta)
|
||||
_handle_honeydew_spawn(delta)
|
||||
|
||||
|
||||
func erase_honeydew(item: Honeydew) -> void:
|
||||
var item_id := item.get_instance_id()
|
||||
if not spawned_honeydews.keys().has(item_id):
|
||||
return
|
||||
|
||||
spawned_honeydews.erase(item_id)
|
||||
|
||||
|
||||
func _handle_wandering(delta: float) -> void:
|
||||
@@ -18,3 +44,39 @@ func _handle_wandering(delta: float) -> void:
|
||||
return
|
||||
|
||||
_wander(delta)
|
||||
|
||||
|
||||
func _handle_honeydew_spawn(delta: float) -> void:
|
||||
if spawned_honeydews.size() >= HONEYDEWS_MAX:
|
||||
return
|
||||
|
||||
if honeydew_spawn_timer >= 0:
|
||||
honeydew_spawn_timer -= delta
|
||||
return
|
||||
|
||||
var new_honeydew := honeydew_scene.instantiate() as Honeydew
|
||||
new_honeydew.set_aphid(self)
|
||||
|
||||
var new_pos := Vector3(
|
||||
randf_range(-HONEYDEW_SPAWN_SPREAD, HONEYDEW_SPAWN_SPREAD),
|
||||
new_honeydew.HEIGHT_OFFSET,
|
||||
randf_range(-HONEYDEW_SPAWN_SPREAD, HONEYDEW_SPAWN_SPREAD),
|
||||
)
|
||||
holder.add_child(new_honeydew)
|
||||
new_honeydew.global_position = global_position + new_pos
|
||||
_put_honeydew(new_honeydew)
|
||||
audio_player.play_polyphonic(SoundManager.pop())
|
||||
|
||||
_set_spawn_timer()
|
||||
|
||||
|
||||
func _put_honeydew(item: Honeydew) -> void:
|
||||
var item_id := item.get_instance_id()
|
||||
spawned_honeydews[item_id] = item as Honeydew
|
||||
|
||||
|
||||
func _set_spawn_timer() -> void:
|
||||
honeydew_spawn_timer = randf_range(
|
||||
HONEYDEW_INTERVAL_MIN,
|
||||
HONEYDEW_INTERVAL_MAX,
|
||||
)
|
||||
|
||||
@@ -44,6 +44,7 @@ var showing_after_set: bool = false
|
||||
func _ready() -> void:
|
||||
assert(collision_shape != null, "collision_shape missing!")
|
||||
assert(radius_indicator != null, "radius_indicator missing!")
|
||||
assert(audio_player != null, "audio_player missing!")
|
||||
body_entered.connect(_on_body_entered)
|
||||
body_exited.connect(_on_body_exited)
|
||||
|
||||
@@ -189,6 +190,7 @@ func _deposit() -> void:
|
||||
audio_player.play_polyphonic(SoundManager.swoosh())
|
||||
await item.start_moving(anthill.global_position).moved
|
||||
audio_player.play_polyphonic(SoundManager.pop())
|
||||
item.remove_from_spawner()
|
||||
_erase_honeydew(item)
|
||||
item.queue_free()
|
||||
anthill.deposit_honeydew(1)
|
||||
|
||||
@@ -25,6 +25,9 @@ var advance_anim_delta_accum: float = 0
|
||||
$VisibleOnScreenNotifier3D
|
||||
)
|
||||
@onready var main_camera: MainCamera = $/root/World/MainCamera
|
||||
@onready var audio_player: AudioStreamPlayerPolyphonic = (
|
||||
$AudioStreamPlayerPolyphonic
|
||||
)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -34,6 +37,7 @@ func _ready() -> void:
|
||||
assert(ui_origin != null, "ui_origin missing!")
|
||||
assert(main_camera != null, "main_camera missing!")
|
||||
assert(anim_advance_indicator != null, "anim_advance_indicator missing!")
|
||||
assert(audio_player != null, "audio_player missing!")
|
||||
super._ready()
|
||||
|
||||
anim_advance_indicator.visible = false
|
||||
|
||||
Reference in New Issue
Block a user