IEnumerator gameOver() { ThrowGameManager.Instance.gameState = ThrowGameManager.StateType.GAME_END; message.GetComponent <ThrowGame_Message>().show("遊戲結束"); yield return(new WaitForSeconds(2.0f)); number_ctlr.destoryAllNumber(0); //倒數文字變回白色 txt_leftTime.gameObject.GetComponent <MeshRenderer>().material.color = Color.blue; disableAllText(); //關閉能量表 //energyBar.gameObject.SetActive(false); //分數進排行榜 if (ThrowGame_ScoreRecorder.Instance.isHighScore(score)) { message.GetComponent <ThrowGame_Message>().show("恭喜上榜"); yield return(new WaitForSeconds(1.5f)); message.GetComponent <ThrowGame_Message>().keepShow("輸入你的名字"); //開啟鍵盤 MyKeyboard.Instance.enableKeyboard(); //等到案ENTER while (!MyKeyboard.Instance.finishInput()) { yield return(new WaitForSeconds(0.5f)); } //關閉鍵盤 MyKeyboard.Instance.disableKeyboard(); //更新到排行榜 string player_name = MyKeyboard.Instance.txt_input.text.ToString(); if (name == "") { name = "[ ]"; } score_tuple record = new score_tuple(); record.score = this.score; record.name = player_name; record.date = "2016"; ThrowGame_ScoreRecorder.Instance.addScore(record, ThrowGameManager.Mode.TIMER_MODE); } ThrowGameManager.Instance.backToUnstart(); this.gameObject.SetActive(false); }
//遊戲過關 IEnumerator gameClear() { ThrowGameManager.Instance.gameState = ThrowGameManager.StateType.GAME_END; //移除障礙 obstacle.GetComponent <ThrowGame_Obstacle>().disableObstacle(); message.GetComponent <ThrowGame_Message>().show("恭喜過關!!"); yield return(new WaitForSeconds(1.5f)); //分數進排行榜 if (ThrowGame_ScoreRecorder.Instance.isHighScore(score)) { message.GetComponent <ThrowGame_Message>().show("恭喜上榜"); yield return(new WaitForSeconds(1.5f)); message.GetComponent <ThrowGame_Message>().keepShow("輸入你的名字"); //開啟鍵盤 MyKeyboard.Instance.enableKeyboard(); //等到案ENTER while (!MyKeyboard.Instance.finishInput()) { yield return(new WaitForSeconds(0.5f)); } //關閉鍵盤 MyKeyboard.Instance.disableKeyboard(); //更新到排行榜 string player_name = MyKeyboard.Instance.txt_input.text.ToString(); if (name == "") { name = "[ ]"; } score_tuple record = new score_tuple(); record.score = this.score; record.name = player_name; record.date = "2016"; ThrowGame_ScoreRecorder.Instance.addScore(record, ThrowGameManager.Mode.NORMAL_MODE); } disableAllText(); ThrowGameManager.Instance.backToUnstart(); this.gameObject.SetActive(false); }
//新增一筆成績紀錄 public void addScore(score_tuple one_score, ThrowGameManager.Mode mode) { Debug.Log("Add Score"); switch (mode) { case ThrowGameManager.Mode.NORMAL_MODE: scoreDB.normalScoreList.Add(one_score); break; case ThrowGameManager.Mode.TIMER_MODE: scoreDB.timerScoreList.Add(one_score); break; } //排序 sort(); //儲存 saveScore(); //更新排行榜顯示 isChanged = true; }