Exemplo n.º 1
0
 void Start()
 {
     starMap.GameOverHandler.AddListener(OnGameOverHandler);
     NewGame();
     historyList = JsonReadFileTool.JsonToClasses <int[]>(PlayerPrefs.GetString("history")).ToList();
     if (historyList != null && historyList.Count > 0)
     {
         uiPanel.HistoryPoint.text = "历史最高:" + historyList[0];
     }
     else
     {
         historyList = new List <int>()
         {
             0
         };
     }
 }
Exemplo n.º 2
0
    // 游戏结束的 事件处理
    void OnGameOverHandler()
    {
        // 纪录  历史纪录
        int count = historyList.Count;       // [法1

        for (int i = 0; i < count; i++)      // todo 注意 List的 Count 是动态变化的,插入一个就会更新大小
        {
            if (totalPoint > historyList[i]) // 按照从大到小的 顺序排序
            {
                historyList.Insert(i, totalPoint);
                // return;  // [法2
            }
        }
        PlayerPrefs.SetString("history", JsonReadFileTool.ClassesToString(historyList));
        uiPanel.HistoryPoint.text = "历史最高:" + +historyList[0];
        starMap.ClearAllStar();
    }
Exemplo n.º 3
0
        // 每帧更新
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Q))
            {
                Debug.Log("调试用, 输出所有星星内容");
                GameManager.Instance.starMap.PrintStarList();
            }

            // 查看 历史最高纪录
            if (Input.GetKeyDown(KeyCode.W))
            {
                Debug.LogWarning("查看 历史最高纪录");
                var historyList = JsonReadFileTool.JsonToClasses <int[]>(PlayerPrefs.GetString("history")).ToList();
                if (historyList != null && historyList.Count > 0)
                {
                    for (int i = 0; i < historyList.Count; i++)
                    {
                        Debug.Log("" + (i + 1) + ": " + historyList[i]);
                    }
                }
            }
        }