コード例 #1
0
        // Update is called once per frame
        void Update()
        {
            if (gameStarted && TimeRemaining.TotalSeconds > 0)
            {
                TimeRemaining = TimeRemaining.Subtract(TimeSpan.FromSeconds(Time.deltaTime));
                var timer = GameObject.Find("Timer").GetComponent <Text>();
                timer.text = $"{TimeRemaining.Minutes.ToString("00")}:{TimeRemaining.Seconds.ToString("00")}";

                if (TimeRemaining <= TimeSpan.FromSeconds(0.17 * TimeInSeconds))
                {
                    timer.color = Color.red;
                }
                else if (TimeRemaining <= TimeSpan.FromSeconds(0.5 * TimeInSeconds))
                {
                    timer.color = Color.yellow;
                }
                else
                {
                    timer.color = Color.white;
                }
            }
            else if (TimeRemaining.TotalSeconds < 1)
            {
                gameOver();
            }
        }
コード例 #2
0
ファイル: Microwave3.cs プロジェクト: jaredallpass/Microwave3
    /// <summary>
    /// Executes the cooking processes.
    /// </summary>
    private void Cook()
    {
        TimeRemaining = TimeRemaining.Subtract(new TimeSpan(0, 0, 1));

        //if (TimeRemaining == new TimeSpan())
        //{
        //    Stop();
        //}
    }
コード例 #3
0
 private void Tick(object sender, ElapsedEventArgs e)
 {
     if (TimeRemaining == null || TimeRemaining.TotalMilliseconds <= timer.Interval)
     {
         TimeRemaining = new TimeSpan();
     }
     else
     {
         TimeRemaining.Subtract(TimeSpan.FromMilliseconds(timer.Interval));
     }
 }
コード例 #4
0
 public void Decrement()
 {
     TimeRemaining =
         TimeRemaining.Subtract(TimeSpan.FromSeconds(1));
 }