Selling mechanism
This commit is contained in:
BIN
Assets/Others/cross.png
Normal file
BIN
Assets/Others/cross.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
34
Assets/Others/cross.png.import
Normal file
34
Assets/Others/cross.png.import
Normal 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
|
19
Game/Accesories/deleter.gd
Normal file
19
Game/Accesories/deleter.gd
Normal 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
|
1
Game/Accesories/deleter.gd.uid
Normal file
1
Game/Accesories/deleter.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://d0umyo4x3npp6
|
21
Game/Accesories/deleter.tscn
Normal file
21
Game/Accesories/deleter.tscn
Normal 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")
|
@ -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:
|
||||
|
@ -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():
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user