mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 19:23:03 +02:00
Soldier: Added preliminary interrupt handling
+ soldier can now set its target destination when ordered to move to a position +/- Squad: refactored MovementOrder to be less error prone - cleaned up NotImplementedException for Exeecuting a Movement order
This commit is contained in:
parent
2c52961575
commit
1469eadfd5
@ -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()
|
||||
{
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user