Wall implemented
This commit is contained in:
@ -12,6 +12,17 @@ script = ExtResource("1_wft0c")
|
||||
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CPUParticles2D" type="CPUParticles2D" parent="CharacterBody2D"]
|
||||
position = Vector2(0, 10)
|
||||
lifetime = 0.5
|
||||
speed_scale = 5.0
|
||||
emission_shape = 2
|
||||
emission_sphere_radius = 4.0
|
||||
spread = 0.0
|
||||
gravity = Vector2(0, 0)
|
||||
scale_amount_min = 2.0
|
||||
scale_amount_max = 4.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
|
||||
shape = SubResource("RectangleShape2D_wft0c")
|
||||
|
||||
|
@ -36,7 +36,6 @@ func _process(delta: float) -> void:
|
||||
|
||||
|
||||
func target_reached() -> void:
|
||||
var chance = 0
|
||||
if name.contains("Arrow"): #special effects here!
|
||||
if randf() < 0.1:
|
||||
target.get_parent().set_speed(target.get_parent().get_speed() / 2)
|
||||
|
@ -33,5 +33,4 @@ func game_over()-> void:
|
||||
var enemy = get_node("Path2D").get_children()
|
||||
for i in enemy:
|
||||
i.get_children()[0].set_process(false)
|
||||
i.get_children()[0].name
|
||||
|
||||
|
@ -92,12 +92,12 @@ func adjust_health_bar() -> void:
|
||||
bg_style.corner_radius_bottom_right = 20
|
||||
|
||||
if current_shield > 0:
|
||||
fill_style.bg_color = Color(0, 0, 1) # Blue for shield
|
||||
bg_style.bg_color = Color(0, 1, 0) # Green background
|
||||
health_bar.value = int((current_shield / float(shield)) * 100) # Use current_shield and shield
|
||||
fill_style.bg_color = Color(0, 0, 1)
|
||||
bg_style.bg_color = Color(0, 1, 0)
|
||||
health_bar.value = int((current_shield / float(shield)) * 100)
|
||||
else:
|
||||
fill_style.bg_color = Color(0, 1, 0) # Green for health
|
||||
bg_style.bg_color = Color(1, 0, 0) # Red background
|
||||
fill_style.bg_color = Color(0, 1, 0)
|
||||
bg_style.bg_color = Color(1, 0, 0)
|
||||
health_bar.value = int((current_health / float(health)) * 100)
|
||||
|
||||
# Apply the styles
|
||||
@ -137,7 +137,7 @@ func Collision_Handler(body: Node2D):
|
||||
if i.get_parent().name.contains(j):
|
||||
enemy_hurt(100)
|
||||
body.get_parent().Explode_Mine()
|
||||
|
||||
|
||||
|
||||
func get_progress():
|
||||
return get_parent().get_progress()
|
||||
|
@ -54,5 +54,5 @@ autoplay = "idle"
|
||||
[node name="Area2D" type="Area2D" parent="CharacterBody2D"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D/Area2D"]
|
||||
scale = Vector2(4, 4)
|
||||
scale = Vector2(6, 6)
|
||||
shape = SubResource("CircleShape2D_uiyu1")
|
||||
|
@ -1,12 +1,17 @@
|
||||
extends Node2D
|
||||
|
||||
var follower = false
|
||||
var health = 100
|
||||
static var NAMES = ["Forkman", "Cobold", "Ork"]
|
||||
|
||||
func _ready() -> void:
|
||||
follower = true
|
||||
if name.contains("Mine"):
|
||||
get_node("CharacterBody2D/AnimatedSprite2D").connect("animation_finished", Callable(self, "Remove_Mine"))
|
||||
set_process_input(true)
|
||||
|
||||
if name.contains("Wall"):
|
||||
get_node("CharacterBody2D/ProgressBar").hide()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if follower:
|
||||
@ -26,3 +31,34 @@ func Explode_Mine() -> void:
|
||||
|
||||
func Remove_Mine() -> void:
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_area_2d_body_shape_entered(body_rid: RID, body: Node2D, body_shape_index: int, local_shape_index: int) -> void:
|
||||
if follower == false:
|
||||
get_node("CharacterBody2D/Timer").start()
|
||||
for i in get_node("CharacterBody2D/Area2D").get_overlapping_bodies():
|
||||
for j in NAMES:
|
||||
if i.get_parent().name.contains(j):
|
||||
get_node("CharacterBody2D/ProgressBar").show()
|
||||
i.get_parent().set_process(false)
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
var minus = 0
|
||||
|
||||
for i in get_node("CharacterBody2D/Area2D").get_overlapping_bodies():
|
||||
for j in NAMES:
|
||||
if i.get_parent().name.contains(j):
|
||||
minus += 1
|
||||
|
||||
health -= minus
|
||||
get_node("CharacterBody2D/ProgressBar").value = health
|
||||
if minus == 0:
|
||||
get_node("CharacterBody2D/Timer").stop()
|
||||
|
||||
if health <= 0:
|
||||
for i in get_node("CharacterBody2D/Area2D").get_overlapping_bodies():
|
||||
for j in NAMES:
|
||||
if i.get_parent().name.contains(j):
|
||||
i.get_parent().set_process(true)
|
||||
queue_free()
|
||||
|
70
Game/Traps/wall.tscn
Normal file
70
Game/Traps/wall.tscn
Normal file
@ -0,0 +1,70 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://cc5j50rtwlfld"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://3gn70ilm20tw" path="res://Game/Traps/traps.gd" id="1_3ht3o"]
|
||||
[ext_resource type="Texture2D" uid="uid://ri5c5u8gbjde" path="res://Assets/Traps/Wall/Tile2_49.png" id="1_y07rg"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5wu41w5yjr25" path="res://Assets/Traps/Wall/Tile2_57.png" id="2_3ht3o"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bxxpj"]
|
||||
size = Vector2(22.5, 75)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3ht3o"]
|
||||
bg_color = Color(1, 0, 0, 1)
|
||||
corner_radius_top_left = 20
|
||||
corner_radius_top_right = 20
|
||||
corner_radius_bottom_right = 20
|
||||
corner_radius_bottom_left = 20
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_bxxpj"]
|
||||
bg_color = Color(0, 1, 0, 1)
|
||||
corner_radius_top_left = 20
|
||||
corner_radius_top_right = 20
|
||||
corner_radius_bottom_right = 20
|
||||
corner_radius_bottom_left = 20
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3ht3o"]
|
||||
size = Vector2(38, 59)
|
||||
|
||||
[node name="Wall" type="Node2D"]
|
||||
script = ExtResource("1_3ht3o")
|
||||
|
||||
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
|
||||
|
||||
[node name="Sprite2D2" type="Sprite2D" parent="CharacterBody2D"]
|
||||
position = Vector2(13, -16)
|
||||
scale = Vector2(1, 0.923)
|
||||
texture = ExtResource("1_y07rg")
|
||||
offset = Vector2(-10, 0)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
|
||||
position = Vector2(2.38419e-07, -0.999999)
|
||||
scale = Vector2(0.8, 0.8)
|
||||
shape = SubResource("RectangleShape2D_bxxpj")
|
||||
|
||||
[node name="Tile257" type="Sprite2D" parent="CharacterBody2D"]
|
||||
position = Vector2(3, 13)
|
||||
scale = Vector2(1, 0.923)
|
||||
texture = ExtResource("2_3ht3o")
|
||||
|
||||
[node name="ProgressBar" type="ProgressBar" parent="CharacterBody2D"]
|
||||
custom_minimum_size = Vector2(40, 1)
|
||||
offset_left = -20.0
|
||||
offset_top = 29.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 37.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_3ht3o")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_bxxpj")
|
||||
value = 100.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="CharacterBody2D"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D/Area2D"]
|
||||
position = Vector2(-9, -1.5)
|
||||
shape = SubResource("RectangleShape2D_3ht3o")
|
||||
|
||||
[node name="Timer" type="Timer" parent="CharacterBody2D"]
|
||||
wait_time = 0.3
|
||||
|
||||
[connection signal="body_shape_entered" from="CharacterBody2D/Area2D" to="." method="_on_area_2d_body_shape_entered"]
|
||||
[connection signal="body_shape_exited" from="CharacterBody2D/Area2D" to="." method="_on_area_2d_body_shape_exited"]
|
||||
[connection signal="timeout" from="CharacterBody2D/Timer" to="." method="_on_timer_timeout"]
|
@ -8,6 +8,8 @@ const STICK_TRAP = preload("res://Game/Traps/stick_trap.tscn")
|
||||
@onready var minespawner: Button = $HBoxContainer4/HBoxContainer4/Button3
|
||||
const MINE = preload("res://Game/Traps/mine.tscn")
|
||||
|
||||
@onready var wallspawner: Button = $HBoxContainer4/HBoxContainer4/Button4
|
||||
const WALL = preload("res://Game/Traps/wall.tscn")
|
||||
|
||||
@onready var archertowerspawn: Button = $HBoxContainer4/HBoxContainer2/Button2
|
||||
const ARCHER_TOWER = preload("res://Game/Towers/archer_tower.tscn")
|
||||
@ -24,6 +26,7 @@ var lives = 0
|
||||
func _ready() -> void:
|
||||
stickspawner.connect("button_up", Spawn_Stick)
|
||||
minespawner.connect("button_up", Spawn_Mine)
|
||||
wallspawner.connect("button_down", Spawn_Wall)
|
||||
archertowerspawn.connect("button_up", Spawn_Archer)
|
||||
wizardtowerspawn.connect("button_up", Spawn_wizard)
|
||||
delete_tower_button.connect("button_up", Spawn_Deleter)
|
||||
@ -52,6 +55,11 @@ func Spawn_Mine() -> void:
|
||||
mine.name = "Mine-" + str(randi())
|
||||
get_parent().add_child(mine)
|
||||
|
||||
func Spawn_Wall() -> void:
|
||||
var wall = WALL.instantiate()
|
||||
wall.name = "Wall-" + str(randi())
|
||||
get_parent().add_child(wall)
|
||||
|
||||
func Spawn_Archer() -> void:
|
||||
var tower = ARCHER_TOWER.instantiate()
|
||||
tower.name = "ArcherTower-" + str(randi())
|
||||
|
@ -43,6 +43,7 @@ custom_minimum_size = Vector2(90, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
focus_mode = 0
|
||||
text = "Archer"
|
||||
|
||||
[node name="Button3" type="Button" parent="HBoxContainer4/HBoxContainer2"]
|
||||
@ -50,6 +51,7 @@ custom_minimum_size = Vector2(90, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
focus_mode = 0
|
||||
text = "Wizard"
|
||||
|
||||
[node name="Button4" type="Button" parent="HBoxContainer4/HBoxContainer2"]
|
||||
@ -57,6 +59,7 @@ custom_minimum_size = Vector2(90, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
focus_mode = 0
|
||||
text = "Mortar"
|
||||
|
||||
[node name="HBoxContainer4" type="HBoxContainer" parent="HBoxContainer4"]
|
||||
@ -69,6 +72,7 @@ custom_minimum_size = Vector2(90, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
focus_mode = 0
|
||||
text = "Sticks"
|
||||
|
||||
[node name="Button3" type="Button" parent="HBoxContainer4/HBoxContainer4"]
|
||||
@ -76,6 +80,7 @@ custom_minimum_size = Vector2(90, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
focus_mode = 0
|
||||
text = "Mine"
|
||||
|
||||
[node name="Button4" type="Button" parent="HBoxContainer4/HBoxContainer4"]
|
||||
@ -83,6 +88,7 @@ custom_minimum_size = Vector2(90, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
focus_mode = 0
|
||||
text = "Wall"
|
||||
|
||||
[node name="HBoxContainer5" type="HBoxContainer" parent="HBoxContainer4"]
|
||||
@ -95,6 +101,7 @@ custom_minimum_size = Vector2(90, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
focus_mode = 0
|
||||
text = "Sell"
|
||||
|
||||
[node name="HBoxContainer3" type="HBoxContainer" parent="HBoxContainer4"]
|
||||
|
Reference in New Issue
Block a user