commit no. 5
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user