first commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Player : Node2D
|
||||
{
|
||||
public bool _aiming = false;
|
||||
public PackedScene _attackScene = GD.Load<PackedScene>("res://Attack.tscn");
|
||||
public Attack _currentAttack;
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
base._Process(delta);
|
||||
if (_currentAttack == null){
|
||||
GD.Print("Loading attack");
|
||||
_currentAttack = _attackScene.Instantiate<Attack>();
|
||||
_currentAttack.GravityScale = 0;
|
||||
_currentAttack.Position = GetViewportRect().Size / 2;
|
||||
AddChild(_currentAttack);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public void ShootCurrentAttack(Vector2 FORCE){
|
||||
GD.Print("Shooting attack");
|
||||
_currentAttack.Shoot(FORCE);
|
||||
_aiming = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user