Selling mechanism
This commit is contained in:
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")
|
Reference in New Issue
Block a user