void DestroyMyself() { Destroy(gameObject); // 游戏结束 MainSceneEventManager.GameOver(); }
void Update() { if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began || Input.GetKeyDown(KeyCode.R)) { MainSceneEventManager.RestartGame(); } }
void Update() { SpawnPlatform(); // 随着时间的推移,生成刺的概率将加大 if ((long)MainSceneEventManager.getTimeScore() + MainSceneEventManager.getBonus() > 10000 && addons.Count < 4) { addons.Add(addons[addons.Count - 1]); } }
void Awake() { if (instance != null) { Destroy(gameObject); } instance = this; Time.timeScale = 1; bonus = 0; timeScore = 0; isGameover = false; Random.InitState((int)System.DateTime.Now.Ticks); MySqlSystemInit(); }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Spike")) // 尖刺碰撞 { Dead(); } else if (other.CompareTag("Broken Block")) // 踩在会坏掉的平台上 { other.GetComponent <Brokenblock>().trigger(); } else if (other.CompareTag("Strawberry")) // 吃草莓 { other.GetComponent <Strawberry>().trigger(); MainSceneEventManager.addScore(1000); // 加1000分 Handheld.Vibrate(); } }