156 lines
3.5 KiB
C#
156 lines
3.5 KiB
C#
using Godot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
public partial class Worker : CharacterBody2D
|
|
{
|
|
[Signal]
|
|
public delegate void SetHoveredEventHandler(Worker THIS);
|
|
|
|
public bool _dead = false, _hovered = false, _held = false, _selected = false;
|
|
public int _size, _health, _healthMax;
|
|
public float _distanceTraveled, _stamina, _staminaMax;
|
|
public Stat _aptitude = new(), _agility = new(), _ardor = new(), _accumen = new(), _awareness = new(), _appeal = new();
|
|
public float _rotationalForce = 0;
|
|
public Vector2 _chainPosition = new Vector2(-1, -1), _deskPosition;
|
|
public List<Vector2> _moves = new();
|
|
public Sprite2D _image;
|
|
public ProgressBar _healthBar;
|
|
public Manager _manager;
|
|
public List<Trait> _traits = new();
|
|
public override void _Ready()
|
|
{
|
|
_size = (int)(((CircleShape2D)GetNode<CollisionShape2D>("Bounds").Shape).Radius);
|
|
|
|
_aptitude._default = 5;
|
|
_agility._default = 5;
|
|
_ardor._default = 5;
|
|
_accumen._default = 5;
|
|
_awareness._default = 5;
|
|
_appeal._default = 5;
|
|
|
|
_aptitude._effective = _aptitude._default;
|
|
_agility._effective = _agility._default;
|
|
_ardor._effective = _ardor._default;
|
|
_accumen._effective = _accumen._default;
|
|
_awareness._effective = _awareness._default;
|
|
_appeal._effective = _appeal._default;
|
|
|
|
_image = GetNode<Sprite2D>("Sprite2D");
|
|
|
|
_traits.Add(new BasicAttack(this));
|
|
|
|
// _healthBar = GetNode<ProgressBar>("HealthBar");
|
|
// _healthBar.MaxValue = _healthMax;
|
|
// _healthBar.Value = _health;
|
|
}
|
|
|
|
public override void _Process(double DELTA_)
|
|
{
|
|
if (Globals.Instance._battleRunning)
|
|
{
|
|
_chainPosition = GlobalPosition;
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
// public void ChangeHealth(int CHANGE, Node CHANGEMAKER)
|
|
// {
|
|
// if (_health <= 0 && CHANGE < 0)
|
|
// {
|
|
// // knock the piece off the board and out for the round!
|
|
// // process on knockout
|
|
// }
|
|
// _health += CHANGE;
|
|
// _healthBar.Value = _health;
|
|
// if (_health <= 0)
|
|
// {
|
|
// Sleeping = true;
|
|
// _dead = true;
|
|
// _health = 0;
|
|
// FireActions(Trigger.On.Death, _manager);
|
|
// }
|
|
// }
|
|
|
|
public void Drop()
|
|
{
|
|
if (_held)
|
|
{
|
|
_held = false;
|
|
}
|
|
}
|
|
|
|
public void FireActions(Trigger.On TRIGGER, Worker TARGET = null)
|
|
{
|
|
for (int i = 0; i < _traits.Count; i++)
|
|
{
|
|
if (_traits[i]._triggers.Contains(TRIGGER))
|
|
{
|
|
_traits[i].Target(TARGET);
|
|
_traits[i].Fire();
|
|
}
|
|
}
|
|
}
|
|
|
|
// public bool HasCondition(string CONDITION)
|
|
// {
|
|
// List<string> conditionNames = _conditions.GetChildren().Select(c => c.GetType().ToString()).ToList();
|
|
// return conditionNames.Contains(CONDITION);
|
|
// }
|
|
|
|
public void Hold()
|
|
{
|
|
if (_held)
|
|
{
|
|
return;
|
|
}
|
|
_held = true;
|
|
}
|
|
|
|
public void ResetStats()
|
|
{
|
|
_aptitude._effective = _aptitude._default;
|
|
_agility._effective = _agility._default;
|
|
_ardor._effective = _ardor._default;
|
|
_accumen._effective = _accumen._default;
|
|
_awareness._effective = _awareness._default;
|
|
_appeal._effective = _appeal._default;
|
|
}
|
|
|
|
// PRIVATE METHODS
|
|
private void OnMouseEntered()
|
|
{
|
|
_hovered = true;
|
|
EmitSignal(SignalName.SetHovered, this);
|
|
}
|
|
|
|
private void OnMouseExited()
|
|
{
|
|
_hovered = false;
|
|
EmitSignal(SignalName.SetHovered, this);
|
|
}
|
|
|
|
// private void OnBodyEntered(Node NODE)
|
|
// {
|
|
// if (NODE is Worker)
|
|
// {
|
|
// FireActions(Trigger.On.Collision, NODE);
|
|
|
|
// _rotationalForce *= 0.8f;
|
|
// Vector2 rotatedForce = LinearVelocity.Rotated(((Worker)NODE)._rotationalForce);
|
|
|
|
// ApplyCentralForce(rotatedForce);
|
|
// }
|
|
// else if (NODE is Tchotchke)
|
|
// {
|
|
// Tchotchke tchotchke = (Tchotchke)NODE;
|
|
// tchotchke.FireActions(Trigger.On.Collision, this);
|
|
// }
|
|
// }
|
|
|
|
}
|