using UnityEngine;
using System.Collections;

public class Heretic : 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.CYAN: {
                    ControlCyan();
                    break;
            }
            case Constants.Colors.BLUE: {
                    ControlBlue();
                    break;
                }
            case Constants.Colors.MAGENTA: {
                    ControlMagenta();
                    break;
                }
            case Constants.Colors.GREEN: {
                    ControlGreen();
                    break;
                }
            case Constants.Colors.RED: {
                    ControlRed();
                    break;
                }

        }
    }

    void ControlRed() {
        if(controller.ings.Count==1 && controller.ings[0] == "Dragon's Blood") {
            currentState = Constants.Colors.BLUE;
            controller.ings.Clear();
        }
    }

    void ControlGreen() {
        if (controller.ings.Count == 2 && controller.ings[0] == "SL" && controller.ings[1] == "Stardust") {
            currentState = Constants.Colors.BLUE;
            controller.ings.Clear();
        }
    }

    void ControlMagenta() {
        if (controller.ings.Count == 1 && controller.ings[0] == "Flies") {
            currentState = Constants.Colors.BLUE;
            controller.ings.Clear();
        }
    }
    
    void ControlBlue() {
        if (controller.ings.Count == 1 && controller.ings[0] == "Bone Dust") {
            currentState = Constants.Colors.RED;
            controller.ings.Clear();
        }
        else if(controller.ings.Count == 1 && controller.ings[0] == "Wings of a Bat") {
            currentState = Constants.Colors.MAGENTA;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 2 && controller.ings[0] == "Lava" && controller.ings[1] == "SR") {
            currentState = Constants.Colors.GREEN;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 1 && controller.ings[0] == "SL") {
            currentState = Constants.Colors.CYAN;
            controller.ings.Clear();
        }
    }

    void ControlCyan() {
        if (controller.ings.Count == 1 && controller.ings[0] == "SR") {
            currentState = Constants.Colors.BLUE;
            controller.ings.Clear();
        }
    }
}
