made the first changes towards multiplayer working
This commit is contained in:
parent
b0f8a37f60
commit
f004f64b71
@ -59,8 +59,15 @@ func shoot():
|
|||||||
var target_hitbox = target.shape_owner_get_owner($RayCast3D.get_collider_shape())
|
var target_hitbox = target.shape_owner_get_owner($RayCast3D.get_collider_shape())
|
||||||
if target_hitbox is Hitbox:
|
if target_hitbox is Hitbox:
|
||||||
target_hitbox.damage(stats.damage)
|
target_hitbox.damage(stats.damage)
|
||||||
|
networked_hit.rpc(get_tree().root.get_path_to(target_hitbox))
|
||||||
|
|
||||||
|
|
||||||
@rpc
|
@rpc
|
||||||
func networked_shoot():
|
func networked_shoot():
|
||||||
$AnimationPlayer.play("shoot")
|
$AnimationPlayer.play("shoot")
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("reliable")
|
||||||
|
func networked_hit(target_node_path : String):
|
||||||
|
var target_node = get_tree().root.get_node(target_node_path)
|
||||||
|
target_node.damage(stats.damage)
|
||||||
|
@ -9,7 +9,7 @@ func _ready() -> void:
|
|||||||
cooldown = 1.0 / stats.fire_rate
|
cooldown = 1.0 / stats.fire_rate
|
||||||
|
|
||||||
|
|
||||||
func set_raycast_origin(node):
|
func set_raycast_origin(_node):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ func _ready() -> void:
|
|||||||
cooldown = 1.0 / stats.fire_rate
|
cooldown = 1.0 / stats.fire_rate
|
||||||
|
|
||||||
|
|
||||||
func set_raycast_origin(node):
|
func set_raycast_origin(_node):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ func _ready() -> void:
|
|||||||
cooldown = 1.0 / stats.fire_rate
|
cooldown = 1.0 / stats.fire_rate
|
||||||
|
|
||||||
|
|
||||||
func set_raycast_origin(node):
|
func set_raycast_origin(_node):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
38
PCs/hero.gd
38
PCs/hero.gd
@ -7,6 +7,7 @@ signal died
|
|||||||
|
|
||||||
@export var hero_class: HeroClass
|
@export var hero_class: HeroClass
|
||||||
@export var camera : Camera3D
|
@export var camera : Camera3D
|
||||||
|
@export var gun_camera : Camera3D
|
||||||
@export var left_hand : Node3D
|
@export var left_hand : Node3D
|
||||||
@export var right_hand : Node3D
|
@export var right_hand : Node3D
|
||||||
@export var right_hand_animator : AnimationPlayer
|
@export var right_hand_animator : AnimationPlayer
|
||||||
@ -21,6 +22,7 @@ signal died
|
|||||||
@export var weapon_scene : PackedScene
|
@export var weapon_scene : PackedScene
|
||||||
@export var hud : HUD
|
@export var hud : HUD
|
||||||
@export var movement : PlayerMovement
|
@export var movement : PlayerMovement
|
||||||
|
@export var sprint_zoom_speed := 0.2
|
||||||
|
|
||||||
var equipped_card : Card
|
var equipped_card : Card
|
||||||
var paused := false
|
var paused := false
|
||||||
@ -29,15 +31,13 @@ var profile: PlayerProfile
|
|||||||
var ready_state := false :
|
var ready_state := false :
|
||||||
set(value):
|
set(value):
|
||||||
ready_state = value
|
ready_state = value
|
||||||
networked_set_ready_state.rpc(ready_state)
|
ready_state_changed.emit(value)
|
||||||
ready_state_changed.emit(ready_state)
|
|
||||||
var currency := 0 :
|
var currency := 0 :
|
||||||
set(value):
|
set(value):
|
||||||
currency = value
|
currency = value
|
||||||
hud.set_currency_count(value)
|
hud.set_currency_count(value)
|
||||||
get:
|
get:
|
||||||
return currency
|
return currency
|
||||||
@export var sprint_zoom_speed := 0.2
|
|
||||||
|
|
||||||
|
|
||||||
func set_zoom_factor(value):
|
func set_zoom_factor(value):
|
||||||
@ -48,11 +48,12 @@ func _ready() -> void:
|
|||||||
if is_multiplayer_authority():
|
if is_multiplayer_authority():
|
||||||
right_hand_animator.play("weapon_sway")
|
right_hand_animator.play("weapon_sway")
|
||||||
right_hand_animator.speed_scale = 0
|
right_hand_animator.speed_scale = 0
|
||||||
hud.set_visible(true)
|
|
||||||
camera.make_current()
|
camera.make_current()
|
||||||
sprite.queue_free()
|
sprite.queue_free()
|
||||||
else:
|
else:
|
||||||
camera.set_visible(false)
|
camera.set_visible(false)
|
||||||
|
gun_camera.set_visible(false)
|
||||||
|
hud.set_visible(false)
|
||||||
if weapon != null:
|
if weapon != null:
|
||||||
weapon.set_raycast_origin(camera)
|
weapon.set_raycast_origin(camera)
|
||||||
inventory.contents.append_array(hero_class.deck)
|
inventory.contents.append_array(hero_class.deck)
|
||||||
@ -61,7 +62,7 @@ func _ready() -> void:
|
|||||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
if !is_multiplayer_authority() or paused:
|
if !is_multiplayer_authority() or paused:
|
||||||
return
|
return
|
||||||
if movement.input_vector == Vector2.ZERO:
|
if movement.input_vector == Vector2.ZERO:
|
||||||
@ -147,7 +148,9 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
return
|
return
|
||||||
if editing_mode and event.is_action_pressed("Ready"):
|
if editing_mode and event.is_action_pressed("Ready"):
|
||||||
edit_tool.interact_key_held = false
|
edit_tool.interact_key_held = false
|
||||||
ready_state = true
|
if !ready_state:
|
||||||
|
ready_state = true
|
||||||
|
networked_set_ready_state.rpc(ready_state)
|
||||||
if event.is_action_pressed("Pause"):
|
if event.is_action_pressed("Pause"):
|
||||||
var menu = pause_menu_scene.instantiate() as PauseMenu
|
var menu = pause_menu_scene.instantiate() as PauseMenu
|
||||||
pause()
|
pause()
|
||||||
@ -203,8 +206,11 @@ func equip_weapon():
|
|||||||
unequip_weapon()
|
unequip_weapon()
|
||||||
return
|
return
|
||||||
if inventory.contents.size() > 0:
|
if inventory.contents.size() > 0:
|
||||||
|
networked_equip_weapon.rpc()
|
||||||
equipped_card = inventory.remove()
|
equipped_card = inventory.remove()
|
||||||
weapon = equipped_card.weapon.instantiate()
|
weapon = equipped_card.weapon.instantiate()
|
||||||
|
weapon.name = "weapon"
|
||||||
|
weapon.set_multiplayer_authority(multiplayer.get_unique_id())
|
||||||
right_hand.add_child(weapon)
|
right_hand.add_child(weapon)
|
||||||
gauntlet_sprite.set_visible(false)
|
gauntlet_sprite.set_visible(false)
|
||||||
weapon.set_raycast_origin(camera)
|
weapon.set_raycast_origin(camera)
|
||||||
@ -213,6 +219,7 @@ func equip_weapon():
|
|||||||
|
|
||||||
|
|
||||||
func unequip_weapon():
|
func unequip_weapon():
|
||||||
|
networked_unequip_weapon.rpc()
|
||||||
gauntlet_sprite.set_visible(true)
|
gauntlet_sprite.set_visible(true)
|
||||||
weapon.queue_free()
|
weapon.queue_free()
|
||||||
inventory.add(equipped_card)
|
inventory.add(equipped_card)
|
||||||
@ -224,4 +231,21 @@ func unequip_weapon():
|
|||||||
@rpc("reliable")
|
@rpc("reliable")
|
||||||
func networked_set_ready_state(state: bool):
|
func networked_set_ready_state(state: bool):
|
||||||
ready_state = state
|
ready_state = state
|
||||||
ready_state_changed.emit(state)
|
|
||||||
|
|
||||||
|
@rpc("reliable")
|
||||||
|
func networked_equip_weapon():
|
||||||
|
equipped_card = inventory.remove()
|
||||||
|
weapon = equipped_card.weapon.instantiate()
|
||||||
|
weapon.set_multiplayer_authority(multiplayer.get_remote_sender_id())
|
||||||
|
weapon.name = "weapon"
|
||||||
|
right_hand.add_child(weapon)
|
||||||
|
weapon.set_raycast_origin(camera)
|
||||||
|
weapon.set_hero(self)
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("reliable")
|
||||||
|
func networked_unequip_weapon():
|
||||||
|
weapon.queue_free()
|
||||||
|
inventory.add(equipped_card)
|
||||||
|
equipped_card = null
|
||||||
|
219
PCs/hero.tscn
219
PCs/hero.tscn
@ -55,12 +55,13 @@ viewport_path = NodePath("SubViewport")
|
|||||||
[sub_resource type="ViewportTexture" id="ViewportTexture_574jy"]
|
[sub_resource type="ViewportTexture" id="ViewportTexture_574jy"]
|
||||||
viewport_path = NodePath("MiniMapViewport")
|
viewport_path = NodePath("MiniMapViewport")
|
||||||
|
|
||||||
[node name="Character" type="CharacterBody3D" node_paths=PackedStringArray("camera", "left_hand", "right_hand", "right_hand_animator", "edit_tool", "gauntlet_sprite", "sprite", "interaction_raycast", "inventory", "card", "hud", "movement")]
|
[node name="Character" type="CharacterBody3D" node_paths=PackedStringArray("camera", "gun_camera", "left_hand", "right_hand", "right_hand_animator", "edit_tool", "gauntlet_sprite", "sprite", "interaction_raycast", "inventory", "card", "hud", "movement")]
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
collision_mask = 37
|
collision_mask = 37
|
||||||
script = ExtResource("1_pihpe")
|
script = ExtResource("1_pihpe")
|
||||||
hero_class = ExtResource("2_dbyo0")
|
hero_class = ExtResource("2_dbyo0")
|
||||||
camera = NodePath("Head")
|
camera = NodePath("Head")
|
||||||
|
gun_camera = NodePath("SubViewport/Head2")
|
||||||
left_hand = NodePath("SubViewport/Head2/LeftHand")
|
left_hand = NodePath("SubViewport/Head2/LeftHand")
|
||||||
right_hand = NodePath("SubViewport/Head2/RightHand")
|
right_hand = NodePath("SubViewport/Head2/RightHand")
|
||||||
right_hand_animator = NodePath("SubViewport/Head2/RightHand/AnimationPlayer")
|
right_hand_animator = NodePath("SubViewport/Head2/RightHand/AnimationPlayer")
|
||||||
@ -169,6 +170,114 @@ hover_text = NodePath("Label2")
|
|||||||
enemy_sprites = [NodePath("TextureRect4/TextureRect"), NodePath("TextureRect4/TextureRect2"), NodePath("TextureRect4/TextureRect3"), NodePath("TextureRect4/TextureRect4"), NodePath("TextureRect4/TextureRect5")]
|
enemy_sprites = [NodePath("TextureRect4/TextureRect"), NodePath("TextureRect4/TextureRect2"), NodePath("TextureRect4/TextureRect3"), NodePath("TextureRect4/TextureRect4"), NodePath("TextureRect4/TextureRect5")]
|
||||||
enemy_counts = [NodePath("TextureRect4/TextureRect/Label"), NodePath("TextureRect4/TextureRect2/Label2"), NodePath("TextureRect4/TextureRect3/Label3"), NodePath("TextureRect4/TextureRect4/Label4"), NodePath("TextureRect4/TextureRect5/Label5")]
|
enemy_counts = [NodePath("TextureRect4/TextureRect/Label"), NodePath("TextureRect4/TextureRect2/Label2"), NodePath("TextureRect4/TextureRect3/Label3"), NodePath("TextureRect4/TextureRect4/Label4"), NodePath("TextureRect4/TextureRect5/Label5")]
|
||||||
|
|
||||||
|
[node name="WaveCount" type="Label" parent="HUD"]
|
||||||
|
anchors_preset = 5
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
offset_left = -30.0
|
||||||
|
offset_top = 83.0
|
||||||
|
offset_right = 30.0
|
||||||
|
offset_bottom = 26.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "1"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="EnemyCount" type="Label" parent="HUD"]
|
||||||
|
visible = false
|
||||||
|
offset_left = 10.0
|
||||||
|
offset_top = 80.0
|
||||||
|
offset_right = 123.0
|
||||||
|
offset_bottom = 106.0
|
||||||
|
text = "Enemies left: 0"
|
||||||
|
|
||||||
|
[node name="Crosshair" type="TextureRect" parent="HUD"]
|
||||||
|
texture_filter = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -20.0
|
||||||
|
offset_top = -20.0
|
||||||
|
offset_right = 20.0
|
||||||
|
offset_bottom = 20.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
mouse_filter = 2
|
||||||
|
texture = ExtResource("8_fq3f6")
|
||||||
|
|
||||||
|
[node name="TextureRect" type="TextureRect" parent="HUD"]
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
mouse_filter = 2
|
||||||
|
texture = SubResource("ViewportTexture_mk87g")
|
||||||
|
|
||||||
|
[node name="TextureRect2" type="TextureRect" parent="HUD"]
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_left = -256.0
|
||||||
|
offset_top = 40.0
|
||||||
|
offset_right = -40.0
|
||||||
|
offset_bottom = 256.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
mouse_filter = 2
|
||||||
|
texture = SubResource("ViewportTexture_574jy")
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="HUD"]
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_left = -40.0
|
||||||
|
offset_bottom = 26.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
text = "FPS: "
|
||||||
|
horizontal_alignment = 2
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="LivesBar" parent="HUD" instance=ExtResource("15_cqpib")]
|
||||||
|
anchors_preset = 0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
offset_left = 10.0
|
||||||
|
offset_top = 10.0
|
||||||
|
offset_right = 214.0
|
||||||
|
offset_bottom = 32.0
|
||||||
|
grow_horizontal = 1
|
||||||
|
grow_vertical = 1
|
||||||
|
scale = Vector2(3, 3)
|
||||||
|
mouse_filter = 2
|
||||||
|
|
||||||
|
[node name="LivesCount" type="Label" parent="HUD"]
|
||||||
|
offset_left = -5.0
|
||||||
|
offset_top = 15.0
|
||||||
|
offset_right = 100.0
|
||||||
|
offset_bottom = 72.0
|
||||||
|
theme_override_colors/font_color = Color(0.65098, 0.227451, 0.243137, 1)
|
||||||
|
theme_override_font_sizes/font_size = 37
|
||||||
|
text = "120
|
||||||
|
"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="TextureRect3" type="TextureRect" parent="HUD"]
|
||||||
|
texture_filter = 1
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_left = -262.0
|
||||||
|
offset_top = 37.0
|
||||||
|
offset_right = -37.0
|
||||||
|
offset_bottom = 336.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
mouse_filter = 2
|
||||||
|
texture = ExtResource("16_x1xjr")
|
||||||
|
|
||||||
[node name="TextureRect4" type="TextureRect" parent="HUD"]
|
[node name="TextureRect4" type="TextureRect" parent="HUD"]
|
||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
anchors_preset = 5
|
anchors_preset = 5
|
||||||
@ -291,114 +400,6 @@ text = "999"
|
|||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="WaveCount" type="Label" parent="HUD"]
|
|
||||||
anchors_preset = 5
|
|
||||||
anchor_left = 0.5
|
|
||||||
anchor_right = 0.5
|
|
||||||
offset_left = -30.0
|
|
||||||
offset_top = 83.0
|
|
||||||
offset_right = 30.0
|
|
||||||
offset_bottom = 26.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
|
||||||
text = "1"
|
|
||||||
horizontal_alignment = 1
|
|
||||||
vertical_alignment = 1
|
|
||||||
|
|
||||||
[node name="EnemyCount" type="Label" parent="HUD"]
|
|
||||||
visible = false
|
|
||||||
offset_left = 10.0
|
|
||||||
offset_top = 80.0
|
|
||||||
offset_right = 123.0
|
|
||||||
offset_bottom = 106.0
|
|
||||||
text = "Enemies left: 0"
|
|
||||||
|
|
||||||
[node name="Crosshair" type="TextureRect" parent="HUD"]
|
|
||||||
texture_filter = 1
|
|
||||||
anchors_preset = 8
|
|
||||||
anchor_left = 0.5
|
|
||||||
anchor_top = 0.5
|
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 0.5
|
|
||||||
offset_left = -20.0
|
|
||||||
offset_top = -20.0
|
|
||||||
offset_right = 20.0
|
|
||||||
offset_bottom = 20.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
mouse_filter = 2
|
|
||||||
texture = ExtResource("8_fq3f6")
|
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="HUD"]
|
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
mouse_filter = 2
|
|
||||||
texture = SubResource("ViewportTexture_mk87g")
|
|
||||||
|
|
||||||
[node name="TextureRect2" type="TextureRect" parent="HUD"]
|
|
||||||
anchors_preset = 1
|
|
||||||
anchor_left = 1.0
|
|
||||||
anchor_right = 1.0
|
|
||||||
offset_left = -256.0
|
|
||||||
offset_top = 40.0
|
|
||||||
offset_right = -40.0
|
|
||||||
offset_bottom = 256.0
|
|
||||||
grow_horizontal = 0
|
|
||||||
mouse_filter = 2
|
|
||||||
texture = SubResource("ViewportTexture_574jy")
|
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="HUD"]
|
|
||||||
anchors_preset = 1
|
|
||||||
anchor_left = 1.0
|
|
||||||
anchor_right = 1.0
|
|
||||||
offset_left = -40.0
|
|
||||||
offset_bottom = 26.0
|
|
||||||
grow_horizontal = 0
|
|
||||||
text = "FPS: "
|
|
||||||
horizontal_alignment = 2
|
|
||||||
vertical_alignment = 1
|
|
||||||
|
|
||||||
[node name="LivesBar" parent="HUD" instance=ExtResource("15_cqpib")]
|
|
||||||
anchors_preset = 0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
offset_left = 10.0
|
|
||||||
offset_top = 10.0
|
|
||||||
offset_right = 214.0
|
|
||||||
offset_bottom = 32.0
|
|
||||||
grow_horizontal = 1
|
|
||||||
grow_vertical = 1
|
|
||||||
scale = Vector2(3, 3)
|
|
||||||
mouse_filter = 2
|
|
||||||
|
|
||||||
[node name="LivesCount" type="Label" parent="HUD"]
|
|
||||||
offset_left = -5.0
|
|
||||||
offset_top = 15.0
|
|
||||||
offset_right = 100.0
|
|
||||||
offset_bottom = 72.0
|
|
||||||
theme_override_colors/font_color = Color(0.65098, 0.227451, 0.243137, 1)
|
|
||||||
theme_override_font_sizes/font_size = 37
|
|
||||||
text = "120
|
|
||||||
"
|
|
||||||
horizontal_alignment = 1
|
|
||||||
vertical_alignment = 1
|
|
||||||
|
|
||||||
[node name="TextureRect3" type="TextureRect" parent="HUD"]
|
|
||||||
texture_filter = 1
|
|
||||||
anchors_preset = 1
|
|
||||||
anchor_left = 1.0
|
|
||||||
anchor_right = 1.0
|
|
||||||
offset_left = -262.0
|
|
||||||
offset_top = 37.0
|
|
||||||
offset_right = -37.0
|
|
||||||
offset_bottom = 336.0
|
|
||||||
grow_horizontal = 0
|
|
||||||
mouse_filter = 2
|
|
||||||
texture = ExtResource("16_x1xjr")
|
|
||||||
|
|
||||||
[node name="Currency" type="Label" parent="HUD"]
|
[node name="Currency" type="Label" parent="HUD"]
|
||||||
anchors_preset = 1
|
anchors_preset = 1
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
|
@ -14,13 +14,15 @@ var sprint_zoom_factor := 0.08
|
|||||||
var sprinting := false
|
var sprinting := false
|
||||||
var head_angle := 0.0
|
var head_angle := 0.0
|
||||||
var look_sens : float :
|
var look_sens : float :
|
||||||
set(value):
|
set(_value):
|
||||||
return
|
return
|
||||||
get:
|
get:
|
||||||
return Data.preferences.mouse_sens / 40000.0
|
return Data.preferences.mouse_sens / 40000.0
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
if !is_multiplayer_authority():
|
||||||
|
return
|
||||||
var accel = acceleration
|
var accel = acceleration
|
||||||
if sprinting:
|
if sprinting:
|
||||||
accel = acceleration + sprint_boost
|
accel = acceleration + sprint_boost
|
||||||
@ -35,7 +37,9 @@ func _physics_process(delta: float) -> void:
|
|||||||
sync_rotation.rpc(player.rotation)
|
sync_rotation.rpc(player.rotation)
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
|
if !is_multiplayer_authority():
|
||||||
|
return
|
||||||
can_sprint = true
|
can_sprint = true
|
||||||
input_vector = Input.get_vector("Move Left", "Move Right", "Move Forward", "Move Backward")
|
input_vector = Input.get_vector("Move Left", "Move Right", "Move Forward", "Move Backward")
|
||||||
if input_vector.y >= 0:
|
if input_vector.y >= 0:
|
||||||
@ -52,6 +56,8 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
|
if !is_multiplayer_authority():
|
||||||
|
return
|
||||||
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||||
player.rotation.y -= event.relative.x * (look_sens / zoom_factor) * (-1 if Data.preferences.invert_lookX else 1)
|
player.rotation.y -= event.relative.x * (look_sens / zoom_factor) * (-1 if Data.preferences.invert_lookX else 1)
|
||||||
head_angle -= event.relative.y * (look_sens / zoom_factor) * (-1 if Data.preferences.invert_lookY else 1)
|
head_angle -= event.relative.y * (look_sens / zoom_factor) * (-1 if Data.preferences.invert_lookY else 1)
|
||||||
|
@ -11,9 +11,11 @@ var astar := AStar3D.new()
|
|||||||
@export var end : Node3D
|
@export var end : Node3D
|
||||||
@export var spawner : EnemySpawner
|
@export var spawner : EnemySpawner
|
||||||
@export var visualized_path : VisualizedPath
|
@export var visualized_path : VisualizedPath
|
||||||
|
@export var tower_path : Node
|
||||||
var tower_base_scene = load("res://Scenes/tower_base.tscn")
|
var tower_base_scene = load("res://Scenes/tower_base.tscn")
|
||||||
var tower_frame_scene = load("res://Scenes/tower_frame.tscn")
|
var tower_frame_scene = load("res://Scenes/tower_frame.tscn")
|
||||||
var tower_bases = []
|
var tower_bases = []
|
||||||
|
var wall_id = 0
|
||||||
|
|
||||||
|
|
||||||
func toggle_point(point_id):
|
func toggle_point(point_id):
|
||||||
@ -43,11 +45,19 @@ func networked_toggle_point(point_id):
|
|||||||
astar.set_point_disabled(point_id, false)
|
astar.set_point_disabled(point_id, false)
|
||||||
else:
|
else:
|
||||||
astar.set_point_disabled(point_id, true)
|
astar.set_point_disabled(point_id, true)
|
||||||
var base = tower_base_scene.instantiate()
|
|
||||||
base.position = astar.get_point_position(point_id)
|
|
||||||
tower_bases.append(base)
|
|
||||||
add_child(base)
|
|
||||||
find_path()
|
find_path()
|
||||||
|
if is_multiplayer_authority():
|
||||||
|
networked_spawn_wall.rpc(astar.get_point_position(point_id), wall_id)
|
||||||
|
wall_id += 1
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("reliable", "call_local")
|
||||||
|
func networked_spawn_wall(pos : Vector3, name_id : int):
|
||||||
|
var base = tower_base_scene.instantiate()
|
||||||
|
base.position = pos
|
||||||
|
base.name = "Wall" + str(name_id)
|
||||||
|
tower_bases.append(base)
|
||||||
|
tower_path.add_child(base)
|
||||||
|
|
||||||
|
|
||||||
func find_path() -> bool:
|
func find_path() -> bool:
|
||||||
|
@ -58,13 +58,16 @@ func enemy_count_down(enemy):
|
|||||||
func set_upcoming_wave(value):
|
func set_upcoming_wave(value):
|
||||||
var frame_count = 0
|
var frame_count = 0
|
||||||
enemy_names = []
|
enemy_names = []
|
||||||
|
var wave = {}
|
||||||
|
for index in value:
|
||||||
|
wave[Data.enemies[index]] = value[index]
|
||||||
for x in enemy_sprites.size():
|
for x in enemy_sprites.size():
|
||||||
enemy_sprites[x].set_visible(false)
|
enemy_sprites[x].set_visible(false)
|
||||||
enemy_counts[x].set_visible(false)
|
enemy_counts[x].set_visible(false)
|
||||||
for enemy in value:
|
for enemy in wave:
|
||||||
enemy_names.append(enemy.title)
|
enemy_names.append(enemy.title)
|
||||||
enemy_sprites[frame_count].texture = enemy.icon
|
enemy_sprites[frame_count].texture = enemy.icon
|
||||||
enemy_counts[frame_count].text = str(value[enemy])
|
enemy_counts[frame_count].text = str(wave[enemy])
|
||||||
enemy_sprites[frame_count].set_visible(true)
|
enemy_sprites[frame_count].set_visible(true)
|
||||||
enemy_counts[frame_count].set_visible(true)
|
enemy_counts[frame_count].set_visible(true)
|
||||||
frame_count += 1
|
frame_count += 1
|
||||||
@ -87,6 +90,8 @@ func maximise_minimap(anchor):
|
|||||||
minimap.offset_right = -40
|
minimap.offset_right = -40
|
||||||
minimap_viewport.size = Vector2(1840, 1000)
|
minimap_viewport.size = Vector2(1840, 1000)
|
||||||
minimap_cam.size = 30
|
minimap_cam.size = 30
|
||||||
|
$TextureRect3.set_visible(false)
|
||||||
|
$Currency.set_visible(false)
|
||||||
|
|
||||||
|
|
||||||
func minimize_minimap(anchor):
|
func minimize_minimap(anchor):
|
||||||
@ -98,3 +103,5 @@ func minimize_minimap(anchor):
|
|||||||
minimap.offset_bottom = 256
|
minimap.offset_bottom = 256
|
||||||
minimap_viewport.size = Vector2(256, 256)
|
minimap_viewport.size = Vector2(256, 256)
|
||||||
minimap_cam.size = 15
|
minimap_cam.size = 15
|
||||||
|
$TextureRect3.set_visible(true)
|
||||||
|
$Currency.set_visible(true)
|
||||||
|
@ -2,5 +2,5 @@ extends StatusEffect
|
|||||||
class_name StatusOnFire
|
class_name StatusOnFire
|
||||||
|
|
||||||
|
|
||||||
func proc(affected, stacks, existing_effects):
|
func proc(affected, stacks, _existing_effects):
|
||||||
affected.damage(stats.potency * stacks)
|
affected.damage(stats.potency * stacks)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
extends StatusEffect
|
extends StatusEffect
|
||||||
class_name StatusCold
|
class_name StatusCold
|
||||||
|
|
||||||
func on_attached(affected, existing_effects):
|
func on_attached(affected, _existing_effects):
|
||||||
affected.movement_speed_penalty -= stats.potency
|
affected.movement_speed_penalty -= stats.potency
|
||||||
|
|
||||||
|
|
||||||
func on_removed(affected, existing_effects):
|
func on_removed(affected, _existing_effects):
|
||||||
affected.movement_speed_penalty += stats.potency
|
affected.movement_speed_penalty += stats.potency
|
||||||
|
@ -7,13 +7,13 @@ var time_since_proc := 0.0
|
|||||||
var time_existed := 0.0
|
var time_existed := 0.0
|
||||||
|
|
||||||
|
|
||||||
func on_attached(affected, existing_effects):
|
func on_attached(_affected, _existing_effects):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
func on_removed(affected, existing_effects):
|
func on_removed(_affected, _existing_effects):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
func proc(affected, stacks, existing_effects):
|
func proc(_affected, _stacks, _existing_effects):
|
||||||
pass
|
pass
|
||||||
|
@ -2,5 +2,5 @@ extends StatusEffect
|
|||||||
class_name StatusPoison
|
class_name StatusPoison
|
||||||
|
|
||||||
|
|
||||||
func proc(affected, stacks, existing_effects):
|
func proc(affected, stacks, _existing_effects):
|
||||||
affected.damage(stats.potency * stacks)
|
affected.damage(stats.potency * stacks)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
extends StatusEffect
|
extends StatusEffect
|
||||||
class_name StatusRadioactive
|
class_name StatusRadioactive
|
||||||
|
|
||||||
func proc(affected, stacks, existing_effects):
|
func proc(affected, stacks, _existing_effects):
|
||||||
affected.damage(stats.potency * stacks)
|
affected.damage(stats.potency * stacks)
|
||||||
|
@ -2,9 +2,9 @@ extends StatusEffect
|
|||||||
class_name StatusSticky
|
class_name StatusSticky
|
||||||
|
|
||||||
|
|
||||||
func on_attached(affected, existing_effects):
|
func on_attached(affected, _existing_effects):
|
||||||
affected.movement_speed_penalty -= stats.potency
|
affected.movement_speed_penalty -= stats.potency
|
||||||
|
|
||||||
|
|
||||||
func on_removed(affected, existing_effects):
|
func on_removed(affected, _existing_effects):
|
||||||
affected.movement_speed_penalty += stats.potency
|
affected.movement_speed_penalty += stats.potency
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
extends Node3D
|
extends Node3D
|
||||||
class_name EnemySpawner
|
class_name EnemySpawner
|
||||||
|
|
||||||
|
@export var own_id : int = 0
|
||||||
@export var path : VisualizedPath
|
@export var path : VisualizedPath
|
||||||
@export var type : Data.EnemyType
|
@export var type : Data.EnemyType
|
||||||
@export var dest : Node3D
|
@export var dest : Node3D
|
||||||
|
@export var enemy_path : Node
|
||||||
|
|
||||||
var signal_for_after_enemy_died
|
var signal_for_after_enemy_died
|
||||||
var signal_for_after_enemy_reached_goal
|
var signal_for_after_enemy_reached_goal
|
||||||
@ -14,6 +16,7 @@ var enemy_spawn_timers = {}
|
|||||||
var enemies_spawned = {}
|
var enemies_spawned = {}
|
||||||
var enemies_to_spawn := 0
|
var enemies_to_spawn := 0
|
||||||
var done_spawning = true
|
var done_spawning = true
|
||||||
|
var enemy_id = 0
|
||||||
|
|
||||||
@export var land_enemy_scene : PackedScene
|
@export var land_enemy_scene : PackedScene
|
||||||
@export var air_enemy_scene : PackedScene
|
@export var air_enemy_scene : PackedScene
|
||||||
@ -27,40 +30,59 @@ func _process(delta: float) -> void:
|
|||||||
for x in enemy_spawn_timers:
|
for x in enemy_spawn_timers:
|
||||||
if enemies_spawned[x] == current_wave[x]:
|
if enemies_spawned[x] == current_wave[x]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
var enemy_stats = x
|
var enemy_stats = x
|
||||||
enemy_spawn_timers[x] += delta
|
enemy_spawn_timers[x] += delta
|
||||||
|
|
||||||
if enemy_spawn_timers[x] >= enemy_stats.spawn_cooldown:
|
if enemy_spawn_timers[x] >= enemy_stats.spawn_cooldown:
|
||||||
if type == Data.EnemyType.LAND:
|
if is_multiplayer_authority():
|
||||||
var enemy = land_enemy_scene.instantiate() as EnemyController
|
if type == Data.EnemyType.LAND:
|
||||||
enemy.stats = enemy_stats
|
networked_spawn_land_enemy.rpc(var_to_str(enemy_stats), own_id, enemy_id)
|
||||||
enemy.died.connect(signal_for_after_enemy_died)
|
if type == Data.EnemyType.AIR:
|
||||||
enemy.reached_goal.connect(signal_for_after_enemy_reached_goal)
|
var radius = 10.0
|
||||||
enemy.movement_controller.path = path.curve
|
var random_dir = Vector3(randf_range(-1, 1), randf_range(-1, 1), randf_range(-1, 1))
|
||||||
add_child(enemy)
|
var random_pos = randf_range(0, radius) * random_dir.normalized()
|
||||||
enemy_spawn_timers[x] -= enemy_stats.spawn_cooldown
|
networked_spawn_air_enemy.rpc(var_to_str(enemy_stats), random_pos, own_id, enemy_id)
|
||||||
signal_for_when_enemy_spawns.emit()
|
|
||||||
if type == Data.EnemyType.AIR:
|
enemy_spawn_timers[x] -= enemy_stats.spawn_cooldown
|
||||||
var enemy = air_enemy_scene.instantiate() as EnemyController
|
signal_for_when_enemy_spawns.emit()
|
||||||
var radius = 10.0
|
enemy_id += 1
|
||||||
var random_dir = Vector3(randf_range(-1, 1), randf_range(-1, 1), randf_range(-1, 1))
|
|
||||||
var random_pos = randf_range(0, radius) * random_dir.normalized()
|
|
||||||
enemy.position = random_pos
|
|
||||||
enemy.stats = enemy_stats
|
|
||||||
enemy.died.connect(signal_for_after_enemy_died)
|
|
||||||
enemy.reached_goal.connect(signal_for_after_enemy_reached_goal)
|
|
||||||
enemy.movement_controller.goal = dest
|
|
||||||
add_child(enemy)
|
|
||||||
enemy_spawn_timers[x] -= enemy_stats.spawn_cooldown
|
|
||||||
signal_for_when_enemy_spawns.emit()
|
|
||||||
enemies_spawned[x] += 1
|
enemies_spawned[x] += 1
|
||||||
enemies_to_spawn -= 1
|
enemies_to_spawn -= 1
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("reliable", "call_local")
|
||||||
|
func networked_spawn_land_enemy(enemy_stats, id1, id2):
|
||||||
|
var enemy = land_enemy_scene.instantiate() as EnemyController
|
||||||
|
enemy.name = str(id1) + str(id2)
|
||||||
|
enemy.stats = str_to_var(enemy_stats)
|
||||||
|
enemy.died.connect(signal_for_after_enemy_died)
|
||||||
|
enemy.reached_goal.connect(signal_for_after_enemy_reached_goal)
|
||||||
|
enemy.movement_controller.path = path.curve
|
||||||
|
enemy.position = global_position
|
||||||
|
enemy_path.add_child(enemy)
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("reliable", "call_local")
|
||||||
|
func networked_spawn_air_enemy(enemy_stats, pos, id1, id2):
|
||||||
|
var enemy = air_enemy_scene.instantiate() as EnemyController
|
||||||
|
enemy.name = str(id1) + str(id2)
|
||||||
|
enemy.position = pos + global_position
|
||||||
|
enemy.stats = str_to_var(enemy_stats)
|
||||||
|
enemy.died.connect(signal_for_after_enemy_died)
|
||||||
|
enemy.reached_goal.connect(signal_for_after_enemy_reached_goal)
|
||||||
|
enemy.movement_controller.goal = dest
|
||||||
|
enemy_path.add_child(enemy)
|
||||||
|
|
||||||
|
|
||||||
func spawn_wave(value):
|
func spawn_wave(value):
|
||||||
var relevant_enemies = {}
|
var relevant_enemies = {}
|
||||||
for x in value:
|
var wave = {}
|
||||||
|
for index in value:
|
||||||
|
wave[Data.enemies[index]] = value[index]
|
||||||
|
for x in wave:
|
||||||
if x.target_type == type:
|
if x.target_type == type:
|
||||||
relevant_enemies[x] = value[x]
|
relevant_enemies[x] = wave[x]
|
||||||
current_wave = relevant_enemies
|
current_wave = relevant_enemies
|
||||||
enemies_to_spawn = 0
|
enemies_to_spawn = 0
|
||||||
enemy_spawn_timers = {}
|
enemy_spawn_timers = {}
|
||||||
|
@ -81,8 +81,6 @@ func ready_player(_value):
|
|||||||
for key in connected_players_nodes:
|
for key in connected_players_nodes:
|
||||||
if connected_players_nodes[key].ready_state == false:
|
if connected_players_nodes[key].ready_state == false:
|
||||||
return
|
return
|
||||||
for key in connected_players_nodes:
|
|
||||||
connected_players_nodes[key].ready_state = false
|
|
||||||
spawn_enemy_wave()
|
spawn_enemy_wave()
|
||||||
|
|
||||||
|
|
||||||
@ -96,9 +94,18 @@ func spawn_enemy_wave():
|
|||||||
|
|
||||||
|
|
||||||
func set_upcoming_wave():
|
func set_upcoming_wave():
|
||||||
var spawn_power = WaveManager.calculate_spawn_power(wave + 1, connected_players_nodes.size())
|
if is_multiplayer_authority():
|
||||||
upcoming_wave = WaveManager.generate_wave(spawn_power, level.enemy_pool)
|
var spawn_power = WaveManager.calculate_spawn_power(wave + 1, connected_players_nodes.size())
|
||||||
pot = 6 + (spawn_power / 100)
|
var new_wave = WaveManager.generate_wave(spawn_power, level.enemy_pool)
|
||||||
|
networked_set_upcoming_wave.rpc(new_wave, 6 + (spawn_power / 100))
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("reliable", "call_local")
|
||||||
|
func networked_set_upcoming_wave(wave_dict, coins):
|
||||||
|
upcoming_wave = wave_dict
|
||||||
|
pot = coins
|
||||||
|
for key in connected_players_nodes:
|
||||||
|
connected_players_nodes[key].hud.set_upcoming_wave(upcoming_wave)
|
||||||
|
|
||||||
|
|
||||||
func increase_enemy_count():
|
func increase_enemy_count():
|
||||||
@ -137,13 +144,11 @@ func damage_goal(enemy, penalty):
|
|||||||
|
|
||||||
func end_wave():
|
func end_wave():
|
||||||
for peer_id in connected_players_nodes:
|
for peer_id in connected_players_nodes:
|
||||||
connected_players_nodes[peer_id].currency += pot / connected_players_nodes.size()
|
connected_players_nodes[peer_id].currency += ceili(pot / connected_players_nodes.size())
|
||||||
|
connected_players_nodes[peer_id].ready_state = false
|
||||||
level.a_star_graph_3d.visualized_path.enable_visualization()
|
level.a_star_graph_3d.visualized_path.enable_visualization()
|
||||||
wave_finished.emit(wave)
|
wave_finished.emit(wave)
|
||||||
set_upcoming_wave()
|
set_upcoming_wave()
|
||||||
if wave < 20:
|
|
||||||
for key in connected_players_nodes:
|
|
||||||
connected_players_nodes[key].hud.set_upcoming_wave(upcoming_wave)
|
|
||||||
|
|
||||||
|
|
||||||
func remove_player(peer_id):
|
func remove_player(peer_id):
|
||||||
@ -158,7 +163,6 @@ func start_game():
|
|||||||
set_upcoming_wave()
|
set_upcoming_wave()
|
||||||
for peer_id in connected_players_nodes:
|
for peer_id in connected_players_nodes:
|
||||||
connected_players_nodes[peer_id].currency = 20
|
connected_players_nodes[peer_id].currency = 20
|
||||||
connected_players_nodes[peer_id].hud.set_upcoming_wave(upcoming_wave)
|
|
||||||
game_started.emit()
|
game_started.emit()
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,10 +10,10 @@ signal health_changed(health)
|
|||||||
var current_health
|
var current_health
|
||||||
|
|
||||||
func take_damage(damage):
|
func take_damage(damage):
|
||||||
var marker = damage_particle_scene.instantiate()
|
#var marker = damage_particle_scene.instantiate()
|
||||||
get_tree().root.add_child(marker)
|
#get_tree().root.add_child(marker)
|
||||||
marker.set_number(damage)
|
#marker.set_number(damage)
|
||||||
marker.position = get_parent().global_position + Vector3.UP
|
#marker.position = get_parent().global_position + Vector3.UP
|
||||||
|
|
||||||
current_health -= damage
|
current_health -= damage
|
||||||
health_changed.emit(current_health)
|
health_changed.emit(current_health)
|
||||||
@ -25,3 +25,4 @@ func heal_damage(healing):
|
|||||||
current_health += healing
|
current_health += healing
|
||||||
if current_health > max_health:
|
if current_health > max_health:
|
||||||
current_health = max_health
|
current_health = max_health
|
||||||
|
health_changed.emit(current_health)
|
||||||
|
@ -5,9 +5,4 @@ signal took_damage(amount)
|
|||||||
|
|
||||||
|
|
||||||
func damage(amount):
|
func damage(amount):
|
||||||
networked_damage.rpc(amount)
|
|
||||||
|
|
||||||
|
|
||||||
@rpc("any_peer","call_local")
|
|
||||||
func networked_damage(amount):
|
|
||||||
took_damage.emit(amount)
|
took_damage.emit(amount)
|
||||||
|
@ -9,7 +9,7 @@ var contents : Array[Card] = []
|
|||||||
var selected_index := 0
|
var selected_index := 0
|
||||||
var selected_item : Card :
|
var selected_item : Card :
|
||||||
get:
|
get:
|
||||||
return contents[selected_index]
|
return contents[selected_index] if contents.size() > 0 else null
|
||||||
set(_value):
|
set(_value):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -44,6 +44,7 @@ func increment_selected():
|
|||||||
selected_index += 1
|
selected_index += 1
|
||||||
if selected_index >= contents.size():
|
if selected_index >= contents.size():
|
||||||
selected_index = 0
|
selected_index = 0
|
||||||
|
networked_set_selected.rpc(selected_index)
|
||||||
|
|
||||||
|
|
||||||
func decrement_selected():
|
func decrement_selected():
|
||||||
@ -51,16 +52,22 @@ func decrement_selected():
|
|||||||
selected_index -= 1
|
selected_index -= 1
|
||||||
if selected_index < 0:
|
if selected_index < 0:
|
||||||
selected_index = contents.size() - 1
|
selected_index = contents.size() - 1
|
||||||
|
networked_set_selected.rpc(selected_index)
|
||||||
|
|
||||||
|
|
||||||
@rpc("reliable")
|
@rpc("reliable", "any_peer")
|
||||||
func networked_add(value):
|
func networked_add(value):
|
||||||
contents.append(Data.cards[value])
|
contents.append(Data.cards[value])
|
||||||
item_added.emit(Data.cards[value])
|
item_added.emit(Data.cards[value])
|
||||||
|
|
||||||
|
|
||||||
@rpc("reliable")
|
@rpc("reliable", "any_peer")
|
||||||
func networked_remove_at(value):
|
func networked_remove_at(value):
|
||||||
var item = contents[value]
|
var item = contents[value]
|
||||||
contents.remove_at(value)
|
contents.remove_at(value)
|
||||||
item_removed.emit(item)
|
item_removed.emit(item)
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("reliable", "any_peer")
|
||||||
|
func networked_set_selected(value):
|
||||||
|
selected_index = value
|
||||||
|
@ -17,17 +17,12 @@ var has_card : bool :
|
|||||||
func add_card(card: Card) -> bool:
|
func add_card(card: Card) -> bool:
|
||||||
var result = inventory.add(card)
|
var result = inventory.add(card)
|
||||||
if result:
|
if result:
|
||||||
tower = card.turret.instantiate() as Tower
|
networked_spawn_tower.rpc()
|
||||||
tower.stats = card.tower_stats
|
|
||||||
minimap_icon.modulate = Color.RED
|
|
||||||
add_child(tower)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
func remove_card() -> Card:
|
func remove_card() -> Card:
|
||||||
tower.queue_free()
|
networked_remove_tower.rpc()
|
||||||
tower = null
|
|
||||||
minimap_icon.modulate = Color.GREEN
|
|
||||||
return inventory.remove()
|
return inventory.remove()
|
||||||
|
|
||||||
|
|
||||||
@ -37,3 +32,19 @@ func set_material(value: StandardMaterial3D):
|
|||||||
|
|
||||||
func toggle_collision():
|
func toggle_collision():
|
||||||
collider.disabled = !collider.disabled
|
collider.disabled = !collider.disabled
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("reliable", "call_local", "any_peer")
|
||||||
|
func networked_spawn_tower():
|
||||||
|
tower = inventory.selected_item.turret.instantiate() as Tower
|
||||||
|
tower.stats = inventory.selected_item.tower_stats
|
||||||
|
tower.name = "tower"
|
||||||
|
minimap_icon.modulate = Color.RED
|
||||||
|
add_child(tower)
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("reliable", "call_local", "any_peer")
|
||||||
|
func networked_remove_tower():
|
||||||
|
tower.queue_free()
|
||||||
|
tower = null
|
||||||
|
minimap_icon.modulate = Color.GREEN
|
||||||
|
@ -15,7 +15,7 @@ func generate_wave(spawn_power : int, spawn_pool : Array[Enemy]) -> Dictionary:
|
|||||||
var choice = enemy_choices.pick_random()
|
var choice = enemy_choices.pick_random()
|
||||||
enemy_choices.erase(choice)
|
enemy_choices.erase(choice)
|
||||||
if sp_allotment / choice.spawn_power > 0:
|
if sp_allotment / choice.spawn_power > 0:
|
||||||
wave[choice] = sp_allotment / choice.spawn_power
|
wave[Data.enemies.find(choice)] = sp_allotment / choice.spawn_power
|
||||||
#sp_used += wave[choice] * choice.spawn_power
|
#sp_used += wave[choice] * choice.spawn_power
|
||||||
#print("tried to generate wave with " + str(spawn_power) + " spawn power, used " + str(sp_used))
|
#print("tried to generate wave with " + str(spawn_power) + " spawn power, used " + str(sp_used))
|
||||||
return wave
|
return wave
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
extends CharacterBody3D
|
|
||||||
class_name AirEnemyController
|
|
||||||
|
|
||||||
signal reached_goal(enemy, penalty)
|
|
||||||
signal died(enemy)
|
|
||||||
|
|
||||||
var alive = true
|
|
||||||
|
|
||||||
@export var stats : Enemy
|
|
||||||
@export var status_manager : StatusEffector
|
|
||||||
|
|
||||||
var movement_speed
|
|
||||||
var movement_speed_penalty := 1.0
|
|
||||||
var progress := 0.0
|
|
||||||
var progress_ratio := 0.0
|
|
||||||
var destination : Node3D
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
$Health.max_health = stats.health
|
|
||||||
$Health.current_health = stats.health
|
|
||||||
$SubViewport/ProgressBar.max_value = stats.health
|
|
||||||
$SubViewport/ProgressBar.value = stats.health
|
|
||||||
$Sprite3D3.texture = stats.sprite.duplicate()
|
|
||||||
movement_speed = stats.movement_speed
|
|
||||||
|
|
||||||
|
|
||||||
func damage(amount):
|
|
||||||
$Hitbox.damage(amount)
|
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
|
||||||
progress += (movement_speed * clampf(movement_speed_penalty, 0.0, 1.0)) * delta
|
|
||||||
velocity = global_position.direction_to(destination.global_position) * (movement_speed * clampf(movement_speed_penalty, 0.0, 1.0))
|
|
||||||
move_and_slide()
|
|
||||||
if global_position.distance_to(destination.global_position) <= 1.0:
|
|
||||||
reached_goal.emit(stats, stats.penalty)
|
|
||||||
queue_free()
|
|
||||||
|
|
||||||
|
|
||||||
func die():
|
|
||||||
died.emit(stats)
|
|
||||||
queue_free()
|
|
||||||
|
|
||||||
|
|
||||||
func _on_health_health_depleted() -> void:
|
|
||||||
if alive:
|
|
||||||
alive = false
|
|
||||||
die()
|
|
||||||
|
|
||||||
|
|
||||||
func _on_health_health_changed(health) -> void:
|
|
||||||
$SubViewport/ProgressBar.value = health
|
|
||||||
var percent = float($Health.current_health) / float($Health.max_health)
|
|
||||||
$SubViewport/ProgressBar.tint_progress = Color(1 - percent, percent, 0.0)
|
|
||||||
$SubViewport/ProgressBar.set_visible(true)
|
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_21dgw"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_21dgw"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_73qac"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ln1wo"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
atlas = ExtResource("3_naknq")
|
atlas = ExtResource("3_naknq")
|
||||||
region = Rect2(0, 0, 32, 32)
|
region = Rect2(0, 0, 32, 32)
|
||||||
@ -41,7 +41,7 @@ script = ExtResource("2_j8yin")
|
|||||||
[node name="DirectionSprite" parent="." instance=ExtResource("2_o7jmg")]
|
[node name="DirectionSprite" parent="." instance=ExtResource("2_o7jmg")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.642479, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.642479, 0)
|
||||||
pixel_size = 0.04
|
pixel_size = 0.04
|
||||||
texture = SubResource("AtlasTexture_73qac")
|
texture = SubResource("AtlasTexture_ln1wo")
|
||||||
|
|
||||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||||
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 1.20821, 0)
|
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 1.20821, 0)
|
||||||
|
@ -74,16 +74,19 @@ shape = SubResource("BoxShape3D_awjk1")
|
|||||||
curve = SubResource("Curve3D_suxqu")
|
curve = SubResource("Curve3D_suxqu")
|
||||||
script = ExtResource("11_d7ofl")
|
script = ExtResource("11_d7ofl")
|
||||||
|
|
||||||
[node name="GroundSpawn" parent="." node_paths=PackedStringArray("path", "dest") instance=ExtResource("3_5imwp")]
|
[node name="GroundSpawn" parent="." node_paths=PackedStringArray("path", "dest", "enemy_path") instance=ExtResource("3_5imwp")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -20, 0.5, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -20, 0.5, 0)
|
||||||
path = NodePath("../VisualizedPath")
|
path = NodePath("../VisualizedPath")
|
||||||
type = 1
|
type = 1
|
||||||
dest = NodePath("../EnemyGoal")
|
dest = NodePath("../EnemyGoal")
|
||||||
|
enemy_path = NodePath("../Enemies")
|
||||||
|
|
||||||
[node name="AirSpawn" parent="." node_paths=PackedStringArray("dest") instance=ExtResource("3_5imwp")]
|
[node name="AirSpawn" parent="." node_paths=PackedStringArray("dest", "enemy_path") instance=ExtResource("3_5imwp")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -47.0801, 22.5492, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -47.0801, 22.5492, 0)
|
||||||
|
own_id = 1
|
||||||
type = 2
|
type = 2
|
||||||
dest = NodePath("../EnemyGoal")
|
dest = NodePath("../EnemyGoal")
|
||||||
|
enemy_path = NodePath("../Enemies")
|
||||||
|
|
||||||
[node name="CardPrinter" parent="." instance=ExtResource("9_r25gu")]
|
[node name="CardPrinter" parent="." instance=ExtResource("9_r25gu")]
|
||||||
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 25.1496, 0.499996, 5.79039)
|
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 25.1496, 0.499996, 5.79039)
|
||||||
@ -530,7 +533,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 1, 1)
|
|||||||
[node name="PlayerSpawn4" type="Node3D" parent="PlayerSpawnLocations"]
|
[node name="PlayerSpawn4" type="Node3D" parent="PlayerSpawnLocations"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1)
|
||||||
|
|
||||||
[node name="AStarGraph3D" type="Node3D" parent="." node_paths=PackedStringArray("start", "end", "spawner", "visualized_path")]
|
[node name="AStarGraph3D" type="Node3D" parent="." node_paths=PackedStringArray("start", "end", "spawner", "visualized_path", "tower_path")]
|
||||||
script = ExtResource("11_07ukk")
|
script = ExtResource("11_07ukk")
|
||||||
grid_size = Vector2(19, 9)
|
grid_size = Vector2(19, 9)
|
||||||
point_gap = 1.5
|
point_gap = 1.5
|
||||||
@ -538,6 +541,7 @@ start = NodePath("../GroundSpawn")
|
|||||||
end = NodePath("../EnemyGoal")
|
end = NodePath("../EnemyGoal")
|
||||||
spawner = NodePath("../GroundSpawn")
|
spawner = NodePath("../GroundSpawn")
|
||||||
visualized_path = NodePath("../VisualizedPath")
|
visualized_path = NodePath("../VisualizedPath")
|
||||||
|
tower_path = NodePath("../Towers")
|
||||||
|
|
||||||
[node name="InvisibleWalls" type="Node3D" parent="."]
|
[node name="InvisibleWalls" type="Node3D" parent="."]
|
||||||
|
|
||||||
@ -573,4 +577,8 @@ collision_mask = 0
|
|||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="InvisibleWalls/StaticBody3D4"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="InvisibleWalls/StaticBody3D4"]
|
||||||
shape = SubResource("BoxShape3D_kkwvm")
|
shape = SubResource("BoxShape3D_kkwvm")
|
||||||
|
|
||||||
|
[node name="Towers" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="Enemies" type="Node" parent="."]
|
||||||
|
|
||||||
[connection signal="body_entered" from="EnemyGoal/Area3D" to="EnemyGoal" method="_on_area_3d_body_entered"]
|
[connection signal="body_entered" from="EnemyGoal/Area3D" to="EnemyGoal" method="_on_area_3d_body_entered"]
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user