commit no. 5

This commit is contained in:
2026-05-29 10:51:25 -04:00
parent 617c6cc233
commit facb2e227e
27 changed files with 348 additions and 87 deletions
+51
View File
@@ -0,0 +1,51 @@
using Godot;
using System;
public partial class Tower : Sprite2D
{
public bool _hovered, _aiming;
public Commander _commander;
public Area2D _area;
public override void _Ready()
{
base._Ready();
_area = GetNode<Area2D>("Area");
}
public override void _Process(double delta)
{
base._Process(delta);
if (Input.IsActionJustPressed("leftClick"))
{
if (_hovered)
{
_aiming = true;
_commander.LoadAttack();
}
}
if (_aiming)
{
if (Input.IsActionJustReleased("rightClick"))
{
Vector2 offset = (GlobalPosition - GetGlobalMousePosition()) * 500;
_commander.ShootCurrentAttack(offset);
_aiming = false;
}
else if (Input.IsActionJustReleased("leftClick"))
{
_commander.UnloadAttack();
_aiming = false;
}
}
}
public void OnMouseEntered(){
_hovered = true;
}
public void OnMouseExited(){
_hovered = true;
}
}