start MapNodes

This commit is contained in:
2022-12-10 07:15:02 +01:00
parent 0d3aaf42d8
commit e4d130f581
8 changed files with 126 additions and 105 deletions

View File

@@ -1,17 +1,33 @@
extends Node
class_name Train
signal test
signal hit(player, dmg)
signal game_over
var speed = 10
var is_P1 = true
var current_speed = 10
var CANNONS = []
var STORAGES = []
#@onready var ENGINE = $Module/Engine
# Called when the node enters the scene tree for the first time.
@onready var root = get_tree().root.get_child(0) as Game
func _ready():
pass
for child in get_children():
if(child is Cannon):
CANNONS.append(child)
if(child is Storage):
STORAGES.append(child)
root.shoot.connect(_on_signal_shooting)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
test.emit() # Replace with function body.
func _on_signal_shooting():
for cannon in CANNONS:
if cannon.shoot():
hit.emit(is_P1,cannon.DAMAGE)
print("Shot P2")
func is_dead():
if current_speed <= 0:
game_over.emit()