void Start() { if ((mTesting && !Application.isEditor)) { GameObject.Destroy(this.gameObject); Debug.Log("Destroyed Test Game Instance"); return; } if (mInstance != null && mInstance != this) { GameObject.Destroy(this); return; } mInstance = this; DontDestroyOnLoad(this); InitLogicImplementation(); gameLogicImplementation.Start(); mGameLicense = Helpers.CreateComponentIfNotExists <GameLicense>(this); mGameOptions = Helpers.CreateComponentIfNotExists <GameOptions>(this); mGameState = Helpers.CreateComponentIfNotExists <GameStateManager>(this); mGamePlayer = Helpers.CreateComponentIfNotExists <GamePlayer>(this); mGameMusic = Helpers.CreateComponentIfNotExists <GameMusic>(this); mGameLoca = Helpers.CreateComponentIfNotExists <GameLocalization>(this); mGameLoca.Initialize(); mGamePause = Helpers.CreateComponentIfNotExists <GamePause>(this); mGameInput = Helpers.CreateComponentIfNotExists <GameInput>(this); mSceneTransition = Helpers.CreateComponentIfNotExists <SceneTransition>(this); mGameData = Helpers.CreateComponentIfNotExists <GameData>(this); mFirstFrame = true; }
IEnumerator InitializeInternal() { initialized = true; Instance = this; DontDestroyOnLoad(this); ThreadingBridge.Initialize(); // for webgl we cannot use custom attributes to find classes, so we rely on a delegate to create the logic instance for us. Initialize(); #if UNITY_WEBGL webGLHelper = this.AddComponentIfNotExists <WebGLPlatformHelper>(); #endif gameOptions = this.AddComponentIfNotExists <GameOptions>(); gameMusic = this.AddComponentIfNotExists <GameMusic>(); gameLoca = this.AddComponentIfNotExists <GameLocalization>(); gameLoca.Initialize(); gameInput = this.AddComponentIfNotExists <GameInput>(); sceneTransition = this.AddComponentIfNotExists <SceneTransition>(); objectPool = new ObjectPool(); yield return(new WaitForEndOfFrame()); GameSetupReady(); }
/// <summary> /// Соединяет информацию из файла локализации с базовыми игровыми показателями /// </summary> /// <returns>Объект с полной информацией и локализацией</returns> private List <GameItem> ConvertXmlToGameItemList(GameLocalization gameLocalization) { var localiz = gameLocalization.WorldObjects_Localization.Items_Localization.descriptionItems; var badIds = CheckAndGetBadIds(localiz.Select(x => x.Id).ToList(), xmlGameItemsParameters.Select(x => x.Id).ToList(), "ConvertXmlToItemsList"); xmlGameItemsParameters = xmlGameItemsParameters.Where(x => localiz.Any(y => y.Id == x.Id)).ToList(); List <GameItem> gameItems = new List <GameItem>(); foreach (var paramsItem in xmlGameItemsParameters) { try { GameItem gameItem = new GameItem() { Id = Convert.ToInt32(paramsItem.Id), Description = localiz.FirstOrDefault(x => x.Id == paramsItem.Id).MainDescription, Name = localiz.FirstOrDefault(x => x.Id == paramsItem.Id).SecondaryDescription }; gameItems.Add(gameItem); } catch (Exception ex) { Debug.LogError(ex.Message); continue; } } return(gameItems); }
/// <summary> /// Перезагружает локализацию в игровые объекты воркеров /// </summary> /// <param name="localizationRegion"></param> public void ReloadLocalization(LocalizationOption.LocalizationRegion localizationRegion) { GameLocalization gameLocalization = dataBaseComponent.GetGlobalLocalizationFile(localizationRegion); foreach (var dataBaseWorker in dataBaseWorkers) { dataBaseWorker.ReloadObjectsLanguage(gameLocalization); } }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } }
public bool ReloadObjectsLanguage(GameLocalization gameLocalization) { try { baseUpgradeObjectItems = ConvertXmlToObjectList(xmlUpgrades.Upgrade_Items.Boost_Items.UpgradeBoost_Items.updateObject, gameLocalization.Upgrades_Localization.Upgrade_Items_Localization.Boost_Items_Localization.descriptionItems); allUpgradeBoostItems = ConvertBaseObjectXmlToObjectList(); saveUpgradeBoostItems = ConverSaveXmlToObjectList(); return(true); } catch (Exception ex) { Debug.LogError(ex.Message); return(false); } }
public bool ReloadObjectsLanguage(GameLocalization gameLocalization) { try { allGameItems = ConvertXmlToGameItemList(gameLocalization); allGameItemsSave = ConvertSaveXMLToGameItemList(); return(true); } catch (Exception ex) { Debug.LogError($"{ex.Message} \n {ex.StackTrace} \n MethodName: ReloadItemsLanguage()"); return(false); } }
public bool AreEqual(Object object1, Object object2) { if (object1.GetType() != typeof(Game) || object2.GetType() != typeof(Game)) { throw new ArgumentException(String.Format("An object is not an instance of a {0} class. ", typeof(Game))); } var game1 = (Game)object1; var game2 = (Game)object2; bool genresEquals = true; if (game1.Genres != null && game2.Genres != null) { if (game1.Genres.Count != game2.Genres.Count) { genresEquals = false; } else { foreach (Genre genre in game1.Genres) { string genreName = genre.GenreLocalizations.First( loc => String.Equals(loc.Language.Code, Constants.EnglishLanguageCode, StringComparison.CurrentCultureIgnoreCase)).Name; if (!game2.Genres.Any(x => x.GenreLocalizations .First(loc => String.Equals(loc.Language.Code, Constants.EnglishLanguageCode, StringComparison.CurrentCultureIgnoreCase)) .Name == genreName)) { genresEquals = false; } } } } if ((game1.Genres == null && game2.Genres != null && game2.Genres.Count > 0) || (game1.Genres != null && game2.Genres == null && game1.Genres.Count > 0)) { genresEquals = false; } bool platformTypesEquals = true; if (game1.PlatformTypes != null && game2.PlatformTypes != null) { if (game1.PlatformTypes.Count != game2.PlatformTypes.Count) { platformTypesEquals = false; } else { foreach (PlatformType platformType in game1.PlatformTypes) { string platformTypeType = platformType.PlatformTypeLocalizations.First( loc => String.Equals(loc.Language.Code, Constants.EnglishLanguageCode, StringComparison.CurrentCultureIgnoreCase)).Type; if (!game2.PlatformTypes.Any(x => x.PlatformTypeLocalizations .First(loc => String.Equals(loc.Language.Code, Constants.EnglishLanguageCode, StringComparison.CurrentCultureIgnoreCase)) .Type == platformTypeType)) { platformTypesEquals = false; } } } } if ((game1.PlatformTypes == null && game2.PlatformTypes != null && game2.PlatformTypes.Count > 0) || (game1.PlatformTypes != null && game2.PlatformTypes == null && game1.PlatformTypes.Count > 0)) { platformTypesEquals = false; } bool publisherEquals = true; if (game1.Publisher != null && game2.Publisher != null) { string companyName1 = game1.Publisher.PublisherLocalizations.First(loc => String.Equals(loc.Language.Code, Constants.EnglishLanguageCode, StringComparison.CurrentCultureIgnoreCase)) .CompanyName; string companyName2 = game2.Publisher.PublisherLocalizations.First(loc => String.Equals(loc.Language.Code, Constants.EnglishLanguageCode, StringComparison.CurrentCultureIgnoreCase)) .CompanyName; publisherEquals = companyName1 == companyName2; } bool localizationsEquals = true; GameLocalization englishLocalization1 = game1.GameLocalizations.First( loc => String.Equals(loc.Language.Code, Constants.EnglishLanguageCode, StringComparison.CurrentCultureIgnoreCase)); GameLocalization englishLocalization2 = game2.GameLocalizations.First( loc => String.Equals(loc.Language.Code, Constants.EnglishLanguageCode, StringComparison.CurrentCultureIgnoreCase)); if (englishLocalization1.Name != englishLocalization2.Name || englishLocalization1.Description != englishLocalization2.Description) { localizationsEquals = false; } bool result = game1.Key == game2.Key && game1.Discontinued == game2.Discontinued && game1.UnitsInStock == game2.UnitsInStock && game1.Price == game2.Price && game1.NorthwindId == game2.NorthwindId && game1.IsReadonly == game2.IsReadonly && genresEquals && publisherEquals && platformTypesEquals && localizationsEquals; return(result); }
public bool IsCurrentLocalization(GameLocalization localiztion) { return(CurrentGameLocalization == localiztion); }