using UnityEngine;



public class VisualDebug : UserAgentBaseClass
{

    [SerializeField]
    bool debugMode;

    [SerializeField]
    Material redMaterial;
    [SerializeField]
    Material whiteMaterial;
    [SerializeField]
    Material pinkMaterial;
    [SerializeField]
    Material greenMaterial;
    [SerializeField]
    Material yellowMaterial;
    [SerializeField]
    Material orangeMaterial;
    [SerializeField]
    Material brownMaterial;
    [SerializeField]
    Material lightGreenMaterial;
    [SerializeField]
    Material tealMaterial;
    [SerializeField]
    Material blackMaterial;

    [SerializeField]
    Material defaultMaterial;

    [SerializeField]
    MeshRenderer meshRenderer;



    void Update()
    {
        if (debugMode) { SetColor(); }
    }

    public void SetColor()
    {
        if (buttonPad.AreAllButtonsFree())
        {
            RevertToDefault();
            return;
        }

        if (buttonPad.AreAllButtonsPressed())
        {
            TurnBlack();
            return;
        }

        if (buttonPad.AreDiagonalButtonsPressed_RedYellow())
        {
            TurnOrange();
            return;
        }

        if (buttonPad.AreDiagonalButtonsPressed_GreenWhite())
        {
            TurnLightGreen();
            return;
        }

        if (buttonPad.AreParallelButtonsPressed_GreenYellow())
        {
            TurnTeal();
            return;
        }

        if (buttonPad.AreParallelButtonsPressed_RedGreen())
        {
            TurnBrown();
            return;
        }

        if (buttonPad.AreParallelButtonsPressed_RedWhite())
        {
            TurnPink();
            return;
        }

        if (buttonPad.redButtonState)
            TurnRed();
        else if (buttonPad.greenButtonState)
            TurnGreen();
        else if (buttonPad.whiteButtonState)
            TurnWhite();
        else
            TurnYellow();
    }

    #region visualDebug
    public void TurnRed()
    {
        meshRenderer.material = redMaterial;
    }
    public void TurnPink()
    {
        meshRenderer.material = pinkMaterial;
    }
    public void TurnYellow()
    {
        meshRenderer.material = yellowMaterial;
    }
    public void TurnGreen()
    {
        meshRenderer.material = greenMaterial;
    }
    public void TurnWhite()
    {
        meshRenderer.material = whiteMaterial;
    }
    public void TurnTeal()
    {
        meshRenderer.material = tealMaterial;
    }
    public void TurnOrange()
    {
        meshRenderer.material = orangeMaterial;
    }
    public void TurnBrown()
    {
        meshRenderer.material = brownMaterial;
    }
    public void TurnLightGreen()
    {
        meshRenderer.material = lightGreenMaterial;
    }
    public void TurnBlack()
    {
        meshRenderer.material = blackMaterial;
    }


    public void RevertToDefault()
    {
        meshRenderer.material = defaultMaterial;
    }
    #endregion 
}