Skip to content
Snippets Groups Projects
ChangeColour.cs~ 1.28 KiB
Newer Older
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ChangeColour : MonoBehaviour
{
    public int GoalState = 0; // Any integer between 0 - 2, nogo, target, go respectively
    public Color NoGoColor = Color.red;
    public Color TargetColor = Color.yellow;
    public Color GoColor = Color.green;

    private bool Target = false;
    private bool Go = false;
    private bool NoGo = false;

    
    private SpriteRenderer m_SpriteRenderer;

    // Start is called before the first frame update
    void Start()
    {
        m_SpriteRenderer = gameObject.GetComponent<SpriteRenderer>();
        m_SpriteRenderer.color = NoGoColor;
        NoGo = true;
    }

    // Update is called once per frame
    void Update()
    {
        switch(GoalState)
        {
            case 0:
                m_SpriteRenderer.color = NoGoColor;
                Go = false;
                Target = false;
                break;
            case 1:
                m_SpriteRenderer.color = TargetColor;
                NoGo = false;
                Go = false;
                break;
            case 2:
                m_SpriteRenderer.color = GoColor;
                NoGo = false;
                Target = false;
                break;
        }
    }
}