Files
peggle-roguelike/Commander.cs
T
2026-05-29 10:51:25 -04:00

64 lines
1.3 KiB
C#

using Godot;
using System;
public partial class Commander : Sprite2D
{
[Signal]
public delegate void TurnDoneEventHandler();
public int _health = 10;
public PackedScene _attackScene = GD.Load<PackedScene>("res://Attack.tscn");
public Attack _attack;
public override void _Process(double delta)
{
base._Process(delta);
if (_attack != null)
{
if (_attack.Position.Y > GetViewportRect().Size.Y + 50)
{
_attack.QueueFree();
_attack = null;
}
}
}
public void StartTurn()
{
}
public void LoadAttack()
{
if (_attack == null)
{
GD.Print("Loading attack");
_attack = _attackScene.Instantiate<Attack>();
_attack._commanderOwner = this;
_attack.GravityScale = 0;
AddChild(_attack);
}
}
public void TakeDamage(int DAMAGE, Enemy ATTACKER)
{
_health -= DAMAGE;
if (_health <= 0)
{
GD.Print("GAME OVER");
GetTree().Quit();
}
}
public void ShootCurrentAttack(Vector2 FORCE){
GD.Print("Shooting attack");
_attack.Shoot(FORCE);
}
public void UnloadAttack()
{
_attack.QueueFree();
}
}