void SetUp()
    {
        // Set Time
        currentMinutes = startMinutes;
        currentSeconds = startingSeconds;
        deductTime     = true;

        // Set the current and last state
        currentState = timeState.okay;
        lastState    = currentState;

        // Create color
        col = new Color();
        col = Color.green;

        // Get UI Text and set color
        timeDisplayed       = GetComponent <Text>();
        timeDisplayed.color = col;
    }
 void RefreshColourAndMusic()
 {
     if (currentMinutes <= 0)
     {
         if (currentSeconds >= 30)
         {
             col = Color.green;
             timeDisplayed.color = col;
             currentState        = timeState.okay;
         }
         else if (currentSeconds >= 15)
         {
             col = Color.yellow;
             timeDisplayed.color = col;
             currentState        = timeState.late;
         }
         else if (currentSeconds > 0)
         {
             col = Color.red;
             timeDisplayed.color = col;
             currentState        = timeState.hurry;
         }
         else
         {
             col = Color.black;
             timeDisplayed.color = col;
             currentState        = timeState.hurry;
         }
     }
     else
     {
         col = Color.green;
         timeDisplayed.color = col;
         currentState        = timeState.okay;
     }
 }
Beispiel #3
0
    //Actually add stuff here to change the state of the object as necessary, this just makes it actually affected by the change in time
    //Should probably write more functions to change sprite, interactability/collider, etc.
    public void changeTime(timeState new_time)
    {
        if (currentTime == new_time)
        {
            Debug.Log("Time already set! No changes to be made to " + this + " object.");
            return;
        }
        else
        {
            position = GetComponent <Transform>().position;
            rotation = GetComponent <Transform>().rotation;
            var laser     = GetComponent <Laser>();
            var clockrock = GetComponent <ChangeTime>();

            if (new_time == timeState.Past)
            {
                currentTime = timeState.Past;
                //Debug.Log("Setting this " + this + " object to past!");
                if (laser)
                {
                    parent         = laser.transform.parent.gameObject;
                    laserdirection = laser.dir;
                    Destroy(this.gameObject);
                    var newobj = Instantiate(pastObject, parent.transform);
                    newobj.GetComponent <Laser>().dir          = laserdirection;
                    newobj.GetComponent <Transform>().position = position;
                    newobj.GetComponent <Transform>().rotation = rotation;
                }
                else if (clockrock)
                {
                    radius = clockrock.CastRadius;
                    Destroy(this.gameObject);
                    var newobj = Instantiate(pastObject);
                    newobj.GetComponent <ChangeTime>().CastRadius = radius;
                    newobj.GetComponent <Transform>().position    = position;
                }
                else
                {
                    Destroy(this.gameObject);
                    var newobj = Instantiate(pastObject);
                    newobj.GetComponent <Transform>().position = position;
                }
            }
            else
            {
                currentTime = timeState.Present;
                //Debug.Log("Setting this " + this + "object to present!");
                if (laser)
                {
                    parent         = laser.transform.parent.gameObject;
                    laserdirection = laser.dir;
                    Destroy(this.gameObject);
                    var newobj = Instantiate(presentObject, parent.transform);
                    newobj.GetComponent <Laser>().dir          = laserdirection;
                    newobj.GetComponent <Transform>().position = position;
                    newobj.GetComponent <Transform>().rotation = rotation;
                }
                else if (clockrock)
                {
                    radius = clockrock.CastRadius;
                    Destroy(this.gameObject);
                    var newobj = Instantiate(presentObject);
                    newobj.GetComponent <ChangeTime>().CastRadius = radius;
                    newobj.GetComponent <Transform>().position    = position;
                }
                else
                {
                    Destroy(this.gameObject);
                    var newobj = Instantiate(presentObject);
                    newobj.GetComponent <Transform>().position = position;
                }
            }
        }
    }