using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class CommandList : MonoBehaviour {

    [System.Serializable]
	public enum Command
	{
		NONE=0,
		MOVE_FORWARD=1,
		MOVE_BACKWARD=2,
		STOP_MOVING=3,
		FIRE_CANNON=4,
		FIRE_ROCKET=5,
		FIRE_MACHINEGUN=6,

	};

	public List<Command> list;
	int currentIndex = 0;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}

	public string ExportCommads()
	{
		string result = "";
		foreach(Command node in list)
		{
			result += (int)node + ":";
		}

		return result;
	}

	public void SetCommandList(List<Command> newList)
	{
		currentIndex = 0;
		list = newList;
	}

	public void SetCommandList(string newList)
	{
		currentIndex = 0;
		list.Clear();

		string[] result = newList.Split(new string[]{":"},System.StringSplitOptions.None);
		foreach(string value in result)
		{
			if (value.Length == 0)
				continue;
			int command = int.Parse(value);
			list.Add( (Command) command);
		}

	}

	public Command PopFirstCommand()
	{
		Command result = Command.NONE;
		if (currentIndex < list.Count)
		{	
			result = list[currentIndex++];
		}

		return result;
	}
}
