feat: 添加敌人并且追踪player,同时避免敌人重叠
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
extends Node
|
||||
|
||||
|
||||
var player: Player
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
uid://ck4yt74lql4eq
|
||||
@@ -15,6 +15,10 @@ run/main_scene="uid://cgljr7wcstmyp"
|
||||
config/features=PackedStringArray("4.6", "Mobile")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
||||
Global="*uid://ck4yt74lql4eq"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1920
|
||||
@@ -49,6 +53,11 @@ dash={
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
2d_physics/layer_1="Player"
|
||||
2d_physics/layer_2="Enemy"
|
||||
|
||||
[physics]
|
||||
|
||||
3d/physics_engine="Jolt Physics"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
[gd_resource type="Resource" script_class="UnitStats" format=3 uid="uid://delxlqjos3br"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://emsi6ifyt0vf" path="res://assets/sprites/Enemies/Enemy_5.png" id="1_ab1gs"]
|
||||
[ext_resource type="Script" uid="uid://dgjdpmaiufhs6" path="res://resources/units/unit_stats.gd" id="2_mh3yp"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_mh3yp")
|
||||
name = "Charger"
|
||||
type = 1
|
||||
icon = ExtResource("1_ab1gs")
|
||||
health = 8
|
||||
health_increase_per_wave = 3.0
|
||||
damage = 2.5
|
||||
damage_increase_per_wave = 2.0
|
||||
speed = 280
|
||||
luck = 0.0
|
||||
block_chance = 6.0
|
||||
gold_drop = 3
|
||||
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
||||
@@ -0,0 +1,19 @@
|
||||
[gd_resource type="Resource" script_class="UnitStats" format=3 uid="uid://cv3187t7wsfxh"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c6vplmpl4q4jr" path="res://assets/sprites/Enemies/Enemy_3.png" id="1_ymlpp"]
|
||||
[ext_resource type="Script" uid="uid://dgjdpmaiufhs6" path="res://resources/units/unit_stats.gd" id="2_86dbv"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_86dbv")
|
||||
name = "Chaser Fast"
|
||||
type = 1
|
||||
icon = ExtResource("1_ymlpp")
|
||||
health = 6
|
||||
health_increase_per_wave = 2.5
|
||||
damage = 1.5
|
||||
damage_increase_per_wave = 1.5
|
||||
speed = 350
|
||||
luck = 0.0
|
||||
block_chance = 5.0
|
||||
gold_drop = 2
|
||||
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
||||
@@ -0,0 +1,17 @@
|
||||
[gd_resource type="Resource" script_class="UnitStats" format=3 uid="uid://db0igkyfvumk7"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bf4ls8ho3cuqa" path="res://assets/sprites/Enemies/Enemy_2.png" id="1_gkg84"]
|
||||
[ext_resource type="Script" uid="uid://dgjdpmaiufhs6" path="res://resources/units/unit_stats.gd" id="2_o5vp8"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_o5vp8")
|
||||
name = "Chaser Mid"
|
||||
type = 1
|
||||
icon = ExtResource("1_gkg84")
|
||||
health = 8
|
||||
health_increase_per_wave = 2.0
|
||||
damage = 2.0
|
||||
luck = 0.0
|
||||
block_chance = 7.0
|
||||
gold_drop = 2
|
||||
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
||||
@@ -0,0 +1,16 @@
|
||||
[gd_resource type="Resource" script_class="UnitStats" format=3 uid="uid://bn4dskgwnahaq"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://d1ou504pylric" path="res://assets/sprites/Enemies/Enemy_1.png" id="1_cneyk"]
|
||||
[ext_resource type="Script" uid="uid://dgjdpmaiufhs6" path="res://resources/units/unit_stats.gd" id="1_m42qi"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_m42qi")
|
||||
name = "Chaser Slow"
|
||||
type = 1
|
||||
icon = ExtResource("1_cneyk")
|
||||
health = 6
|
||||
damage = 1.5
|
||||
speed = 250
|
||||
luck = 0.0
|
||||
block_chance = 3.0
|
||||
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
||||
@@ -0,0 +1,19 @@
|
||||
[gd_resource type="Resource" script_class="UnitStats" format=3 uid="uid://bnknrm368mpwb"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://4mllmwdfhmce" path="res://assets/sprites/Enemies/Enemy_4.png" id="1_llpja"]
|
||||
[ext_resource type="Script" uid="uid://dgjdpmaiufhs6" path="res://resources/units/unit_stats.gd" id="2_1vxf5"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_1vxf5")
|
||||
name = "Shooter"
|
||||
type = 1
|
||||
icon = ExtResource("1_llpja")
|
||||
health = 4
|
||||
health_increase_per_wave = 2.0
|
||||
damage = 3.0
|
||||
damage_increase_per_wave = 1.5
|
||||
speed = 260
|
||||
luck = 0.0
|
||||
block_chance = 3.0
|
||||
gold_drop = 3
|
||||
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
||||
@@ -0,0 +1,18 @@
|
||||
[gd_resource type="Resource" script_class="UnitStats" format=3 uid="uid://dhbwq0p1appau"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dpxw8tsbgrfse" path="res://assets/sprites/Players/Player_2.png" id="1_artcn"]
|
||||
[ext_resource type="Script" uid="uid://dgjdpmaiufhs6" path="res://resources/units/unit_stats.gd" id="1_fokdh"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_fokdh")
|
||||
name = "Brawler"
|
||||
icon = ExtResource("1_artcn")
|
||||
health = 25
|
||||
health_increase_per_wave = 0.0
|
||||
damage = 4
|
||||
damage_increase_per_wave = 0.0
|
||||
speed = 270
|
||||
luck = 3.0
|
||||
block_chance = 5.0
|
||||
gold_drop = 0
|
||||
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
||||
@@ -0,0 +1,18 @@
|
||||
[gd_resource type="Resource" script_class="UnitStats" format=3 uid="uid://ceyne237du1"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dgjdpmaiufhs6" path="res://resources/units/unit_stats.gd" id="1_02km3"]
|
||||
[ext_resource type="Texture2D" uid="uid://dmox6e28kf6ax" path="res://assets/sprites/Players/Player_4.png" id="1_ul0bi"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_02km3")
|
||||
name = "Bunny"
|
||||
icon = ExtResource("1_ul0bi")
|
||||
health = 20
|
||||
health_increase_per_wave = 0.0
|
||||
damage = 5
|
||||
damage_increase_per_wave = 0.0
|
||||
speed = 325
|
||||
luck = 5.0
|
||||
block_chance = 3.0
|
||||
gold_drop = 0
|
||||
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
||||
@@ -0,0 +1,18 @@
|
||||
[gd_resource type="Resource" script_class="UnitStats" format=3 uid="uid://cuj1u77pg06ah"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dq63ocnu3lset" path="res://assets/sprites/Players/Player_3}.png" id="1_6fhtk"]
|
||||
[ext_resource type="Script" uid="uid://dgjdpmaiufhs6" path="res://resources/units/unit_stats.gd" id="2_olwl6"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_olwl6")
|
||||
name = "Crazy"
|
||||
icon = ExtResource("1_6fhtk")
|
||||
health = 15
|
||||
health_increase_per_wave = 0.0
|
||||
damage = 3
|
||||
damage_increase_per_wave = 0.0
|
||||
speed = 350
|
||||
luck = 5.0
|
||||
block_chance = 5.0
|
||||
gold_drop = 0
|
||||
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
||||
@@ -0,0 +1,17 @@
|
||||
[gd_resource type="Resource" script_class="UnitStats" format=3 uid="uid://crhkwist448wy"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bt0lww88864ws" path="res://assets/sprites/Players/Player_5.png" id="1_ujefh"]
|
||||
[ext_resource type="Script" uid="uid://dgjdpmaiufhs6" path="res://resources/units/unit_stats.gd" id="2_xvmk0"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_xvmk0")
|
||||
name = "Knight"
|
||||
icon = ExtResource("1_ujefh")
|
||||
health = 30
|
||||
health_increase_per_wave = 0.0
|
||||
damage = 6
|
||||
damage_increase_per_wave = 0.0
|
||||
speed = 260
|
||||
block_chance = 10.0
|
||||
gold_drop = 0
|
||||
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
||||
@@ -0,0 +1,17 @@
|
||||
[gd_resource type="Resource" script_class="UnitStats" format=3 uid="uid://btnfef0ui2ju8"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cproxhccob85g" path="res://assets/sprites/Players/Player_1.png" id="1_6skj5"]
|
||||
[ext_resource type="Script" uid="uid://dgjdpmaiufhs6" path="res://resources/units/unit_stats.gd" id="1_g5q6j"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_g5q6j")
|
||||
name = "Well Rounded"
|
||||
icon = ExtResource("1_6skj5")
|
||||
health = 15
|
||||
health_increase_per_wave = 0.0
|
||||
damage = 3
|
||||
damage_increase_per_wave = 0.0
|
||||
luck = 5.0
|
||||
block_chance = 1.0
|
||||
gold_drop = 0
|
||||
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
||||
@@ -0,0 +1,19 @@
|
||||
extends Resource
|
||||
class_name UnitStats
|
||||
|
||||
enum UnitType {
|
||||
PLAYER,
|
||||
ENEMY
|
||||
}
|
||||
|
||||
@export var name: String
|
||||
@export var type: UnitType
|
||||
@export var icon: Texture2D
|
||||
@export var health := 1
|
||||
@export var health_increase_per_wave := 1.0
|
||||
@export var damage := 1.0
|
||||
@export var damage_increase_per_wave := 1.0
|
||||
@export var speed := 300
|
||||
@export var luck := 1.0
|
||||
@export var block_chance := 0.0
|
||||
@export var gold_drop := 1
|
||||
@@ -0,0 +1 @@
|
||||
uid://dgjdpmaiufhs6
|
||||
@@ -0,0 +1,13 @@
|
||||
extends Node2D
|
||||
class_name Arena
|
||||
|
||||
@export var player: Player
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
Global.player = player
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
uid://3v66wxbdeto5
|
||||
@@ -0,0 +1,34 @@
|
||||
[gd_scene format=3 uid="uid://dy355015qgab6"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cy4xfx762bxgb" path="res://assets/sprites/BG.png" id="1_8trdl"]
|
||||
[ext_resource type="Script" uid="uid://3v66wxbdeto5" path="res://scenes/arena/arena.gd" id="1_asdgj"]
|
||||
[ext_resource type="Texture2D" uid="uid://ov4fmsbglo55" path="res://assets/sprites/Map.png" id="2_5tue2"]
|
||||
[ext_resource type="PackedScene" uid="uid://cgljr7wcstmyp" path="res://scenes/unit/players/player_well_rounded.tscn" id="3_5tue2"]
|
||||
[ext_resource type="Script" uid="uid://cegcsi6n6r4gv" path="res://scenes/arena/camera_2d.gd" id="4_aj7ud"]
|
||||
[ext_resource type="PackedScene" uid="uid://bfuqhhe8r8asg" path="res://scenes/unit/enemy/enemy_chaser_slow.tscn" id="6_jx0ua"]
|
||||
|
||||
[node name="Arena" type="Node2D" unique_id=1021720471 node_paths=PackedStringArray("player")]
|
||||
script = ExtResource("1_asdgj")
|
||||
player = NodePath("PlayerWellRounded")
|
||||
|
||||
[node name="BlackBG" type="Sprite2D" parent="." unique_id=29383651]
|
||||
scale = Vector2(2, 2)
|
||||
texture = ExtResource("1_8trdl")
|
||||
|
||||
[node name="GrassBG" type="Sprite2D" parent="." unique_id=1846603042]
|
||||
scale = Vector2(2, 2)
|
||||
texture = ExtResource("2_5tue2")
|
||||
|
||||
[node name="PlayerWellRounded" parent="." unique_id=2022554550 instance=ExtResource("3_5tue2")]
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="." unique_id=758039070]
|
||||
script = ExtResource("4_aj7ud")
|
||||
|
||||
[node name="EnemyChaserSlow" parent="." unique_id=2092979720 instance=ExtResource("6_jx0ua")]
|
||||
position = Vector2(-493, 26)
|
||||
|
||||
[node name="EnemyChaserSlow2" parent="." unique_id=1388344292 instance=ExtResource("6_jx0ua")]
|
||||
position = Vector2(-382, 165)
|
||||
|
||||
[node name="EnemyChaserSlow3" parent="." unique_id=597651166 instance=ExtResource("6_jx0ua")]
|
||||
position = Vector2(-385, -141)
|
||||
@@ -0,0 +1,13 @@
|
||||
extends Camera2D
|
||||
class_name Camera
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if is_instance_valid(Global.player):
|
||||
global_position = Global.player.position
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
uid://cegcsi6n6r4gv
|
||||
@@ -0,0 +1,57 @@
|
||||
extends Unit
|
||||
class_name Enemy
|
||||
|
||||
@export var flock_push := 20.0
|
||||
|
||||
@onready var vision_area: Area2D = $VisionArea
|
||||
|
||||
var can_move := true
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if not can_move:
|
||||
return
|
||||
|
||||
if not can_move_forwards_player():
|
||||
return
|
||||
|
||||
position += get_move_direction() * stats.speed * delta
|
||||
|
||||
update_rotate()
|
||||
|
||||
|
||||
func get_move_direction() -> Vector2:
|
||||
|
||||
if not is_instance_valid(Global.player):
|
||||
return Vector2.ZERO
|
||||
|
||||
var direction := global_position.direction_to(Global.player.position)
|
||||
|
||||
for area: Node2D in vision_area.get_overlapping_areas():
|
||||
if area != self and area.is_inside_tree():
|
||||
var vector := global_position - area.global_position
|
||||
direction += flock_push * vector.normalized() / vector.length()
|
||||
|
||||
return direction
|
||||
|
||||
func update_rotate() -> void:
|
||||
if is_instance_valid(Global.player):
|
||||
return
|
||||
|
||||
var player_pos := Global.player.position
|
||||
|
||||
var moving_right := global_position.x < player_pos.x
|
||||
visuals.scale = Vector2(-0.5,0.5) if moving_right else Vector2(0.5,0.5)
|
||||
|
||||
func can_move_forwards_player() -> bool:
|
||||
return is_instance_valid(Global.player) and\
|
||||
global_position.distance_to(Global.player.position) > 60
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://b5j2awtdd1a4a
|
||||
@@ -0,0 +1,11 @@
|
||||
[gd_scene format=3 uid="uid://bot1mnbk3iu11"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bfuqhhe8r8asg" path="res://scenes/unit/enemy/enemy_chaser_slow.tscn" id="1_ksdef"]
|
||||
[ext_resource type="Resource" uid="uid://delxlqjos3br" path="res://resources/units/enemies/stats_enemy_charger.tres" id="2_4i178"]
|
||||
[ext_resource type="Texture2D" uid="uid://emsi6ifyt0vf" path="res://assets/sprites/Enemies/Enemy_5.png" id="2_knpng"]
|
||||
|
||||
[node name="EnemyCharger" unique_id=2092979720 instance=ExtResource("1_ksdef")]
|
||||
stats = ExtResource("2_4i178")
|
||||
|
||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="1" unique_id=1925870318]
|
||||
texture = ExtResource("2_knpng")
|
||||
@@ -0,0 +1,11 @@
|
||||
[gd_scene format=3 uid="uid://s6tc5m2wg178"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bfuqhhe8r8asg" path="res://scenes/unit/enemy/enemy_chaser_slow.tscn" id="1_yb8ih"]
|
||||
[ext_resource type="Texture2D" uid="uid://c6vplmpl4q4jr" path="res://assets/sprites/Enemies/Enemy_3.png" id="2_fw3op"]
|
||||
[ext_resource type="Resource" uid="uid://cv3187t7wsfxh" path="res://resources/units/enemies/stats_enemy_chaser_fast.tres" id="2_p0tt2"]
|
||||
|
||||
[node name="EnemyChaserFast" unique_id=2092979720 instance=ExtResource("1_yb8ih")]
|
||||
stats = ExtResource("2_p0tt2")
|
||||
|
||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="1" unique_id=1925870318]
|
||||
texture = ExtResource("2_fw3op")
|
||||
@@ -0,0 +1,11 @@
|
||||
[gd_scene format=3 uid="uid://c151jxi18d6uo"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bfuqhhe8r8asg" path="res://scenes/unit/enemy/enemy_chaser_slow.tscn" id="1_qulsm"]
|
||||
[ext_resource type="Texture2D" uid="uid://bf4ls8ho3cuqa" path="res://assets/sprites/Enemies/Enemy_2.png" id="2_aqv7o"]
|
||||
[ext_resource type="Resource" uid="uid://db0igkyfvumk7" path="res://resources/units/enemies/stats_enemy_chaser_mid.tres" id="2_w0b3r"]
|
||||
|
||||
[node name="EnemyChaserMid" unique_id=2092979720 instance=ExtResource("1_qulsm")]
|
||||
stats = ExtResource("2_w0b3r")
|
||||
|
||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="1" unique_id=1925870318]
|
||||
texture = ExtResource("2_aqv7o")
|
||||
@@ -0,0 +1,34 @@
|
||||
[gd_scene format=3 uid="uid://bfuqhhe8r8asg"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://d2l68snnemcet" path="res://scenes/unit/unit.tscn" id="1_dd0vi"]
|
||||
[ext_resource type="Script" uid="uid://b5j2awtdd1a4a" path="res://scenes/unit/enemy/enemy.gd" id="2_lmqbh"]
|
||||
[ext_resource type="Texture2D" uid="uid://d1ou504pylric" path="res://assets/sprites/Enemies/Enemy_1.png" id="2_oo7ju"]
|
||||
[ext_resource type="Resource" uid="uid://bn4dskgwnahaq" path="res://resources/units/enemies/stats_enemy_chaser_slow.tres" id="3_lmqbh"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_e15k4"]
|
||||
radius = 31.016125
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_lmqbh"]
|
||||
radius = 150.0
|
||||
|
||||
[node name="EnemyChaserSlow" unique_id=2092979720 instance=ExtResource("1_dd0vi")]
|
||||
collision_layer = 2
|
||||
script = ExtResource("2_lmqbh")
|
||||
flock_push = 20.0
|
||||
stats = ExtResource("3_lmqbh")
|
||||
|
||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="1" unique_id=1925870318]
|
||||
texture = ExtResource("2_oo7ju")
|
||||
|
||||
[node name="CollisionShape2D" parent="." index="1" unique_id=139786467]
|
||||
position = Vector2(0, -30)
|
||||
shape = SubResource("CircleShape2D_e15k4")
|
||||
debug_color = Color(0.97292477, 0.10649621, 0.32710177, 0.41960785)
|
||||
|
||||
[node name="VisionArea" type="Area2D" parent="." index="3" unique_id=466967301]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="VisionArea" index="0" unique_id=715489053]
|
||||
position = Vector2(0, -25)
|
||||
shape = SubResource("CircleShape2D_lmqbh")
|
||||
@@ -0,0 +1,11 @@
|
||||
[gd_scene format=3 uid="uid://cb24l2xfnn7fy"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bfuqhhe8r8asg" path="res://scenes/unit/enemy/enemy_chaser_slow.tscn" id="1_tty1r"]
|
||||
[ext_resource type="Resource" uid="uid://bnknrm368mpwb" path="res://resources/units/enemies/stats_enemy_shooter.tres" id="2_6k67w"]
|
||||
[ext_resource type="Texture2D" uid="uid://4mllmwdfhmce" path="res://assets/sprites/Enemies/Enemy_4.png" id="2_tev67"]
|
||||
|
||||
[node name="EnemyShooter" unique_id=2092979720 instance=ExtResource("1_tty1r")]
|
||||
stats = ExtResource("2_6k67w")
|
||||
|
||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="1" unique_id=1925870318]
|
||||
texture = ExtResource("2_tev67")
|
||||
@@ -8,6 +8,7 @@ class_name Player
|
||||
@onready var dash_timer: Timer = $DashTimer
|
||||
@onready var dash_cooldown_timer: Timer = $DashCooldownTimer
|
||||
@onready var collision: CollisionShape2D = $CollisionShape2D
|
||||
@onready var trail: Trail = %Trail
|
||||
|
||||
var move_dir: Vector2
|
||||
var is_dashing := false
|
||||
@@ -24,12 +25,15 @@ func _ready() -> void:
|
||||
func _process(delta: float) -> void:
|
||||
move_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
|
||||
var current_velocity := move_dir * 500
|
||||
var current_velocity := move_dir * stats.speed
|
||||
if is_dashing:
|
||||
current_velocity *= dash_speed_multi
|
||||
|
||||
position += current_velocity * delta
|
||||
|
||||
position.x = clamp(position.x, -1000, 1000)
|
||||
position.y = clamp(position.y, -500, 500)
|
||||
|
||||
if can_dash():
|
||||
start_dash()
|
||||
|
||||
@@ -54,6 +58,7 @@ func update_rotation() -> void:
|
||||
func start_dash() -> void:
|
||||
is_dashing = true
|
||||
dash_timer.start()
|
||||
trail.start_trail()
|
||||
visuals.modulate.a = 0.5
|
||||
collision.set_deferred("disabled",true)
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[gd_scene format=3 uid="uid://deqpkmjaerop3"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cgljr7wcstmyp" path="res://scenes/unit/players/player_well_rounded.tscn" id="1_t1ilm"]
|
||||
[ext_resource type="Resource" uid="uid://dhbwq0p1appau" path="res://resources/units/players/stats_player_brawler.tres" id="2_k813p"]
|
||||
[ext_resource type="Texture2D" uid="uid://dpxw8tsbgrfse" path="res://assets/sprites/Players/Player_2.png" id="2_tvi6w"]
|
||||
|
||||
[node name="PlayerBrawler" unique_id=2022554550 instance=ExtResource("1_t1ilm")]
|
||||
stats = ExtResource("2_k813p")
|
||||
|
||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="2" unique_id=1925870318]
|
||||
texture = ExtResource("2_tvi6w")
|
||||
@@ -0,0 +1,11 @@
|
||||
[gd_scene format=3 uid="uid://3ous2yjlqlki"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cgljr7wcstmyp" path="res://scenes/unit/players/player_well_rounded.tscn" id="1_tex7i"]
|
||||
[ext_resource type="Resource" uid="uid://ceyne237du1" path="res://resources/units/players/stats_player_bunny.tres" id="2_da4ie"]
|
||||
[ext_resource type="Texture2D" uid="uid://dmox6e28kf6ax" path="res://assets/sprites/Players/Player_4.png" id="2_lbt10"]
|
||||
|
||||
[node name="PlayerBunny" unique_id=2022554550 instance=ExtResource("1_tex7i")]
|
||||
stats = ExtResource("2_da4ie")
|
||||
|
||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="2" unique_id=1925870318]
|
||||
texture = ExtResource("2_lbt10")
|
||||
@@ -0,0 +1,11 @@
|
||||
[gd_scene format=3 uid="uid://qaqitaf84hdm"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cgljr7wcstmyp" path="res://scenes/unit/players/player_well_rounded.tscn" id="1_5054k"]
|
||||
[ext_resource type="Resource" uid="uid://cuj1u77pg06ah" path="res://resources/units/players/stats_player_crazy.tres" id="2_e1phh"]
|
||||
[ext_resource type="Texture2D" uid="uid://dq63ocnu3lset" path="res://assets/sprites/Players/Player_3}.png" id="2_ii53f"]
|
||||
|
||||
[node name="PlayerCrazy" unique_id=2022554550 instance=ExtResource("1_5054k")]
|
||||
stats = ExtResource("2_e1phh")
|
||||
|
||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="2" unique_id=1925870318]
|
||||
texture = ExtResource("2_ii53f")
|
||||
@@ -0,0 +1,11 @@
|
||||
[gd_scene format=3 uid="uid://d0q8iu2ceyjde"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cgljr7wcstmyp" path="res://scenes/unit/players/player_well_rounded.tscn" id="1_tsqjv"]
|
||||
[ext_resource type="Resource" uid="uid://crhkwist448wy" path="res://resources/units/players/stats_player_knight.tres" id="2_rn052"]
|
||||
[ext_resource type="Texture2D" uid="uid://bt0lww88864ws" path="res://assets/sprites/Players/Player_5.png" id="2_t2hln"]
|
||||
|
||||
[node name="PlayerKnight" unique_id=2022554550 instance=ExtResource("1_tsqjv")]
|
||||
stats = ExtResource("2_rn052")
|
||||
|
||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="2" unique_id=1925870318]
|
||||
texture = ExtResource("2_t2hln")
|
||||
@@ -1,18 +1,44 @@
|
||||
[gd_scene format=3 uid="uid://cgljr7wcstmyp"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://d2l68snnemcet" path="res://scenes/unit/unit.tscn" id="1_wkafa"]
|
||||
[ext_resource type="Texture2D" uid="uid://cproxhccob85g" path="res://assets/sprites/Players/Player_1.png" id="2_etcc1"]
|
||||
[ext_resource type="Script" uid="uid://b5makasbbi1ov" path="res://scenes/unit/players/player.gd" id="2_xa7el"]
|
||||
[ext_resource type="Resource" uid="uid://btnfef0ui2ju8" path="res://resources/units/players/stats_player_well_rounded.tres" id="3_xa7el"]
|
||||
[ext_resource type="Script" uid="uid://bkfe6nn8yxhbq" path="res://scenes/unit/players/trail.gd" id="4_0kki1"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_ht2l1"]
|
||||
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_etcc1"]
|
||||
radius = 30.0
|
||||
|
||||
[node name="PlayerWellRounded" unique_id=2022554550 instance=ExtResource("1_wkafa")]
|
||||
collision_mask = 2
|
||||
script = ExtResource("2_xa7el")
|
||||
dash_duration = 0.4
|
||||
dash_speed_multi = 2.7
|
||||
dash_cooldown = 1.5
|
||||
stats = ExtResource("3_xa7el")
|
||||
|
||||
[node name="Trail" type="Line2D" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="0" unique_id=1482185349 node_paths=PackedStringArray("player")]
|
||||
unique_name_in_owner = true
|
||||
top_level = true
|
||||
position = Vector2(0, -31)
|
||||
width = 40.0
|
||||
width_curve = SubResource("Curve_ht2l1")
|
||||
script = ExtResource("4_0kki1")
|
||||
player = NodePath("../..")
|
||||
|
||||
[node name="Shadow" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="1" unique_id=2136480859]
|
||||
z_index = 1
|
||||
|
||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="2" unique_id=1925870318]
|
||||
z_index = 1
|
||||
texture = ExtResource("2_etcc1")
|
||||
|
||||
[node name="CollisionShape2D" parent="." index="1" unique_id=139786467]
|
||||
visible = false
|
||||
position = Vector2(0, -31)
|
||||
shape = SubResource("CircleShape2D_etcc1")
|
||||
|
||||
@@ -22,4 +48,8 @@ one_shot = true
|
||||
[node name="DashCooldownTimer" type="Timer" parent="." index="4" unique_id=278610339]
|
||||
one_shot = true
|
||||
|
||||
[node name="TrailTimer" type="Timer" parent="." index="5" unique_id=2006934730]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[connection signal="timeout" from="DashTimer" to="." method="_on_dash_timer_timeout"]
|
||||
[connection signal="timeout" from="TrailTimer" to="Visuals/Trail" method="_on_trail_timer_timeout"]
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
extends Line2D
|
||||
class_name Trail
|
||||
|
||||
@export var player: Player
|
||||
@export var trail_length := 25
|
||||
@export var trail_duration := 1.0
|
||||
|
||||
@onready var trail_timer: Timer = %TrailTimer
|
||||
|
||||
var pointers_array: Array[Vector2] = []
|
||||
var is_active := false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if not is_active:
|
||||
return
|
||||
|
||||
pointers_array.append(player.global_position)
|
||||
if pointers_array.size() > trail_length:
|
||||
pointers_array.pop_front()
|
||||
|
||||
points = pointers_array
|
||||
|
||||
func start_trail() -> void:
|
||||
is_active = true
|
||||
clear_points()
|
||||
pointers_array.clear()
|
||||
trail_timer.start(trail_duration)
|
||||
|
||||
|
||||
func _on_trail_timer_timeout() -> void:
|
||||
is_active = false
|
||||
clear_points()
|
||||
pointers_array.clear()
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://bkfe6nn8yxhbq
|
||||
@@ -1,6 +1,8 @@
|
||||
extends Node2D
|
||||
class_name Unit
|
||||
|
||||
@export var stats: UnitStats
|
||||
|
||||
@onready var visuals: Node2D = %Visuals
|
||||
@onready var sprite: Sprite2D = %Sprite
|
||||
@onready var anim_player: AnimationPlayer = $AnimationPlayer
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://devt2xbk78rej" path="res://assets/sprites/shadow.png" id="1_fvc8g"]
|
||||
[ext_resource type="Script" uid="uid://cwf3afjy6t6rg" path="res://scenes/unit/unit.gd" id="1_vh40f"]
|
||||
[ext_resource type="Texture2D" uid="uid://cproxhccob85g" path="res://assets/sprites/Players/Player_1.png" id="2_vh40f"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_bhlit"]
|
||||
length = 0.001
|
||||
@@ -224,7 +223,7 @@ _data = {
|
||||
&"move": SubResource("Animation_3po7s")
|
||||
}
|
||||
|
||||
[node name="Unit" type="Node2D" unique_id=2022554550]
|
||||
[node name="Unit" type="Area2D" unique_id=2092979720]
|
||||
script = ExtResource("1_vh40f")
|
||||
|
||||
[node name="Visuals" type="Node2D" parent="." unique_id=395976388]
|
||||
@@ -240,7 +239,6 @@ texture = ExtResource("1_fvc8g")
|
||||
[node name="Sprite" type="Sprite2D" parent="Visuals" unique_id=1925870318]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2(0, -61)
|
||||
texture = ExtResource("2_vh40f")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=139786467]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user