Wizard Tower and special effects

This commit is contained in:
2025-04-15 20:32:00 +02:00
parent c4c01800dd
commit 08479e83c1
16 changed files with 302 additions and 20 deletions

View File

@ -8,7 +8,7 @@ var follower = false
var target = null
const ARROW = preload("res://Game/Bullets/arrow.tscn")
const MAGIC = preload("res://Game/Bullets/magic.tscn")
func _ready() -> void:
follower = true
@ -26,10 +26,13 @@ func _process(delta: float) -> void:
func set_properties() -> void:
if self.name.contains("ArcherTower"):
get_node("Timer").wait_time = 0.8
bulletSpeed = 400
hitpoint = 50
get_node("Timer").wait_time = 0.5
bulletSpeed = 600
hitpoint = 25
if self.name.contains("WizardTower"):
get_node("Timer").wait_time = 2.0
bulletSpeed = 450
hitpoint = 10
func get_if_moving_state():
return follower
@ -43,9 +46,14 @@ func choose_target(body : Node2D) -> void:
if not follower:
var surroinding_enemies = get_node("CharacterBody2D/Area2D").get_overlapping_bodies()
target = surroinding_enemies[0]
for i in surroinding_enemies:
if i.get_parent().get_progress() > target.get_parent().get_progress():
target = i
if self.name.contains("ArcherTower") or self.name.contains("BombTower"):
for i in surroinding_enemies:
if i.get_parent().get_progress() > target.get_parent().get_progress():
target = i
if self.name.contains("WizardTower"):
for i in surroinding_enemies:
if i.get_parent().get_progress() < target.get_parent().get_progress():
target = i
pass
func shoot() -> void:
@ -57,4 +65,12 @@ func shoot() -> void:
arrow.set_targe(target)
arrow.set_hitpoint(hitpoint)
get_parent().add_child(arrow)
if self.name.contains("WizardTower"):
var magic = MAGIC.instantiate()
magic.position = self.position
magic.set_speed(bulletSpeed)
magic.set_targe(target)
magic.set_hitpoint(hitpoint)
get_parent().add_child(magic)
pass

View File

@ -0,0 +1,89 @@
[gd_scene load_steps=12 format=3 uid="uid://b4e605q60lde4"]
[ext_resource type="Script" uid="uid://dil41a1ymo0ua" path="res://Game/Towers/towers.gd" id="1_grwc8"]
[ext_resource type="Texture2D" uid="uid://dngrpwmj4oedg" path="res://Assets/Towers/S_Fly.png" id="2_grwc8"]
[sub_resource type="AtlasTexture" id="AtlasTexture_35u2c"]
atlas = ExtResource("2_grwc8")
region = Rect2(0, 0, 96, 96)
[sub_resource type="AtlasTexture" id="AtlasTexture_fpdhp"]
atlas = ExtResource("2_grwc8")
region = Rect2(96, 0, 96, 96)
[sub_resource type="AtlasTexture" id="AtlasTexture_mo8k5"]
atlas = ExtResource("2_grwc8")
region = Rect2(192, 0, 96, 96)
[sub_resource type="AtlasTexture" id="AtlasTexture_uxuma"]
atlas = ExtResource("2_grwc8")
region = Rect2(288, 0, 96, 96)
[sub_resource type="AtlasTexture" id="AtlasTexture_l7hme"]
atlas = ExtResource("2_grwc8")
region = Rect2(384, 0, 96, 96)
[sub_resource type="AtlasTexture" id="AtlasTexture_pvyvx"]
atlas = ExtResource("2_grwc8")
region = Rect2(480, 0, 96, 96)
[sub_resource type="SpriteFrames" id="SpriteFrames_pvyvx"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_35u2c")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_fpdhp")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_mo8k5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uxuma")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_l7hme")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_pvyvx")
}],
"loop": true,
"name": &"Default",
"speed": 5.0
}]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_hcema"]
radius = 29.0
height = 88.0
[sub_resource type="CircleShape2D" id="CircleShape2D_c5q70"]
radius = 183.044
[node name="WizardTower" type="Node2D"]
script = ExtResource("1_grwc8")
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="CharacterBody2D"]
position = Vector2(1, 13)
scale = Vector2(1.5, 1.5)
sprite_frames = SubResource("SpriteFrames_pvyvx")
animation = &"Default"
autoplay = "Default"
frame_progress = 0.265757
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
position = Vector2(0, 17)
shape = SubResource("CapsuleShape2D_hcema")
[node name="Area2D" type="Area2D" parent="CharacterBody2D"]
position = Vector2(2, 20)
collision_mask = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D/Area2D"]
shape = SubResource("CircleShape2D_c5q70")
[node name="Timer" type="Timer" parent="."]
wait_time = 2.0
autostart = true