コード例 #1
0
ファイル: GameController.cs プロジェクト: spietari/Missile
 // A score is always given when autopilot is off.
 // Spawner gives progressively faster asteroids as the score increases.
 public void addKill()
 {
     if (!autopilot.enabled)
     {
         showMessage("+1");
         score.score++;
     }
     spawner.spawn(score.score);
 }
コード例 #2
0
 // Update is called once per frame
 void Update()
 {
     Bombardment();
     runtime = Time.time - inittime;
     if (Random.Range(0, 1f) < spawnProb)
     {
         GameObject go = asts.spawn(Random.Range(0, 3));
         if (go != null)
         {
             spawnProb += spawnIncr;
         }
     }
     if ((-earthMass + ESS.EarthMass) > delta)
     {
         earthMass = ESS.EarthMass;
     }
     if (earthMass > 1f && earthMass < 2f)
     {
         if (!winstarted)
         {
             winStartTime = Time.time;
             winstarted   = !winstarted;
         }
         winningtime = Time.time - winStartTime;
         if (winningtime > 50f)
         {
             FailText.text = "YOU WON!";
             FailText.canvasRenderer.SetAlpha(1f);
             ec.Lock();
             spawnProb = -1f;
         }
         CoolTime.text = (Mathf.Round(winningtime * 100f) / 100f).ToString();
     }
     if (earthMass > 2f)
     {
         FailText.text = "YOU LOST!";
         FailText.canvasRenderer.SetAlpha(1f);
         ec.Lock();
         spawnProb = 1f;
     }
     TimeElapsed.text     = (Mathf.Round(runtime * 100f) / 100f).ToString();
     EarthMassNumber.text = (Mathf.Round(earthMass * 1000f) / 1000f).ToString();
     if (Input.GetKeyDown(KeyCode.R))
     {
         Restart();
         ESS.SetMass(initEarthScale);
         earthMass = ESS.EarthMass;
         Restart();
     }
 }