Example #1
0
 private void OnGUI()
 {
     GUI.Label(new Rect(10, 5, 200, 50), "分数:", textStyle);
     GUI.Label(new Rect(55, 5, 200, 50), action.GetScore().ToString(), scoreStyle);
     GUI.Label(new Rect(Screen.width - 170, 5, 50, 50), "剩余水晶数", textStyle);
     GUI.Label(new Rect(Screen.width - 80, 5, 50, 50), action.GetCrystalNum().ToString(), scoreStyle);
     if (action.GetGameOver() && action.GetCrystalNum() != 0)
     {
         GUI.Label(new Rect(Screen.width / 2 - 100, Screen.width / 2 - 250, 100, 100), "您已阵亡!游戏结束!", overStyle);
         if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 150, 100, 50), "重新开始"))
         {
             action.Restart();
             return;
         }
     }
     else if (action.GetCrystalNum() == 0)
     {
         GUI.Label(new Rect(Screen.width / 2 - 150, Screen.width / 2 - 250, 100, 100), "恭喜收集完全部水晶!", overStyle);
         if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.width / 2 - 150, 100, 50), "重新开始"))
         {
             action.Restart();
             return;
         }
     }
     if (showTime > 0)
     {
         GUI.Label(new Rect(Screen.width / 2 - 80, 10, 100, 100), "WSAD控制玩家移动", textStyle);
         GUI.Label(new Rect(Screen.width / 2 - 87, 30, 100, 100), "躲避巡逻兵追捕加1分", textStyle);
         GUI.Label(new Rect(Screen.width / 2 - 90, 50, 100, 100), "寻找水晶以通过游戏!", textStyle);
     }
 }
 private void OnGUI()
 {
     GUI.Label(new Rect(10, 5, 200, 50), "分数:", textStyle);
     GUI.Label(new Rect(55, 5, 200, 50), action.GetScore().ToString(), scoreStyle);
     GUI.Label(new Rect(Screen.width - 170, 5, 50, 50), "剩余球数", textStyle);
     GUI.Label(new Rect(Screen.width - 80, 5, 50, 50), action.GetCrystalNum().ToString(), scoreStyle);
     if (action.GetGameOver() && action.GetCrystalNum() != 0)
     {
         GUI.Label(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 250, 100, 100), "Sorry!游戏结束!", overStyle);
         if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 150, 100, 50), "重新开始"))
         {
             action.Restart();
             return;
         }
     }
     else if (action.GetCrystalNum() == 0)
     {
         GUI.Label(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 250, 100, 100), "恭喜收集完全部物品!", overStyle);
         if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.width / 2 - 150, 100, 50), "重新开始"))
         {
             action.Restart();
             return;
         }
     }
     if (showTime > 0)
     {
         GUI.Label(new Rect(Screen.width / 2 - 80, 10, 100, 100), "方向键控制玩家移动", textStyle);
         GUI.Label(new Rect(Screen.width / 2 - 84, 30, 100, 100), "躲避巡逻兵追捕加1分", textStyle);
         GUI.Label(new Rect(Screen.width / 2 - 200, 50, 100, 100), "寻找失落的彩球以通过游戏,彩球会随人物移动而滚动", textStyle);
     }
 }