コード例 #1
0
    void DestroyMyself()
    {
        Destroy(gameObject);

        // 游戏结束
        MainSceneEventManager.GameOver();
    }
コード例 #2
0
 void Update()
 {
     if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began || Input.GetKeyDown(KeyCode.R))
     {
         MainSceneEventManager.RestartGame();
     }
 }
コード例 #3
0
    void Update()
    {
        SpawnPlatform();

        // 随着时间的推移,生成刺的概率将加大
        if ((long)MainSceneEventManager.getTimeScore() + MainSceneEventManager.getBonus() > 10000 && addons.Count < 4)
        {
            addons.Add(addons[addons.Count - 1]);
        }
    }
コード例 #4
0
 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();
 }
コード例 #5
0
 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();
     }
 }