Beispiel #1
0
    void Update()
    {
        //制限時間が0秒以下なら何もしない
        if (totalTime > 1)
        {
            //一旦トータルの制限時間を計測;
            totalTime  = minute * 60 + seconds;
            totalTime -= Time.deltaTime;

            //再設定
            minute  = (int)totalTime / 60;
            seconds = totalTime - minute * 60;

            //タイマー表示用UIテキストに時間を表示する
            if ((int)seconds != (int)oldSeconds)
            {
                timerText.text = minute.ToString("00") + ":" + ((int)seconds).ToString("00");
            }
            oldSeconds = seconds;

            //制限時間以下になったらタイムアップと表示する
            if (totalTime < 1)
            {
                //テキストを表示
                GameObject GoalText;
                GoalText = GameObject.Find("Text");
                Text text = GoalText.GetComponent <Text>();
                text.text = "タイムアップ!";
                //シーン移動
                StartCoroutine("ChangeScene");
            }
        }
    }
 private void Start()
 {
     try
     {
         goalText = FindObjectOfType <GoalText>().GetComponent <GoalText>();
         tutorial = FindObjectOfType <TutorialStage>().GetComponent <TutorialStage>();
     }
     catch (Exception e)
     {
         //Avoid crash
     }
     //Debug data remove
     //PlayerPrefs.DeleteAll();
 }
Beispiel #3
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.name == "player")
     {
         //テキストを表示
         GameObject GoalText;
         GoalText = GameObject.Find("Text");
         Text text = GoalText.GetComponent <Text>();
         text.text = "ゴール!";
         //タイマーを止める
         GameObject Timer  = GameObject.Find("Timer");
         Timer      script = Timer.GetComponent <Timer>();
         script.enabled = false;
         //シーン移動
         StartCoroutine("ChangeScene");
     }
 }
Beispiel #4
0
 // Use this for initialization
 void Start()
 {
     instance = this;
 }