public bool StartHiring() { if (finding) { return(true); } else { if (Crew.crewsList.Count < GetCrewsSlotsCount()) { if (colony.energyCrystalsCount >= hireCost) { colony.GetEnergyCrystals(hireCost); finding = true; return(true); } else { GameLogUI.NotEnoughMoneyAnnounce(); return(false); } } else { GameLogUI.MakeImportantAnnounce(Localization.GetRefusalReason(RefusalReason.NotEnoughSlots)); if (GameMaster.soundEnabled) { GameMaster.audiomaster.Notify(NotificationSound.NotEnoughSlots); } return(false); } } }
public static Crew CreateNewCrew(ColonyController home, int membersCount) { if (crewsList.Count >= RecruitingCenter.GetCrewsSlotsCount()) { return(null); } if (crewsList.Count > MAX_CREWS_COUNT) { GameLogUI.MakeImportantAnnounce(Localization.GetAnnouncementString(GameAnnouncements.CrewsLimitReached)); GameMaster.LoadingFail(); return(null); } Crew c = new GameObject(Localization.NameCrew()).AddComponent <Crew>(); if (crewsContainer == null) { crewsContainer = new GameObject("crewsContainer"); } c.transform.parent = crewsContainer.transform; c.ID = nextID; nextID++; c.atHome = true; //normal parameters c.membersCount = (byte)membersCount; //attributes c.SetAttributes(home); // crewsList.Add(c); listChangesMarkerValue++; return(c); }
public void StartEndQuest(byte routeIndex) { int endIndex = (int)QuestType.Endgame; if (activeQuests[endIndex] != Quest.NoQuest) { activeQuests[endIndex] = new Quest(QuestType.Endgame, routeIndex); questAccessMap[endIndex] = true; } else { GameLogUI.MakeImportantAnnounce(Localization.GetAnnouncementString(GameAnnouncements.AlreadyHaveEndquest)); } }
public void AddArtifact(Artifact a, int slotIndex) { if (a != null && !a.destructed) { if (!a.researched) { GameMaster.audiomaster.Notify(NotificationSound.Disagree); GameLogUI.MakeImportantAnnounce(Localization.GetPhrase(LocalizedPhrase.ArtifactNotResearched)); return; } else { if (affectionPath != Path.TechPath) { GameMaster.audiomaster.Notify(NotificationSound.Disagree); GameLogUI.MakeImportantAnnounce(Localization.GetPhrase(LocalizedPhrase.AffectionTypeNotMatch)); return; } else { if (artifacts == null) { artifacts = new Artifact[4]; } else { if (artifacts[slotIndex] != null) { artifacts[slotIndex].ChangeStatus(Artifact.ArtifactStatus.OnConservation); } } artifacts[slotIndex] = a; a.ChangeStatus(Artifact.ArtifactStatus.UsingInMonument); RecalculateAffection(); } } } }
public void PrepareList() { if (observingMonument == null) { SelfShutOff(); return; } else { if (selectedSlotIndex == -1) { listHolder.SetActive(false); return; } if (Artifact.artifactsList.Count == 0) { GameLogUI.MakeImportantAnnounce(Localization.GetPhrase(LocalizedPhrase.NoArtifacts)); return; } var arts = new List <Artifact>(); ids = new List <int>() { -1 }; var selectedArtifact = observingMonument.artifacts[selectedSlotIndex]; bool slotWithArtifact = selectedArtifact != null; foreach (var a in Artifact.artifactsList) { if (a.researched) { if (a.affectionPath != Path.NoPath & (observingMonument.affectionPath == Path.NoPath | (a.affectionPath == observingMonument.affectionPath)) ) { if (a.status == Artifact.ArtifactStatus.OnConservation | (slotWithArtifact && selectedArtifact.ID == a.ID)) { arts.Add(a); ids.Add(a.ID); } } } } int artsCount = arts.Count; if (artsCount > 0) { // подготовка списка int newSelectedItem = -1; if (artsCount + 1 > items.Length) { // артефакты не помещаются в одну страницу if (!scrollbar.gameObject.activeSelf) { scrollbar.value = 0; scrollbar.gameObject.SetActive(true); } float rsize = items.Length; rsize /= artsCount; if (scrollbar.size != rsize) { scrollbar.size = rsize; } //#preparePositionedList int sindex = GetListStartIndex(); int i = 0; if (sindex == 0) { items[0].transform.GetChild(0).GetComponent <Text>().text = slotWithArtifact ? Localization.GetPhrase(LocalizedPhrase.ClearSlot) : '<' + Localization.GetPhrase(LocalizedPhrase.NoArtifact) + '>'; i = 1; } for (; i < items.Length; i++) { items[i].transform.GetChild(0).GetComponent <Text>().text = '"' + arts[i + sindex - 1].name + '"'; items[i].SetActive(true); } if (selectedArtifact != null) { for (int j = 0; j < items.Length; j++) { if (ids[j + sindex] == selectedArtifact.ID) { newSelectedItem = j; break; } } } else { if (sindex != 0) { newSelectedItem = -1; } else { newSelectedItem = 0; } } // } else { // артефактов меньше, чем позиций списка items[0].transform.GetChild(0).GetComponent <Text>().text = slotWithArtifact ? Localization.GetPhrase(LocalizedPhrase.ClearSlot) : '<' + Localization.GetPhrase(LocalizedPhrase.NoArtifact) + '>'; if (scrollbar.gameObject.activeSelf) { scrollbar.gameObject.SetActive(false); } int i = 0; for (; i < arts.Count; i++) { items[i + 1].transform.GetChild(0).GetComponent <Text>().text = '"' + arts[i].name + '"'; items[i + 1].SetActive(true); } i++; if (i < items.Length) { for (; i < items.Length; i++) { items[i].SetActive(false); } } if (selectedArtifact != null) { for (int j = 1; j < items.Length; j++) { if (ids[j] == selectedArtifact.ID) { newSelectedItem = j; break; } } } else { newSelectedItem = 0; } } if (newSelectedItem != listSelectedItem) { if (listSelectedItem != -1) { items[listSelectedItem].GetComponent <Image>().overrideSprite = null; } if (newSelectedItem != -1) { items[newSelectedItem].GetComponent <Image>().overrideSprite = PoolMaster.gui_overridingSprite; } listSelectedItem = newSelectedItem; } if (!listHolder.activeSelf) { listHolder.SetActive(true); } } else { if (listHolder.activeSelf) { if (ids != null) { ids.Clear(); } listHolder.SetActive(false); } GameLogUI.MakeImportantAnnounce(Localization.GetPhrase(LocalizedPhrase.NoSuitableArtifacts)); return; } } }
public bool LoadGame(string fullname) { bool debug_noresource = weNeedNoResources; FileStream fs = File.Open(fullname, FileMode.Open); double realHashSum = GetHashSum(fs, true); var data = new byte[8]; fs.Read(data, 0, 8); double readedHashSum = System.BitConverter.ToDouble(data, 0); string errorReason = "reason not stated"; if (realHashSum == readedHashSum) { fs.Position = 0; SetPause(true); loading = true; // ОЧИСТКА StopAllCoroutines(); if (Zeppelin.current != null) { Destroy(Zeppelin.current); } if (mainChunk != null) { mainChunk.ClearChunk(); } // очистка подписчиков на ивенты невозможна, сами ивенты к этому моменту недоступны Crew.Reset(); Expedition.GameReset(); Structure.ResetToDefaults_Static(); // все наследуемые resetToDefaults внутри if (colonyController != null) { colonyController.ResetToDefaults(); // подчищает все списки } else { colonyController = gameObject.AddComponent <ColonyController>(); colonyController.Prepare(); } //UI.current.Reset(); // НАЧАЛО ЗАГРУЗКИ if (gameStarted) { SetDefaultValues(); } #region gms mainPartLoading data = new byte[4]; fs.Read(data, 0, 4); uint saveSystemVersion = System.BitConverter.ToUInt32(data, 0); // может пригодиться в дальнейшем //start writing data = new byte[65]; fs.Read(data, 0, data.Length); gameSpeed = System.BitConverter.ToSingle(data, 0); lifeGrowCoefficient = System.BitConverter.ToSingle(data, 4); demolitionLossesPercent = System.BitConverter.ToSingle(data, 8); lifepowerLossesPercent = System.BitConverter.ToSingle(data, 12); LUCK_COEFFICIENT = System.BitConverter.ToSingle(data, 16); sellPriceCoefficient = System.BitConverter.ToSingle(data, 20); tradeVesselsTrafficCoefficient = System.BitConverter.ToSingle(data, 24); upgradeDiscount = System.BitConverter.ToSingle(data, 28); upgradeCostIncrease = System.BitConverter.ToSingle(data, 32); warProximity = System.BitConverter.ToSingle(data, 36); difficulty = (Difficulty)data[40]; startGameWith = (GameStart)data[41]; prevCutHeight = data[42]; day = data[43]; month = data[44]; year = System.BitConverter.ToUInt32(data, 45); timeGone = System.BitConverter.ToSingle(data, 49); gearsDegradeSpeed = System.BitConverter.ToSingle(data, 53); labourTimer = System.BitConverter.ToSingle(data, 57); RecruitingCenter.SetHireCost(System.BitConverter.ToSingle(data, 61)); #endregion DockSystem.LoadDockSystem(fs); globalMap.Load(fs); if (loadingFailed) { errorReason = "global map error"; goto FAIL; } environmentMaster.Load(fs); if (loadingFailed) { errorReason = "environment error"; goto FAIL; } Artifact.LoadStaticData(fs); // crews & monuments if (loadingFailed) { errorReason = "artifacts load failure"; goto FAIL; } Crew.LoadStaticData(fs); if (loadingFailed) { errorReason = "crews load failure"; goto FAIL; } if (mainChunk == null) { GameObject g = new GameObject("chunk"); mainChunk = g.AddComponent <Chunk>(); } mainChunk.LoadChunkData(fs); if (loadingFailed) { errorReason = "chunk load failure"; goto FAIL; } else { if (blockersRestoreEvent != null) { blockersRestoreEvent(); } } Settlement.TotalRecalculation(); // Totaru Annihirationu no imoto-chan if (loadingFailed) { errorReason = "settlements load failure"; goto FAIL; } colonyController.Load(fs); // < --- COLONY CONTROLLER if (loadingFailed) { errorReason = "colony controller load failure"; goto FAIL; } if (loadingFailed) { errorReason = "dock load failure"; goto FAIL; } QuestUI.current.Load(fs); if (loadingFailed) { errorReason = "quest load failure"; goto FAIL; } Expedition.LoadStaticData(fs); Knowledge.Load(fs); fs.Close(); FollowingCamera.main.WeNeedUpdate(); loading = false; savename = fullname; if (afterloadRecalculationEvent != null) { afterloadRecalculationEvent(); afterloadRecalculationEvent = null; } SetPause(false); colonyController.FORCED_PowerGridRecalculation(); return(true); } else { GameLogUI.MakeImportantAnnounce(Localization.GetAnnouncementString(GameAnnouncements.LoadingFailed) + " : hashsum incorrect"); if (soundEnabled) { audiomaster.Notify(NotificationSound.SystemError); } SetPause(true); fs.Close(); return(false); } FAIL: GameLogUI.MakeImportantAnnounce(Localization.GetAnnouncementString(GameAnnouncements.LoadingFailed) + " : data corruption"); if (soundEnabled) { audiomaster.Notify(NotificationSound.SystemError); } print(errorReason); SetPause(true); fs.Close(); if (debug_noresource) { weNeedNoResources = true; } return(false); }