Exemple #1
0
        public override string ToString()
        {
            string s = TimeActive.ToShortString();

            if (RelativeTo != null && RelativeTo.TimeActive.TotalSeconds > 0)
            {
                double p = TimeActive.TotalSeconds / RelativeTo.TimeActive.TotalSeconds * 100;
                s += String.Format(" {0:0}%", p);
            }
            return(s);
        }
Exemple #2
0
        private void Active()
        {
            // if less than 30 seconds since mouse was moved last time - define as active
            var activeSpan = DateTime.Now - LastActivity;

            if (activeSpan.TotalSeconds < 30)
            {
                TimeActive = TimeActive.Add(activeSpan);
            }

            LastActivity = DateTime.Now;
        }
Exemple #3
0
    //We have to pause the game sometimes.
    //For ex: the level finished by player.
    /// <summary>
    /// Stops the game. Shows the after game UI.
    /// </summary>
    public void StopTheGame()
    {
        //UI part
        //starts the animation
        GameObject.Find("Canvas/ScorePanel").GetComponent <Animator>().Play("ScorePanel");
        //updating text
        GameObject.Find("Canvas/ScorePanel/ScoreText").GetComponent <Text>().text = "Your time: " + TimeActive.ToString("0.##");

        //pause the game
        Pause();
        //show the stars
        GameObject.Find("Canvas/ScorePanel").GetComponent <ScorePanelScript>().ShowStar();
    }
Exemple #4
0
 public void Add(double seconds)
 {
     TimeActive = TimeActive.Add(TimeSpan.FromSeconds(seconds));
 }