mirror of
https://github.com/Steffo99/octogem.git
synced 2024-10-16 20:17:26 +00:00
33 lines
713 B
C#
33 lines
713 B
C#
|
using UnityEngine;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
[System.Serializable]
|
|||
|
class Order : System.Object
|
|||
|
{
|
|||
|
public List<MapPosition> steps;
|
|||
|
|
|||
|
public Order(MapPosition start)
|
|||
|
{
|
|||
|
steps.Add(start);
|
|||
|
}
|
|||
|
|
|||
|
public void AddStep(MapPosition newStep)
|
|||
|
{
|
|||
|
MapPosition lastStep = steps[steps.Count - 1];
|
|||
|
if(!newStep.IsAdjacent(lastStep))
|
|||
|
{
|
|||
|
throw new Exception("newStep is not adjacent to the lastStep");
|
|||
|
}
|
|||
|
steps.Add(newStep);
|
|||
|
}
|
|||
|
|
|||
|
public void CancelLastStep()
|
|||
|
{
|
|||
|
if(steps.Count < 2)
|
|||
|
{
|
|||
|
throw new Exception("Can't remove the first step");
|
|||
|
}
|
|||
|
steps.RemoveAt(steps.Count - 1);
|
|||
|
}
|
|||
|
}
|