commit no. 5
This commit is contained in:
+26
-26
@@ -5,43 +5,38 @@ public partial class Commander : Sprite2D
|
||||
{
|
||||
[Signal]
|
||||
public delegate void TurnDoneEventHandler();
|
||||
public bool _aiming = false;
|
||||
public int _health = 10;
|
||||
public PackedScene _attackScene = GD.Load<PackedScene>("res://Attack.tscn");
|
||||
public Attack _currentAttack;
|
||||
public Attack _attack;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
base._Process(delta);
|
||||
if (_currentAttack != null)
|
||||
if (_attack != null)
|
||||
{
|
||||
if (Input.IsActionJustPressed("leftClick")){
|
||||
if (_currentAttack._hovered){
|
||||
_aiming = true;
|
||||
}
|
||||
}
|
||||
if (_aiming){
|
||||
Vector2 offset = (_currentAttack.GlobalPosition - GetGlobalMousePosition()) * 500;
|
||||
if (Input.IsActionJustReleased("leftClick")){
|
||||
ShootCurrentAttack(offset);
|
||||
}
|
||||
}
|
||||
if (_currentAttack.Position.Y > GetViewportRect().Size.Y + 50){
|
||||
_currentAttack.QueueFree();
|
||||
_currentAttack = null;
|
||||
EmitSignal(SignalName.TurnDone);
|
||||
if (_attack.Position.Y > GetViewportRect().Size.Y + 50)
|
||||
{
|
||||
_attack.QueueFree();
|
||||
_attack = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void StartTurn()
|
||||
{
|
||||
if (_currentAttack == null){
|
||||
|
||||
}
|
||||
|
||||
public void LoadAttack()
|
||||
{
|
||||
if (_attack == null)
|
||||
{
|
||||
GD.Print("Loading attack");
|
||||
_currentAttack = _attackScene.Instantiate<Attack>();
|
||||
_currentAttack._commanderOwner = this;
|
||||
_currentAttack.GravityScale = 0;
|
||||
AddChild(_currentAttack);
|
||||
_attack = _attackScene.Instantiate<Attack>();
|
||||
_attack._commanderOwner = this;
|
||||
_attack.GravityScale = 0;
|
||||
AddChild(_attack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +51,13 @@ public partial class Commander : Sprite2D
|
||||
}
|
||||
|
||||
public void ShootCurrentAttack(Vector2 FORCE){
|
||||
|
||||
GD.Print("Shooting attack");
|
||||
_currentAttack.Shoot(FORCE);
|
||||
_aiming = false;
|
||||
_attack.Shoot(FORCE);
|
||||
}
|
||||
|
||||
public void UnloadAttack()
|
||||
{
|
||||
_attack.QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user