Selling mechanism

This commit is contained in:
2025-04-29 14:29:25 +02:00
parent fc4285e99d
commit 0cc20ef435
10 changed files with 131 additions and 17 deletions

BIN
Assets/Others/cross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d4ghsettixo4j"
path="res://.godot/imported/cross.png-a27c4978685dc96222b2454fe6caff77.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Others/cross.png"
dest_files=["res://.godot/imported/cross.png-a27c4978685dc96222b2454fe6caff77.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -0,0 +1,19 @@
extends Node2D
const LIST_OF_ENTITIES = ["ArcherTower", "WizardTower", "MortarTower", "Mine", "StickTrap", "Wall"]
func _ready() -> void:
set_process_input(true)
func _process(delta: float) -> void:
position = get_viewport().get_mouse_position()
func _input(event):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
if abs(position) <= get_viewport().get_mouse_position():
var list_of_entities = get_node("Area2D").get_overlapping_bodies()
for i in list_of_entities:
for j in LIST_OF_ENTITIES:
if i.get_parent().name.contains(j):
i.get_parent().queue_free()
queue_free()
pass

View File

@ -0,0 +1 @@
uid://d0umyo4x3npp6

View File

@ -0,0 +1,21 @@
[gd_scene load_steps=4 format=3 uid="uid://fqjve5d7uj0t"]
[ext_resource type="Texture2D" uid="uid://d4ghsettixo4j" path="res://Assets/Others/cross.png" id="1_veida"]
[ext_resource type="Script" uid="uid://d0umyo4x3npp6" path="res://Game/Accesories/deleter.gd" id="1_y3iui"]
[sub_resource type="CircleShape2D" id="CircleShape2D_y3iui"]
radius = 20.0
[node name="Deleter" type="Node2D"]
script = ExtResource("1_y3iui")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.04, 0.04)
texture = ExtResource("1_veida")
[node name="Area2D" type="Area2D" parent="."]
scale = Vector2(0.1, 0.1)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
scale = Vector2(10, 10)
shape = SubResource("CircleShape2D_y3iui")

View File

@ -8,10 +8,9 @@ const COBOLD = preload("res://Game/Mobs/cobold.tscn")
const enemies = [FORKMAN, COBOLD, ORK]
var lives = 20
func _ready() -> void:
get_node("SidePanel").Update_Lives(lives)
get_node("SidePanel").Update_Lifes(20)
func _on_timer_timeout() -> void:
@ -25,9 +24,8 @@ func spawnMonster():
path_2d.add_child(path)
func decrease_life(damage) -> void:
lives -= damage
get_node("SidePanel").Update_Lives(lives)
if lives <= 0:
get_node("SidePanel").Update_Lifes(-damage)
if get_node("SidePanel").get_Lifes() <= 0:
game_over()
func game_over()-> void:

View File

@ -122,12 +122,9 @@ func enemy_hurt(amount) -> void:
adjust_health_bar()
func AnimatedSprite2D_animation_finished() -> void:
print("Switching to walk animation. Current Speed Scale:",
get_node("CharacterBody2D/AnimatedSprite2D").speed_scale)
get_node("CharacterBody2D/AnimatedSprite2D").play("walk")
func Collision_Handler(body: Node2D):
if body.get_parent().name.contains("StickTrap"):
if not body.get_parent().get_if_moving_state():

View File

@ -13,12 +13,14 @@ script = ExtResource("1_metvu")
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"]
position = Vector2(8, 0)
scale = Vector2(1.5, 1)
position = Vector2(8, 8)
scale = Vector2(1.5, 0.5)
texture = ExtResource("1_dnq4b")
offset = Vector2(10, 0)
[node name="Sprite2D2" type="Sprite2D" parent="CharacterBody2D"]
position = Vector2(0, 8)
scale = Vector2(1, 0.5)
texture = ExtResource("2_metvu")
offset = Vector2(-10, 0)

View File

@ -15,15 +15,33 @@ const ARCHER_TOWER = preload("res://Game/Towers/archer_tower.tscn")
@onready var wizardtowerspawn: Button = $HBoxContainer4/HBoxContainer2/Button3
const WIZARD_TOWER = preload("res://Game/Towers/wizard_tower.tscn")
@onready var delete_tower_button: Button = $HBoxContainer4/HBoxContainer5/Button4
const DELETER = preload("res://Game/Accesories/deleter.tscn")
var lives = 0
func _ready() -> void:
stickspawner.connect("button_up", Spawn_Stick)
minespawner.connect("button_up", Spawn_Mine)
archertowerspawn.connect("button_up", Spawn_Archer)
wizardtowerspawn.connect("button_up", Spawn_wizard)
delete_tower_button.connect("button_up", Spawn_Deleter)
func Update_Lives(lives) -> void:
func set_Lifes(amount) -> void:
lives = amount
func get_Lifes():
return lives
func Update_Lifes(amount) -> void:
lives += amount
livelabel.text = "Lives: " + str(lives)
func Update_Coins(coins) -> void:
livelabel.text = "Lives: " + str(coins)
func Spawn_Stick() -> void:
var stick = STICK_TRAP.instantiate()
stick.name = "StickTrap-" + str(randi())
@ -45,3 +63,8 @@ func Spawn_wizard() -> void:
tower.name = "WizardTower-" + str(randi())
get_parent().add_child(tower)
pass
func Spawn_Deleter() -> void:
var deleter = DELETER.instantiate()
get_parent().add_child(deleter)
pass

View File

@ -39,21 +39,21 @@ theme_override_constants/separation = 30
alignment = 1
[node name="Button2" type="Button" parent="HBoxContainer4/HBoxContainer2"]
custom_minimum_size = Vector2(120, 0)
custom_minimum_size = Vector2(90, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Archer"
[node name="Button3" type="Button" parent="HBoxContainer4/HBoxContainer2"]
custom_minimum_size = Vector2(120, 0)
custom_minimum_size = Vector2(90, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Wizard"
[node name="Button4" type="Button" parent="HBoxContainer4/HBoxContainer2"]
custom_minimum_size = Vector2(120, 0)
custom_minimum_size = Vector2(90, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
@ -65,19 +65,38 @@ theme_override_constants/separation = 30
alignment = 1
[node name="Button2" type="Button" parent="HBoxContainer4/HBoxContainer4"]
custom_minimum_size = Vector2(120, 0)
custom_minimum_size = Vector2(90, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Sticks"
[node name="Button3" type="Button" parent="HBoxContainer4/HBoxContainer4"]
custom_minimum_size = Vector2(120, 0)
custom_minimum_size = Vector2(90, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Mine"
[node name="Button4" type="Button" parent="HBoxContainer4/HBoxContainer4"]
custom_minimum_size = Vector2(90, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Wall"
[node name="HBoxContainer5" type="HBoxContainer" parent="HBoxContainer4"]
layout_mode = 2
theme_override_constants/separation = 120
alignment = 1
[node name="Button4" type="Button" parent="HBoxContainer4/HBoxContainer5"]
custom_minimum_size = Vector2(90, 0)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Sell"
[node name="HBoxContainer3" type="HBoxContainer" parent="HBoxContainer4"]
layout_mode = 2
theme_override_constants/separation = 120