Merge branch 'SpartaqS-SoldierMovementInterrupt' into 'Development'

Soldier: Added preliminary interrupt handling

See merge request gskowron/eopsy-lab-567-project!9
This commit is contained in:
Gabriel Ksawery Skowron-Rodriguez 2022-05-22 21:37:36 +02:00
commit 23de96c839
2 changed files with 22 additions and 9 deletions

View File

@ -17,9 +17,8 @@ public class Soldier : MonoBehaviour
{
public override void Execute(Soldier soldier, TickSystem.OnTickEventArgs tickEventArgs)
{//TO DO: CALL PROPER FUNCTION TO MOVE
Debug.LogWarning($"(tick: {tickEventArgs.tickNumber}) Trying to teleport to {soldier.movementDestination}");
throw new System.NotImplementedException();
//tileMap.Teleport(movementDestination)
throw new System.NotImplementedException($"(tick: {tickEventArgs.tickNumber}) Trying to teleport to {soldier.movementDestination}");
//??tileMap.Teleport(movementDestination)
}
}
private class TryAttack : Action
@ -31,8 +30,16 @@ public class Soldier : MonoBehaviour
soldier.lastAttackTick = tickEventArgs.tickNumber;
}
}
#endregion
public enum SoldierType
#endregion
#region Handling Incoming Orders (Interrupts)
public void HandleMovementOrder(Vector2Int destination)
{
movementDestination = destination;
interrupts.Enqueue(new Movement()); // force soldier to find path to the new destination
}
#endregion
public enum SoldierType
{
Ally,
Enemy
@ -51,7 +58,7 @@ public class Soldier : MonoBehaviour
[SerializeField] private TMP_Text nameText = null;
[SerializeField] private TMP_Text healthPointsText = null;
private Vector3Int movementDestination = Vector3Int.zero;
[SerializeField] private Vector2Int movementDestination = Vector2Int.zero;
public SoldierType TempGetOwnType()
{

View File

@ -15,10 +15,16 @@ public class Squad : MonoBehaviour
public class MovementOrder : Order // example how to add new types of orders
{
public int x;
public int y;
public MovementOrder(int x, int y)
{
this.x = x;
this.y = y;
}
public readonly int x;
public readonly int y;
public override void PassToSoldier(Soldier targetSoldier)
{// here we would set soldier's target position for example
targetSoldier.HandleMovementOrder(new Vector2Int(x, y));
Debug.Log($"Soldier {targetSoldier.name} received movement order towards coordinates {x},{y}");
}
}
@ -54,6 +60,6 @@ public class Squad : MonoBehaviour
{
int targetX = 4;
int targetY = 2;
orders.Enqueue(new MovementOrder() { x = targetX, y = targetY });
orders.Enqueue(new MovementOrder(targetX, targetY));
}
}