diff --git a/theProject/Assets/Scripts/Soldier.cs b/theProject/Assets/Scripts/Soldier.cs index 71ea91a1..d611ae63 100644 --- a/theProject/Assets/Scripts/Soldier.cs +++ b/theProject/Assets/Scripts/Soldier.cs @@ -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() { diff --git a/theProject/Assets/Scripts/Squad.cs b/theProject/Assets/Scripts/Squad.cs index 5ca2ba8a..25d19248 100644 --- a/theProject/Assets/Scripts/Squad.cs +++ b/theProject/Assets/Scripts/Squad.cs @@ -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)); } }