1
Fork 0
mirror of https://github.com/Steffo99/octogem.git synced 2024-10-16 20:17:26 +00:00
octogem/Assets/Scripts/Structures/Order.cs
2018-09-27 00:38:49 +02:00

33 lines
No EOL
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);
}
}