コード例 #1
0
    private void SnakeDone(Snake snake)
    {
        dino.ClearScoreText();

        data.score += snake.GetTotalScore();
        data.movesLeft--;

        OnGameDataUpdated?.Invoke(data);
        CheckTargetGoals();
    }
コード例 #2
0
        public static void ResolveGameData(bool useCloudData)
        {
            if (useCloudData && _resolvingGameData != null)
            {
                Instance.GameData = _resolvingGameData;
            }

            _resolvingGameData = null;
            SaveData();
            OnGameDataUpdated?.Invoke(null, new GameDataUpdatedEventArgs(false));
        }
コード例 #3
0
        private void CloudDataWasReadCallback(SavedGameRequestStatus status, byte[] data)
        {
            if (status == SavedGameRequestStatus.Success)
            {
                GameData loadedGameData;
                var      jsonString = Encoding.ASCII.GetString(data);

                try
                {
                    loadedGameData = JsonUtility.FromJson <GameData>(jsonString);
                    loadedGameData.NormalizeData();
                }
                catch
                {
                    loadedGameData = new GameData();
                }

                if (loadedGameData.dataVersion == GameData.DataVersionReference &&
                    (loadedGameData.gameProgress > GameData.gameProgress ||
                     loadedGameData.gameProgress == GameData.gameProgress && loadedGameData.SaveDate > GameData.SaveDate))
                {
                    _resolvingGameData = loadedGameData;
                    OnGameDataUpdated?.Invoke(this, new GameDataUpdatedEventArgs(true));
                    UpdateCloudStatus(CloudStatus.CloudUpdated);
                }
                else
                {
                    UpdateCloudStatus(CloudStatus.CloudUpdated);
                    OpenCloud(CloudAction.Saving);
                }
            }
            else
            {
                UpdateCloudStatus(CloudStatus.CloudDisconnected);
            }
        }
コード例 #4
0
        public void LoadLocalData()
        {
            UpdateCloudStatus(CloudStatus.CloudDisconnected);

            if (File.Exists(_gameDataPath))
            {
                using (var streamReader = File.OpenText(_gameDataPath))
                {
                    var jsonString = streamReader.ReadToEnd();

                    try
                    {
                        var loadedGameData = JsonUtility.FromJson <GameData>(jsonString);
                        if (loadedGameData.dataVersion != GameData.DataVersionReference)
                        {
                            GameData = new GameData();
                        }
                        else
                        {
                            GameData = loadedGameData;
                            GameData.NormalizeData();
                        }
                    }
                    catch
                    {
                        GameData = new GameData();
                    }
                }
            }
            else
            {
                GameData = new GameData();
            }

            OnGameDataUpdated?.Invoke(this, new GameDataUpdatedEventArgs(false));
        }
コード例 #5
0
ファイル: KancolleGameDataContext.cs プロジェクト: qqdown/Wo
        public void OnAPIResponseReceivedHandler(RequestInfo requestInfo, string response, string api)
        {
            var  data            = JsonConvert.DeserializeObject(response) as JObject;
            var  api_object      = data["api_data"];
            bool gameDataUpdated = true;

            switch (api)
            {
            case "api_start2":
                UpdateShipDatas(api_object["api_mst_ship"] as JArray);
                UpdateMissions(api_object["api_mst_mission"] as JArray);
                UpdateMissions(api_object["api_mst_mission"] as JArray);
                UpdateMapInfoDictionary(api_object["api_mst_mapinfo"] as JArray);
                UpdateSlotDictionary(api_object["api_mst_slotitem"] as JArray);
                UpdateShipTypeDictionary(api_object["api_mst_stype"] as JArray);
                UpdateItemEquipTypeDictionary(api_object["api_mst_slotitem_equiptype"] as JArray);
                break;

            case "api_port/port":
                UpdateOwnedShips(api_object["api_ship"] as JArray);
                UpdateMaterial(api_object["api_material"] as JArray);
                UpdatePort(api_object);
                UpdateDeck(api_object["api_deck_port"] as JArray);
                UpdateDock(api_object["api_ndock"] as JArray);
                break;

            case "api_req_hensei/change":    //舰队编成修改
                UpdateDeck(requestInfo.Data);
                break;

            case "api_get_member/material":
                UpdateMaterial(api_object as JArray);
                break;

            case "api_req_hokyu/charge":
                UpdateMaterial(api_object["api_material"].ToObject <int[]>());
                break;

            case "api_get_member/require_info":
                UpdateOwnedSlotDictionary(api_object["api_slot_item"] as JArray);
                break;

            case "api_get_member/slot_item":
                UpdateOwnedSlotDictionary(api_object as JArray);
                break;

            case "api_get_member/questlist":
                UpdateQuest(api_object);
                break;

            case "api_get_member/mission":    //可进行的远征任务
                UpdateOwnedMissionDictionary(api_object as JArray);
                break;

            case "api_get_member/ship3":
                UpdateShip3(api_object);
                break;

            case "api_req_kaisou/slot_deprive":    //更换在已有舰娘身上的装备
                UpdateDeprived(api_object);
                break;

            case "api_get_member/ndock":    //获取入渠信息
                UpdateDock(api_object as JArray);
                break;

            case "api_get_member/ship_deck":    //战斗后的舰娘信息
                UpdateShips(api_object["api_ship_data"] as JArray);
                break;

            case "api_req_sortie/battle":
                break;

            default:
                gameDataUpdated = false;
                break;
            }
            if (gameDataUpdated)
            {
                //更新装备情况
                UpadteOwnedSlotItemEquipInfo();

                try
                {
                    OnGameDataUpdated?.InvokeAll(this);
                }
                catch (AggregateException exList)
                {
                    foreach (var ex in exList.InnerExceptions)
                    {
                        MessageBox.Show("OnGameDataUpdated出错!\n" + ex.Message + "\n" + ex.StackTrace);
                    }
                }
            }
        }
コード例 #6
0
 public void GameDataUpdated()
 {
     OnGameDataUpdated?.Invoke();
 }