Wall implemented

This commit is contained in:
2025-04-29 22:18:29 +02:00
parent 0cc20ef435
commit 01efa79f63
2103 changed files with 7250 additions and 7043 deletions

View File

@ -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")

View File

@ -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
View 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"]