made the first changes towards multiplayer working
This commit is contained in:
@ -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="AtlasTexture" id="AtlasTexture_73qac"]
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ln1wo"]
|
||||
resource_local_to_scene = true
|
||||
atlas = ExtResource("3_naknq")
|
||||
region = Rect2(0, 0, 32, 32)
|
||||
@ -41,7 +41,7 @@ script = ExtResource("2_j8yin")
|
||||
[node name="DirectionSprite" parent="." instance=ExtResource("2_o7jmg")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.642479, 0)
|
||||
pixel_size = 0.04
|
||||
texture = SubResource("AtlasTexture_73qac")
|
||||
texture = SubResource("AtlasTexture_ln1wo")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
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")
|
||||
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)
|
||||
path = NodePath("../VisualizedPath")
|
||||
type = 1
|
||||
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)
|
||||
own_id = 1
|
||||
type = 2
|
||||
dest = NodePath("../EnemyGoal")
|
||||
enemy_path = NodePath("../Enemies")
|
||||
|
||||
[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)
|
||||
@ -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"]
|
||||
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")
|
||||
grid_size = Vector2(19, 9)
|
||||
point_gap = 1.5
|
||||
@ -538,6 +541,7 @@ start = NodePath("../GroundSpawn")
|
||||
end = NodePath("../EnemyGoal")
|
||||
spawner = NodePath("../GroundSpawn")
|
||||
visualized_path = NodePath("../VisualizedPath")
|
||||
tower_path = NodePath("../Towers")
|
||||
|
||||
[node name="InvisibleWalls" type="Node3D" parent="."]
|
||||
|
||||
@ -573,4 +577,8 @@ collision_mask = 0
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="InvisibleWalls/StaticBody3D4"]
|
||||
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"]
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user