public void Update() { if (Selecting == 6 || !Lights[Selecting].activeInHierarchy) { if (Input.GetKeyDown(KeyCode.UpArrow)||JoyListener.UGetUpDown) OnButtinSelected((Selecting + Buttons.Length - 1) % Buttons.Length); if(Input.GetKeyDown(KeyCode.DownArrow)||JoyListener.UGetDownDown) OnButtinSelected((Selecting + 1) % Buttons.Length); if (Input.GetKeyDown(KeyCode.Return)||(Selecting == 6 && Input.GetButtonDown("A"))) { OnButtinClicked(Selecting); return; } if (Input.GetKeyDown(KeyCode.Escape)||Input.GetButtonDown("B")) { OnButtinClicked(6); } } if (Input.anyKeyDown&&(Selecting<6&&Lights[Selecting].activeInHierarchy)) { foreach (KeyCode keyCode in System.Enum.GetValues(typeof(KeyCode))) { if (Input.GetKeyDown(keyCode)) { if (keyCode == KeyCode.Mouse0 || keyCode == KeyCode.Mouse1 || keyCode == KeyCode.Mouse2 || keyCode == KeyCode.Mouse3 || keyCode == KeyCode.Mouse4 || keyCode == KeyCode.Mouse5 || keyCode == KeyCode.Mouse6) continue; Lights[Selecting].SetActive(false); if (keyCode != KeyCode.Escape && keyCode != KeyCode.Return) { ScoreSaver ss = new ScoreSaver(Application.persistentDataPath + "/gamesave"); switch (Selecting) { case 0: ss.Key_Up = keyCode; break; case 1: ss.Key_Down = keyCode; break; case 2: ss.Key_Left = keyCode; break; case 3: ss.Key_Right = keyCode; break; case 4: ss.Key_Turn = keyCode; break; case 5: ss.Key_OverView = keyCode; break; } ss.SaveToFile(); RefreshScore(); } break; } } } }
private int NowLevel;// 0 to 12 public void RefreshData() { //更新UI if (LevelText != null) { LevelText.text = "Level " + (NowLevel + 1).ToString(); } //更新最高分数据 //UI测试版本 //for (int i = 0; i < NameTexts.Length; ++i) //{ // if (NameTexts[i] == null || ScoreTexts[i] == null) // continue; // NameTexts[i].text = "第" + (NowLevel + 1).ToString() + "关 第" + (i + 1).ToString() + "名"; // ScoreTexts[i].text = "L" + (NowLevel + 1).ToString() + "S" + (i + 1).ToString(); //} //文件存取排行榜 string gamesave = Application.persistentDataPath + "/gamesave"; ScoreSaver ss = new ScoreSaver(gamesave); for (int i = 0; i < 10; ++i) { if (NameTexts[i] == null || ScoreTexts[i] == null) { continue; } NameTexts[i].text = ss.levelScoreSaver[NowLevel].name[i]; ScoreTexts[i].text = ss.levelScoreSaver[NowLevel].score[i].ToString();; } ss.SaveToFile(); }
public override void OnButtinClicked(int ButtinId) { base.OnButtinClicked(ButtinId); //一定是返回按钮了 ScoreSaver ss = new ScoreSaver(Application.persistentDataPath + "/gamesave"); ss.levelScoreSaver[GameObject.FindGameObjectWithTag("LevelManager").GetComponent <LevelManager>().CurrentLevel].AddScore(PlayerNameText.text == ""?"Name_": PlayerNameText.text, (int)theScore); ss.SaveToFile(); GoToMenu(HighscoreMenu); //这里重定义父窗口 HighscoreMenu.GetComponent <MenuScript>().ParentMenu = GameEndMenu; }