using UnityEngine;
using System.Collections;

public class Goat : Graph {

    public Controller controller;
	// Use this for initialization
	void Awake () {
        currentState = startState;
	}
	
	// Update is called once per frame
	void Update () {
        ChangeState();
	}

    void ChangeState() {
        
        switch (currentState)
        {

            case Constants.Colors.PURPLE: {
                    ControlPurple();
                    break;
                }
            case Constants.Colors.ORANGE: {
                    ControlOrange();
                    break;
                }
            case Constants.Colors.RED: {
                    ControlRed();
                    break;
                }
            case Constants.Colors.BLUE: {
                    ControlBlue();
                    break;
                }
            case Constants.Colors.YELLOW: {
                    ControlYellow();
                    break;
                }

        }
    }

    void ControlYellow() {
        if (controller.ings.Count == 3 && controller.ings[2] == "SL" && controller.ings[1] == "SL" && controller.ings[0] == "Lava") {
            currentState = Constants.Colors.RED;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 2 && controller.ings[1] == "Bone Dust" && controller.ings[0] == "Bone Dust") {
            currentState = Constants.Colors.ORANGE;
            controller.ings.Clear();
        }
    }

    void ControlPurple() {
        if (controller.ings.Count == 1 && controller.ings[0] == "Flies") {
            currentState = Constants.Colors.ORANGE;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 2 && controller.ings[1] == "SL" && controller.ings[0] == "Mermaid Findust") {
            currentState = Constants.Colors.BLUE;
            controller.ings.Clear();
        }
    }

    void ControlBlue() {
        if (controller.ings.Count == 1 && controller.ings[0] == "Poppy Seeds") {
            currentState = Constants.Colors.RED;  
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 2 && controller.ings[1] == "Kraken Ink" && controller.ings[0] == "SR") {
            currentState = Constants.Colors.PURPLE;
            controller.ings.Clear();
        }
    }


    void ControlRed() {
        if (controller.ings.Count == 1 && controller.ings[0] == "Troll Snot") {
            currentState = Constants.Colors.BLUE;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 2 && controller.ings[1] == "Unicorn Blood" && controller.ings[0] == "Eye of The Tiger") {
            currentState = Constants.Colors.ORANGE;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 3 && controller.ings[2] == "Stardust" && controller.ings[1] == "SR" && controller.ings[0] == "SR") {
            currentState = Constants.Colors.YELLOW;
            controller.ings.Clear();
        }

    }

    void ControlOrange() {
        if (controller.ings.Count == 2 && controller.ings[1] == "Dragon's Claw" && controller.ings[0] == "Grave Dirt") {
            currentState = Constants.Colors.RED;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 2 && controller.ings[1] == "Dragon's Blood" && controller.ings[0] == "Dragon's Blood") {
            currentState = Constants.Colors.YELLOW;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 1 && controller.ings[0] == "Wings of a Bat") {
            currentState = Constants.Colors.PURPLE;
            controller.ings.Clear();
        }

    }
}
