Beispiel #1
0
        protected virtual void DownloadTitleData_Completed(GetTitleDataResult result)
        {
            Debug.Log("MetaLoopGameManager Downloading TitleData Completed...");
            if (result != null)
            {
                if (!ReadTitleData(result, false))
                {
                    return;
                }
            }
            else
            {
                ShowUnavailableMessage(GameUnavailableMessageType.HOST_UNREACHABLE);
                return;
            }

            AssetManifest assetManifest;

            if (result.Data.ContainsKey(MetaStateSettings._TitleDataKey_CdnManifest))
            {
                assetManifest = JsonConvert.DeserializeObject <AssetManifest>(result.Data[MetaStateSettings._TitleDataKey_CdnManifest]);
                RemoteAssetsManager.Init(assetManifest);
            }


            if (result.Data.ContainsKey(MetaStateSettings._TitleDataKey_RemoteConfig))
            {
                RemoteConfigData.Load(result.Data[MetaStateSettings._TitleDataKey_RemoteConfig]);
            }
            else
            {
                RemoteConfigData.Load(null);
            }


            EventManagerState eventManagerState;

            if (result.Data.ContainsKey(MetaStateSettings._TitleDataKey_EventManager))
            {
                eventManagerState = JsonConvert.DeserializeObject <EventManagerState>(result.Data[MetaStateSettings._TitleDataKey_EventManager]);
            }
            else
            {
                eventManagerState = new EventManagerState();
            }

            Debug.Log("MetaLoopGameManager Downloading User Data...");

            DownloadUserData();
        }
Beispiel #2
0
        public bool ReadTitleData(GetTitleDataResult obj, bool fromRoutineTaskManager = true)
        {
            ServerInfo serverInfo;

            if (obj != null && obj.Data.ContainsKey(MetaStateSettings._TitleDataKey_ServerInfo))
            {
                serverInfo = JsonConvert.DeserializeObject <ServerInfo>(obj.Data[MetaStateSettings._TitleDataKey_ServerInfo]);

                if ((serverInfo.CacheVersion < lastServerInfoCacheVersion) && IsGameAvailable)
                {
                    return(true);                                                                           //ignore this manifest.
                }
                lastServerInfoCacheVersion = serverInfo.CacheVersion;

                if (serverInfo.ServerStatus != ServerStatus.Online)
                {
                    GameUnavailableMessageType gameUnavailableMessageType = GameUnavailableMessageType.MAINTENANCE;

                    if (!string.IsNullOrEmpty(serverInfo.MaintenanceMessage))
                    {
                        try
                        {
                            gameUnavailableMessageType = (GameUnavailableMessageType)Enum.Parse(typeof(GameUnavailableMessageType), serverInfo.MaintenanceMessage);
                        }
                        catch { }
                    }

                    ShowUnavailableMessage(gameUnavailableMessageType);

                    return(false);
                }
                else if (serverInfo.ServerStatus == ServerStatus.Online)
                {
                    //"0.1" is wildcard for dev/staging env
                    if (serverInfo.AppVersion == MetaStateSettings.GetMajorVersion() || serverInfo.AppVersion == "0.10" || serverInfo.AppVersion == "0.1")
                    {
                        IsGameAvailable = true;

                        if (fromRoutineTaskManager && DataLayer.Instance.Connection != null)
                        {
                            if (obj != null && obj.Data.ContainsKey(MetaStateSettings._TitleDataKey_EventManager))
                            {
                                EventManagerState eventManagerState = JsonConvert.DeserializeObject <EventManagerState>(obj.Data[MetaStateSettings._TitleDataKey_EventManager]);
                                GameData.Current.EventManagerState = eventManagerState;
                                GameData.Current.EventManagerState.SyncState(EventData.GetAllEvents());
                            }
                        }
                    }
                    else
                    {
                        ShowUnavailableMessage(GameUnavailableMessageType.VERSION_MISMATCH);
                    }
                }
            }
            else
            {
                if (CheckInternetConnection())
                {
                    ShowUnavailableMessage(GameUnavailableMessageType.HOST_UNREACHABLE);
                }
                else
                {
                    ShowUnavailableMessage(GameUnavailableMessageType.INTERNET_ERROR);
                }

                return(false);
            }

            return(true);
        }