798 lines
17 KiB
C#
798 lines
17 KiB
C#
using Godot;
|
|
using System;
|
|
|
|
public partial class Marble : CharacterBody2D
|
|
{
|
|
public bool _dead, _isTurn, _turnDone, _actionTaken, _isHero, _placed, _hovered, _selected, _aimed, _launched, _collided, _moving;
|
|
public string _class, _id;
|
|
public int _battle, _experience;
|
|
public float _radius, _mass, _distanceMoved, _spin, _damping;
|
|
public Vector2 _startPosition, _velocity, _pullback;
|
|
|
|
public List<Condition> _conditions = new();
|
|
public List<Action> _actions = new();
|
|
public List<Trait> _traits = new();
|
|
public Action _defaultAction;
|
|
public Action _focusedAction;
|
|
public ActionSelector _actionSelector;
|
|
|
|
public Stats _stats;
|
|
|
|
public Player _owner;
|
|
public object _lastCollisionObject;
|
|
|
|
//these may get implemented elsewhere eventually
|
|
public const float _airDrag = 0.1f; // Air drag coefficient (0 = no drag)
|
|
public const float _friction = 0.95f; // Friction coefficient (1 = no friction)
|
|
|
|
|
|
public Marble(float RADIUS, float MASS) : base("Visuals\\basicMarble", new Vector2(-1, -1), new Vector2(RADIUS*2), new Vector2(8, 1), new Vector2(1.0f, 1.0f))
|
|
{
|
|
_class = this.GetType().ToString().Replace("CorporateLadder.", "");
|
|
_id = Guid.NewGuid().ToString();
|
|
_dead = false;
|
|
_isTurn = false;
|
|
_turnDone = false;
|
|
_actionTaken = false;
|
|
_isHero = false;
|
|
_placed = false;
|
|
_hovered = false;
|
|
_selected = false;
|
|
_aimed = false;
|
|
_moving = false;
|
|
_launched = false;
|
|
_collided = false;
|
|
|
|
_battle = 1;
|
|
_experience = 0;
|
|
|
|
_radius = RADIUS;
|
|
_mass = MASS;
|
|
_spin = 0; // 1 RPM = 360 DPM = 6 DPS @ 60FPS = .1 DPF // Divide RPM by 10 to get DPF
|
|
_damping = 0.99f;
|
|
|
|
_pullback = new Vector2(0, 0);
|
|
_velocity = new Vector2(0, 0);
|
|
|
|
_rotation = 0;
|
|
_distanceMoved = 0;
|
|
|
|
_stats = new Stats(_class);
|
|
|
|
_owner = null;
|
|
_lastCollisionObject = null;
|
|
|
|
CreatePerFrameAnimations("Roll");
|
|
SetAnimationByName("Roll");
|
|
_frameAnimations = true;
|
|
|
|
Action tempAction = new Launch(this);
|
|
tempAction.AddTo(this);
|
|
tempAction = new Defend(this);
|
|
tempAction.AddTo(this);
|
|
tempAction = new RecklessLaunch(this);
|
|
tempAction.AddTo(this);
|
|
_defaultAction = _actions[0];
|
|
_actionSelector = new ActionSelector(this);
|
|
|
|
ProcessOnCreation();
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
if (_dead)
|
|
{
|
|
Hide();
|
|
}
|
|
|
|
if (Globals._battle._turn == _owner && !_dead && _position.X > -1 && _position.Y > -1)
|
|
{
|
|
_actionSelector?.Update(_position);
|
|
}
|
|
else
|
|
{
|
|
if (_actionSelector != null && _actionSelector._active)
|
|
{
|
|
_actionSelector.Deactivate();
|
|
}
|
|
}
|
|
|
|
if (_position.X > -1 && _position.Y > -1)
|
|
{
|
|
base.Update();
|
|
if (PassesInitialChecks())
|
|
{
|
|
TryHover();
|
|
TrySelect();
|
|
TryAim();
|
|
|
|
if (!_turnDone)
|
|
{
|
|
if (_actionTaken)
|
|
{
|
|
_turnDone = true;
|
|
}
|
|
}
|
|
}
|
|
TryLaunch();
|
|
TryCollision();
|
|
TryMovement();
|
|
|
|
}
|
|
}
|
|
|
|
public override void Update(Vector2 NEWPOSITION)
|
|
{
|
|
_position = NEWPOSITION;
|
|
_actionSelector?.Update(_position);
|
|
}
|
|
|
|
public virtual void ActionAdd(Action ACTION)
|
|
{
|
|
if (!_actions.Contains(ACTION))
|
|
{
|
|
_actions.Add(ACTION);
|
|
ACTION.ProcessOnAdd();
|
|
}
|
|
}
|
|
|
|
public virtual void ActionRemove(Action ACTION)
|
|
{
|
|
if (_actions.Contains(ACTION))
|
|
{
|
|
ACTION.ProcessOnRemove();
|
|
_actions.Remove(ACTION);
|
|
}
|
|
}
|
|
|
|
public virtual void AddExperience(object INFO)
|
|
{
|
|
_experience += Globals.ConvertToInt(INFO);
|
|
}
|
|
|
|
public virtual void ChangeHealth(Marble ATTACKER, int CHANGE)
|
|
{
|
|
_stats._health += CHANGE;
|
|
_stats._health = Math.Min(_stats._health, _stats._healthMax);
|
|
if (_stats._health <= 0)
|
|
{
|
|
_dead = true;
|
|
//ATTACKER.AddExperience(GetExp());
|
|
}
|
|
}
|
|
|
|
public virtual void CheckIfLevelUp()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual int CheckLevelExperience(int LEVEL)
|
|
{
|
|
return 2 * LEVEL + (int)Math.Pow(2.0, 1.0f + LEVEL * .2f);
|
|
}
|
|
|
|
|
|
|
|
public virtual void CollideWithMarble(Marble OTHER)
|
|
{
|
|
// From: https://stackoverflow.com/q/345838/880990, author: mmcdole
|
|
|
|
Vector2 delta = _position - OTHER._position;
|
|
float distance = delta.Length();
|
|
if (distance <= _radius + OTHER._radius && distance > 1e-5)
|
|
{
|
|
// Minimum translation distance to push balls apart after intersecting
|
|
Vector2 minTranslationDistance = delta * ((_radius + OTHER._radius - distance) / distance);
|
|
|
|
// Resolve intersection - inverse mass quantities
|
|
float inverseMass1 = 1 / _mass;
|
|
float inverseMass2 = 1 / OTHER._mass;
|
|
|
|
// Push-pull them apart based off their mass
|
|
_position += minTranslationDistance * (inverseMass1 / (inverseMass1 + inverseMass2));
|
|
OTHER._position -= minTranslationDistance * (inverseMass1 / (inverseMass1 + inverseMass2));
|
|
|
|
// Impact speed
|
|
Vector2 velocityDelta = _velocity - OTHER._velocity;
|
|
Vector2 minTranslationDistanceNormalized = Vector2.Normalize(minTranslationDistance);
|
|
float velocityNormalized = Vector2.Dot(velocityDelta, minTranslationDistanceNormalized);
|
|
|
|
// Sphere intersecting but moving away from each other already
|
|
if (velocityNormalized > 0.0f) return;
|
|
|
|
// Collision impulse
|
|
const float restitution = 1.0f; // perfectly elastic collision
|
|
|
|
float i = -(1.0f + restitution) * velocityNormalized / (inverseMass1 + inverseMass2);
|
|
Vector2 impulse = minTranslationDistanceNormalized * i;
|
|
|
|
// Change in momentum
|
|
_velocity += impulse * inverseMass1;
|
|
_velocity *= _damping;
|
|
OTHER._velocity -= impulse * inverseMass2;
|
|
OTHER._velocity *= OTHER._damping;
|
|
// Perform
|
|
|
|
_collided = !_launched;
|
|
|
|
ProcessOnCollisionMarble(OTHER);
|
|
OTHER.ProcessOnCollisionMarble(this);
|
|
|
|
}
|
|
}
|
|
|
|
//public virtual void CollideWithWallInner(Rectangle WALL)
|
|
//{
|
|
// // Only reverse velocity if moving towards the walls
|
|
|
|
// if (_position.X + _radius >= WALL.Right && _velocity.X > 0 || _position.X - _radius < WALL.Left && _velocity.X < 0)
|
|
// {
|
|
// _velocity = new Vector2(-_velocity.X, _velocity.Y);
|
|
// ProcessOnCollisionWall();
|
|
// }
|
|
// if (_position.Y + _radius >= WALL.Bottom && _velocity.Y > 0 || _position.Y - _radius < WALL.Top && _velocity.Y < 0)
|
|
// {
|
|
// _velocity = new Vector2(_velocity.X, -_velocity.Y);
|
|
// ProcessOnCollisionWall();
|
|
// }
|
|
//}
|
|
|
|
public virtual void CollideWithWallOuter(Rectangle WALL)
|
|
{
|
|
// Only reverse velocity if moving towards the walls
|
|
|
|
if (!WALL.Contains(_position + Globals.LengthenVector(_velocity, _radius)))
|
|
{
|
|
if (_position.X + _radius >= WALL.Right || _position.X - _radius < WALL.Left)
|
|
{
|
|
_velocity = new Vector2(-_damping * _velocity.X, _velocity.Y);
|
|
}
|
|
if (_position.Y + _radius >= WALL.Bottom || _position.Y - _radius < WALL.Top)
|
|
{
|
|
_velocity = new Vector2(_velocity.X, -_damping * _velocity.Y);
|
|
}
|
|
ProcessOnCollisionWall();
|
|
}
|
|
//if (_position.X + _radius >= WALL.Right && _velocity.X > 0 || _position.X - _radius < WALL.Left && _velocity.X < 0)
|
|
//{
|
|
// _velocity = new Vector2(-_velocity.X, _velocity.Y);
|
|
// ProcessOnCollisionWall();
|
|
//}
|
|
//if (_position.Y + _radius >= WALL.Bottom && _velocity.Y > 0 || _position.Y - _radius < WALL.Top && _velocity.Y < 0)
|
|
//{
|
|
// _velocity = new Vector2(_velocity.X, -_velocity.Y);
|
|
// ProcessOnCollisionWall();
|
|
//}
|
|
|
|
}
|
|
|
|
public virtual void ConditionAdd(Condition CONDITION)
|
|
{
|
|
if (!_conditions.Contains(CONDITION))
|
|
{
|
|
_conditions.Add(CONDITION);
|
|
CONDITION.ProcessOnAdd();
|
|
}
|
|
}
|
|
|
|
public virtual void ConditionRemove(Condition CONDITION)
|
|
{
|
|
if (_conditions.Contains(CONDITION))
|
|
{
|
|
CONDITION.ProcessOnRemove();
|
|
_conditions.Remove(CONDITION);
|
|
}
|
|
}
|
|
|
|
public virtual int GetExp()
|
|
{
|
|
return _battle * 2;
|
|
}
|
|
|
|
public virtual void Hide()
|
|
{
|
|
_position = new Vector2(-1, -1);
|
|
}
|
|
|
|
public virtual bool IsFocal()
|
|
{
|
|
return Globals._battle._focalMarble == this;
|
|
}
|
|
|
|
public virtual bool IsHovered()
|
|
{
|
|
return Globals.CalculateDistance(_position, Globals._mouse._newMousePosition) <= _radius;
|
|
}
|
|
|
|
public virtual void LevelUp()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual bool PassesInitialChecks()
|
|
{
|
|
bool isNotPlaced = !_placed;
|
|
if (isNotPlaced) { return false; }
|
|
|
|
bool isNotTurn = !(Globals._battle._turn == _owner);
|
|
if (isNotTurn) { return false; }
|
|
|
|
if (_actionTaken) { return false; }
|
|
|
|
bool marblesMoving = Globals._battle._movementDetected;
|
|
if (marblesMoving) { return false; }
|
|
|
|
return true;
|
|
}
|
|
|
|
#region PROCS
|
|
public virtual void ProcessOnAdd()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void ProcessOnBattleStart()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnBattleStart();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnBattleStart();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnBattleEnd()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnBattleEnd();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnBattleEnd();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnCollisionMarble(Marble TARGET)
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnCollisionMarble(TARGET);
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnCollisionMarble(TARGET);
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnCollisionWall()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnCollisionWall();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnCollisionWall();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnCreation()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnCreation();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnCreation();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnCritical()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnCritical();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnCritical();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnDeath()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnDeath();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnDeath();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnDefend()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnDefend();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnDefend();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnExpiration()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnExpiration();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnExpiration();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnLaunch()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnLaunch();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnLaunch();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnRemove()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnRemove();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnRemove();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnSell()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnSell();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnSell();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnStop()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnStop();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnStop();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnMovement()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnMovement();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnMovement();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnTurnEnd()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnTurnEnd();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnTurnEnd();
|
|
}
|
|
}
|
|
|
|
public virtual void ProcessOnTurnStart()
|
|
{
|
|
for (int i = 0; i < _conditions.Count; i++)
|
|
{
|
|
_conditions[i].ProcessOnTurnStart();
|
|
}
|
|
for (int i = 0; i < _actions.Count; i++)
|
|
{
|
|
_actions[i].ProcessOnTurnStart();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public virtual void Resurrect()
|
|
{
|
|
_dead = false;
|
|
}
|
|
|
|
public virtual void SetOwner(Player OWNER)
|
|
{
|
|
_owner = OWNER;
|
|
}
|
|
|
|
public virtual void SetPosition(Vector2 POSITION)
|
|
{
|
|
_position = POSITION;
|
|
}
|
|
|
|
public virtual void TraitAdd(Trait TRAIT)
|
|
{
|
|
if (!_traits.Contains(TRAIT))
|
|
{
|
|
_traits.Add(TRAIT);
|
|
TRAIT.ProcessOnAdd();
|
|
|
|
}
|
|
}
|
|
|
|
public virtual void TraitRemove(Trait TRAIT)
|
|
{
|
|
if (_traits.Contains(TRAIT))
|
|
{
|
|
TRAIT.ProcessOnRemove();
|
|
_traits.Remove(TRAIT);
|
|
}
|
|
}
|
|
|
|
public virtual void TryAim()
|
|
{
|
|
if (!_hovered && _selected && IsFocal() && Globals._mouse.LeftClickDrag(_radius / 4) && !_actionSelector._active)
|
|
{
|
|
_aimed = true;
|
|
}
|
|
if (_aimed)
|
|
{
|
|
_selected = false;
|
|
if (Globals._mouse.RightClickRelease())
|
|
{
|
|
return;
|
|
}
|
|
float pullbackX, pullbackY;
|
|
if (Globals._keyboard.GetPress("LeftShift"))
|
|
{
|
|
float pullbackAngle = Globals.CalculateAngle(_position, Globals._mouse._newMousePosition) * 180 / Globals._pi;
|
|
|
|
if ((pullbackAngle >= -22.5f && pullbackAngle <= 22.5f) || (pullbackAngle >= 157.5f || pullbackAngle <= -157.5f))
|
|
{
|
|
pullbackX = _position.X - Globals._mouse._newMousePosition.X;
|
|
pullbackY = 0f;
|
|
}
|
|
else if ((pullbackAngle <= -67.5f && pullbackAngle >= -112.5f) || (pullbackAngle >= 67.5f && pullbackAngle <= 112.5f))
|
|
{
|
|
pullbackX = 0f;
|
|
pullbackY = _position.Y - Globals._mouse._newMousePosition.Y;
|
|
}
|
|
else if ((pullbackAngle <= -22.5f && pullbackAngle >= -67.5f) || (pullbackAngle >= 112.5f && pullbackAngle <= 157.5f))
|
|
{
|
|
pullbackX = _position.X - Globals._mouse._newMousePosition.X;
|
|
pullbackY = -pullbackX;
|
|
}
|
|
else
|
|
{
|
|
pullbackX = _position.X - Globals._mouse._newMousePosition.X;
|
|
pullbackY = pullbackX;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
pullbackX = _position.X - Globals._mouse._newMousePosition.X;
|
|
pullbackY = _position.Y - Globals._mouse._newMousePosition.Y;
|
|
}
|
|
_pullback = new Vector2(pullbackX, pullbackY);
|
|
_rotation = Globals.RotateTowards(_position, _position + _pullback);
|
|
|
|
}
|
|
}
|
|
|
|
public virtual void TryCollision()
|
|
{
|
|
if (_moving)
|
|
{
|
|
for (int i = 0; i < Globals._battle._marbles.Count; i++)
|
|
{
|
|
Marble tempMarble = Globals._battle._marbles[i];
|
|
if (tempMarble == this)
|
|
{
|
|
continue;
|
|
}
|
|
if (Globals.CalculateDistance(_position, tempMarble._position) <= (_radius + tempMarble._radius))
|
|
{
|
|
CollideWithMarble(tempMarble);
|
|
break;
|
|
}
|
|
}
|
|
CollideWithWallOuter(Globals._battle._outerWall);
|
|
//for (int i = 0; i < Globals._battle._innerWalls.Count; i++)
|
|
//{
|
|
// CollideWithInnerWall(Globals._battle._innerWalls[i]);
|
|
//}
|
|
|
|
}
|
|
}
|
|
|
|
public virtual void TryHover()
|
|
{
|
|
_hovered = IsHovered();
|
|
if (_hovered && Globals._battle._focalMarble == null)
|
|
{
|
|
Globals._battle._focalMarble = this;
|
|
}
|
|
}
|
|
|
|
public virtual void TryLaunch()
|
|
{
|
|
if (_aimed && IsFocal() && !_hovered)
|
|
{
|
|
if (Globals._mouse.LeftClickRelease())
|
|
{
|
|
_aimed = false;
|
|
_actionTaken = true;
|
|
_launched = true;
|
|
_velocity = new Vector2(_pullback.X * 20 / _mass / 60, _pullback.Y * 20 / _mass / 60);
|
|
_focusedAction ??= _defaultAction;
|
|
ProcessOnLaunch();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public virtual void TryMovement()
|
|
{
|
|
if (_velocity.X != 0 || _velocity.Y != 0)
|
|
{
|
|
if (!_moving)
|
|
{
|
|
_moving = true;
|
|
}
|
|
ProcessOnMovement();
|
|
|
|
_rotation = Globals.RotateTowards(_position, _position + _velocity);
|
|
_velocity = Globals.RotateAround(_velocity, Vector2.Zero, _spin * 360 / 60 / 60);
|
|
|
|
_position += _velocity;
|
|
_distanceMoved += _velocity.Length();
|
|
|
|
_stats._stamina -= _velocity.Length() / 200;
|
|
float staminaRemaining = _stats._stamina / _stats._staminaMax;
|
|
|
|
Vector2 acceleration = Vector2.Normalize(_velocity) * -5 / 60;
|
|
|
|
//// Air Drag not sure if I'll actually implement
|
|
//float v2 = _velocity.LengthSquared();
|
|
//float vAbs = MathF.Sqrt(v2);
|
|
//float fDrag = _airDrag * v2;
|
|
//Vector2 f = fDrag / vAbs * _velocity;
|
|
//_velocity -= 1 / _mass * f;
|
|
|
|
float velocityX = (_velocity.X + acceleration.X) * staminaRemaining * _friction, velocityY = (_velocity.Y + acceleration.Y) * staminaRemaining * _friction;
|
|
if (Math.Abs(acceleration.X) > Math.Abs(_velocity.X))
|
|
{
|
|
velocityX = 0;
|
|
}
|
|
if (Math.Abs(acceleration.X) > Math.Abs(_velocity.X))
|
|
{
|
|
velocityY = 0;
|
|
}
|
|
_velocity = new Vector2(velocityX, velocityY);
|
|
|
|
}
|
|
else
|
|
{
|
|
if (_moving)
|
|
{
|
|
ProcessOnStop();
|
|
}
|
|
_moving = false;
|
|
_lastCollisionObject = null;
|
|
_launched = false;
|
|
}
|
|
}
|
|
public virtual void TrySelect()
|
|
{
|
|
if (_hovered && IsFocal())
|
|
{
|
|
if (Globals._mouse.LeftClick())
|
|
{
|
|
_selected = true;
|
|
}
|
|
}
|
|
|
|
if (_selected)
|
|
{
|
|
if (_actionSelector != null && Globals._mouse.LeftClickRelease())
|
|
{
|
|
if (!_actionSelector._skipPress)
|
|
{
|
|
_actionSelector.Activate();
|
|
}
|
|
else
|
|
{
|
|
_actionSelector._skipPress = false;
|
|
}
|
|
}
|
|
|
|
if (!_hovered && !_actionSelector._hovered)
|
|
{
|
|
if (Globals._mouse.LeftClick())
|
|
{
|
|
_selected = false;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (_actionSelector != null)
|
|
{
|
|
if (!_actionSelector._hovered)
|
|
{
|
|
_actionSelector.Deactivate();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual void TurnComplete()
|
|
{
|
|
_turnDone = true;
|
|
_isTurn = false;
|
|
_focusedAction = null;
|
|
ProcessOnTurnEnd();
|
|
|
|
//for (int i = 0; i < _actions.Count; i++)
|
|
//{
|
|
// _actions[i].NextTurn();
|
|
//}
|
|
|
|
}
|
|
|
|
public virtual void TurnStart()
|
|
{
|
|
_turnDone = false;
|
|
_isTurn = true;
|
|
_actionTaken = false;
|
|
_startPosition = _position;
|
|
_stats._stamina = _stats._staminaMax;
|
|
ProcessOnTurnStart();
|
|
}
|
|
|
|
public override void Draw()
|
|
{
|
|
if (_position.X > -1 && _position.Y > -1)
|
|
{
|
|
base.Draw();
|
|
if (_actionSelector != null)
|
|
{
|
|
if (_actionSelector._active)
|
|
{
|
|
_actionSelector.Draw();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|