private void UpdateRecruitButtonState() { bool flag = GarrisonStatus.WarResources() >= this.m_shipmentCost; this.m_itemResourceCostText.color = ((!flag) ? Color.red : Color.white); bool flag2 = true; if (this.m_charShipmentRec != null && !PersistentShipmentData.CanOrderShipmentType(this.m_charShipmentRec.ID)) { flag2 = false; } TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); if (componentsInChildren.Length < 6) { this.m_troopSlotsRootObject.GetComponent <GridLayoutGroup>().constraintCount = 2; } else { this.m_troopSlotsRootObject.GetComponent <GridLayoutGroup>().constraintCount = 3; } bool flag3 = false; foreach (TroopSlot troopSlot in componentsInChildren) { if (troopSlot.IsEmpty()) { flag3 = true; break; } } this.m_recruitButtonText.color = new Color(1f, 0.82f, 0f, 1f); if (!flag3) { this.m_recruitButtonText.text = StaticDB.GetString("SLOTS_FULL", null); this.m_recruitButtonText.color = new Color(0.5f, 0.5f, 0.5f, 1f); } else if (!flag) { this.m_recruitButtonText.text = StaticDB.GetString("CANT_AFFORD", "Can't Afford"); this.m_recruitButtonText.color = new Color(0.5f, 0.5f, 0.5f, 1f); } else if (this.m_isTroop) { this.m_recruitButtonText.text = StaticDB.GetString("RECRUIT", null); } else { this.m_recruitButtonText.text = StaticDB.GetString("PLACE_ORDER", null); } if (flag3 && flag && flag2) { this.m_recruitTroopsButton.interactable = true; } else { this.m_recruitTroopsButton.interactable = false; this.m_recruitButtonText.color = new Color(0.5f, 0.5f, 0.5f, 1f); } }
private void ShipmentTypesHandler(LegionCompanionWrapper.ShipmentTypesResultEvent eventArgs) { PersistentShipmentData.SetAvailableShipmentTypes(eventArgs.Shipments); if (this.ShipmentTypesUpdatedAction != null) { this.ShipmentTypesUpdatedAction(); } }
private void ShipmentsUpdateHandler(LegionCompanionWrapper.ShipmentsUpdateEvent eventArgs) { PersistentShipmentData.ClearData(); foreach (WrapperCharacterShipment shipment in eventArgs.Shipments) { PersistentShipmentData.AddOrUpdateShipment(shipment); if (this.ShipmentAddedAction != null) { this.ShipmentAddedAction(shipment.ShipmentRecID, shipment.ShipmentID); } } }
public static int GetNumReadyShipments() { int num = 0; foreach (WrapperCharacterShipment wrapperCharacterShipment in PersistentShipmentData.shipmentDictionary.Values) { if (PersistentShipmentData.ShipmentTypeForShipmentIsAvailable(wrapperCharacterShipment.ShipmentRecID)) { TimeSpan t = GarrisonStatus.CurrentTime() - wrapperCharacterShipment.CreationTime; if ((wrapperCharacterShipment.ShipmentDuration - t).TotalSeconds <= 0.0) { num++; } } } return(num); }
public void MobileLoggedIn() { PersistentArmamentData.ClearData(); PersistentBountyData.ClearData(); PersistentEquipmentData.ClearData(); PersistentFollowerData.ClearData(); PersistentFollowerData.ClearPreMissionFollowerData(); PersistentMissionData.ClearData(); PersistentShipmentData.ClearData(); PersistentTalentData.ClearData(); MissionDataCache.ClearData(); WorldQuestData.ClearData(); ItemStatCache.instance.ClearItemStats(); GarrisonStatus.Initialized = false; MobileClient.SetCommunityID(Singleton <CharacterData> .Instance.CommunityID); MobileClient.Initialize(); Singleton <GarrisonWrapper> .Instance.MobileRequestData(); }
private void UpdateItemSlots() { if (this.m_isArtifactResearch && this.m_akResearchDisabled) { TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy(componentsInChildren[i].gameObject); } return; } bool flag = true; if (this.m_charShipmentRec != null && !PersistentShipmentData.CanPickupShipmentType(this.m_charShipmentRec.ID)) { flag = false; } int num = 0; foreach (WrapperCharacterShipment wrapperCharacterShipment in PersistentShipmentData.shipmentDictionary.Values) { if (wrapperCharacterShipment.ShipmentRecID == this.m_charShipmentRec.ID) { num++; break; } } if (num > 0 && !flag) { this.m_troopSlotsCanvasGroup.alpha = 0f; this.m_troopSlotsCanvasGroup.interactable = false; this.m_troopSlotsCanvasGroup.blocksRaycasts = false; } else { this.m_troopSlotsCanvasGroup.alpha = 1f; this.m_troopSlotsCanvasGroup.interactable = true; this.m_troopSlotsCanvasGroup.blocksRaycasts = true; } int maxShipments = (int)this.m_charShipmentRec.MaxShipments; TroopSlot[] componentsInChildren2 = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); if (componentsInChildren2.Length < maxShipments) { for (int j = componentsInChildren2.Length; j < maxShipments; j++) { GameObject gameObject = Object.Instantiate <GameObject>(this.m_troopSlotPrefab); gameObject.transform.SetParent(this.m_troopSlotsRootObject.transform, false); TroopSlot component = gameObject.GetComponent <TroopSlot>(); component.SetCharShipment(this.m_charShipmentRec.ID, 0UL, 0, false, 0); } } if (componentsInChildren2.Length > maxShipments) { for (int k = maxShipments; k < componentsInChildren2.Length; k++) { Object.Destroy(componentsInChildren2[k].gameObject); } } componentsInChildren2 = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); foreach (TroopSlot troopSlot in componentsInChildren2) { if (troopSlot.GetDBID() != 0UL && !PersistentShipmentData.shipmentDictionary.ContainsKey(troopSlot.GetDBID())) { troopSlot.SetCharShipment(this.m_charShipmentRec.ID, 0UL, 0, false, 0); } } foreach (WrapperCharacterShipment wrapperCharacterShipment2 in PersistentShipmentData.shipmentDictionary.Values) { if (wrapperCharacterShipment2.ShipmentRecID == this.m_charShipmentRec.ID) { this.SetTroopSlotForPendingShipment(componentsInChildren2, wrapperCharacterShipment2.ShipmentID); } } }
private void InitList() { List <WrapperShipmentType> availableShipmentTypes = PersistentShipmentData.GetAvailableShipmentTypes(); if (availableShipmentTypes == null || availableShipmentTypes.Count == 0) { this.m_noRecruitsYetMessage.gameObject.SetActive(true); } else { this.m_noRecruitsYetMessage.gameObject.SetActive(false); } TroopsListItem[] componentsInChildren = this.m_troopsListContents.GetComponentsInChildren <TroopsListItem>(true); TroopsListItem[] troopsListItemArray = componentsInChildren; for (int i = 0; i < (int)troopsListItemArray.Length; i++) { TroopsListItem troopsListItem = troopsListItemArray[i]; bool flag = true; if (availableShipmentTypes != null) { foreach (WrapperShipmentType availableShipmentType in availableShipmentTypes) { if (troopsListItem.GetCharShipmentTypeID() != availableShipmentType.CharShipmentID) { continue; } flag = false; break; } } if (flag) { UnityEngine.Object.Destroy(troopsListItem.gameObject); } } if (availableShipmentTypes == null) { return; } componentsInChildren = this.m_troopsListContents.GetComponentsInChildren <TroopsListItem>(true); for (int j = 0; j < availableShipmentTypes.Count; j++) { bool flag1 = false; TroopsListItem[] troopsListItemArray1 = componentsInChildren; int num = 0; while (num < (int)troopsListItemArray1.Length) { if (troopsListItemArray1[num].GetCharShipmentTypeID() != availableShipmentTypes[j].CharShipmentID) { num++; } else { flag1 = true; break; } } if (!flag1) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_troopsListItemPrefab); gameObject.transform.SetParent(this.m_troopsListContents.transform, false); TroopsListItem component = gameObject.GetComponent <TroopsListItem>(); component.SetCharShipment(new WrapperShipmentType?(availableShipmentTypes[j]), false, null); FancyEntrance mListItemInitialEntranceDelay = component.GetComponent <FancyEntrance>(); mListItemInitialEntranceDelay.m_timeToDelayEntrance = this.m_listItemInitialEntranceDelay + this.m_listItemEntranceDelay * (float)j; mListItemInitialEntranceDelay.Activate(); } } foreach (WrapperCharacterShipment value in PersistentShipmentData.shipmentDictionary.Values) { if (!PersistentShipmentData.ShipmentTypeForShipmentIsAvailable(value.ShipmentRecID)) { bool flag2 = true; bool flag3 = false; if (value.ShipmentRecID < 372 || value.ShipmentRecID > 383) { flag2 = false; } if (value.ShipmentRecID == 178 || value.ShipmentRecID == 179 || value.ShipmentRecID == 180 || value.ShipmentRecID == 192 || value.ShipmentRecID == 194 || value.ShipmentRecID == 195) { flag3 = true; } if (flag2 || flag3) { CharShipmentRec record = StaticDB.charShipmentDB.GetRecord(value.ShipmentRecID); if (record != null) { GameObject gameObject1 = UnityEngine.Object.Instantiate <GameObject>(this.m_troopsListItemPrefab); gameObject1.transform.SetParent(this.m_troopsListContents.transform, false); gameObject1.GetComponent <TroopsListItem>().SetCharShipment(null, true, record); } } } } }
private void Update() { switch (this.m_navButtonType) { case OrderHallNavButton.NavButtonType.missions: { int numCompletedMissions = PersistentMissionData.GetNumCompletedMissions(true); if (numCompletedMissions == 0 && this.m_notificationBadgeRoot.activeSelf) { this.m_notificationBadgeRoot.SetActive(false); } else if (numCompletedMissions > 0) { if (!this.m_notificationBadgeRoot.activeSelf) { this.m_notificationBadgeRoot.SetActive(true); } if (this.m_notificationPulseHandle == null) { this.m_notificationPulseHandle = UiAnimMgr.instance.PlayAnim("MinimapLoopPulseAnim", this.m_notificationBadgeRoot.transform, Vector3.zero, 1f, 0f); } else { this.RealignNotificationPulse(); } this.m_notificationBadgeText.text = string.Empty + numCompletedMissions; } break; } case OrderHallNavButton.NavButtonType.recruit: { int numReadyShipments = PersistentShipmentData.GetNumReadyShipments(); if (numReadyShipments == 0 && this.m_notificationBadgeRoot.activeSelf) { this.m_notificationBadgeRoot.SetActive(false); } else if (numReadyShipments > 0) { if (!this.m_notificationBadgeRoot.activeSelf) { this.m_notificationBadgeRoot.SetActive(true); } if (this.m_notificationPulseHandle == null) { this.m_notificationPulseHandle = UiAnimMgr.instance.PlayAnim("MinimapLoopPulseAnim", this.m_notificationBadgeRoot.transform, Vector3.zero, 1f, 0f); } else { this.RealignNotificationPulse(); } this.m_notificationBadgeText.text = string.Empty + numReadyShipments; } break; } case OrderHallNavButton.NavButtonType.talents: { bool flag = this.m_gamePanel.m_talentTreePanel.TalentIsReadyToPlayGreenCheckAnim(); if (!flag && this.m_notificationBadgeRoot.activeSelf) { this.m_notificationBadgeRoot.SetActive(false); } else if (flag && !this.m_notificationBadgeRoot.activeSelf) { this.m_notificationBadgeRoot.SetActive(true); this.m_notificationBadgeText.text = "1"; if (this.m_notificationPulseHandle == null) { this.m_notificationPulseHandle = UiAnimMgr.instance.PlayAnim("MinimapLoopPulseAnim", this.m_notificationBadgeRoot.transform, Vector3.zero, 1f, 0f); } else { this.RealignNotificationPulse(); } } break; } } }
private void UpdateItemSlots() { if (this.m_isArtifactResearch && this.m_akResearchDisabled) { TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); for (int i = 0; i < (int)componentsInChildren.Length; i++) { UnityEngine.Object.Destroy(componentsInChildren[i].gameObject); } return; } bool flag = true; if (this.m_charShipmentRec != null && !PersistentShipmentData.CanPickupShipmentType(this.m_charShipmentRec.ID)) { flag = false; } int num = 0; foreach (WrapperCharacterShipment value in PersistentShipmentData.shipmentDictionary.Values) { if (value.ShipmentRecID != this.m_charShipmentRec.ID) { continue; } num++; break; } if (num <= 0 || flag) { this.m_troopSlotsCanvasGroup.alpha = 1f; this.m_troopSlotsCanvasGroup.interactable = true; this.m_troopSlotsCanvasGroup.blocksRaycasts = true; } else { this.m_troopSlotsCanvasGroup.alpha = 0f; this.m_troopSlotsCanvasGroup.interactable = false; this.m_troopSlotsCanvasGroup.blocksRaycasts = false; } int maxShipments = (int)this.m_charShipmentRec.MaxShipments; TroopSlot[] troopSlotArray = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); if ((int)troopSlotArray.Length < maxShipments) { for (int j = (int)troopSlotArray.Length; j < maxShipments; j++) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_troopSlotPrefab); gameObject.transform.SetParent(this.m_troopSlotsRootObject.transform, false); TroopSlot component = gameObject.GetComponent <TroopSlot>(); component.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, 0, false, 0); } } if ((int)troopSlotArray.Length > maxShipments) { for (int k = maxShipments; k < (int)troopSlotArray.Length; k++) { UnityEngine.Object.Destroy(troopSlotArray[k].gameObject); } } troopSlotArray = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); TroopSlot[] troopSlotArray1 = troopSlotArray; for (int l = 0; l < (int)troopSlotArray1.Length; l++) { TroopSlot troopSlot = troopSlotArray1[l]; if (troopSlot.GetDBID() != (long)0 && !PersistentShipmentData.shipmentDictionary.ContainsKey(troopSlot.GetDBID())) { troopSlot.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, 0, false, 0); } } foreach (WrapperCharacterShipment wrapperCharacterShipment in PersistentShipmentData.shipmentDictionary.Values) { if (wrapperCharacterShipment.ShipmentRecID != this.m_charShipmentRec.ID) { continue; } this.SetTroopSlotForPendingShipment(troopSlotArray, wrapperCharacterShipment.ShipmentID); } }
private void InitList() { List <WrapperShipmentType> availableShipmentTypes = PersistentShipmentData.GetAvailableShipmentTypes(); if (availableShipmentTypes == null || availableShipmentTypes.Count == 0) { this.m_noRecruitsYetMessage.gameObject.SetActive(true); } else { this.m_noRecruitsYetMessage.gameObject.SetActive(false); } TroopsListItem[] componentsInChildren = this.m_troopsListContents.GetComponentsInChildren <TroopsListItem>(true); foreach (TroopsListItem troopsListItem in componentsInChildren) { bool flag = true; if (availableShipmentTypes != null) { foreach (WrapperShipmentType wrapperShipmentType in availableShipmentTypes) { if (troopsListItem.GetCharShipmentTypeID() == wrapperShipmentType.CharShipmentID) { flag = false; break; } } } if (flag) { Object.Destroy(troopsListItem.gameObject); } } if (availableShipmentTypes == null) { return; } componentsInChildren = this.m_troopsListContents.GetComponentsInChildren <TroopsListItem>(true); for (int j = 0; j < availableShipmentTypes.Count; j++) { bool flag2 = false; foreach (TroopsListItem troopsListItem2 in componentsInChildren) { if (troopsListItem2.GetCharShipmentTypeID() == availableShipmentTypes[j].CharShipmentID) { flag2 = true; break; } } if (!flag2) { GameObject gameObject = Object.Instantiate <GameObject>(this.m_troopsListItemPrefab); gameObject.transform.SetParent(this.m_troopsListContents.transform, false); TroopsListItem component = gameObject.GetComponent <TroopsListItem>(); component.SetCharShipment(new WrapperShipmentType?(availableShipmentTypes[j]), false, null); FancyEntrance component2 = component.GetComponent <FancyEntrance>(); component2.m_timeToDelayEntrance = this.m_listItemInitialEntranceDelay + this.m_listItemEntranceDelay * (float)j; component2.Activate(); } } foreach (WrapperCharacterShipment wrapperCharacterShipment in PersistentShipmentData.shipmentDictionary.Values) { if (!PersistentShipmentData.ShipmentTypeForShipmentIsAvailable(wrapperCharacterShipment.ShipmentRecID)) { bool flag3 = true; bool flag4 = false; if (wrapperCharacterShipment.ShipmentRecID < 372 || wrapperCharacterShipment.ShipmentRecID > 383) { flag3 = false; } if (wrapperCharacterShipment.ShipmentRecID == 178 || wrapperCharacterShipment.ShipmentRecID == 179 || wrapperCharacterShipment.ShipmentRecID == 180 || wrapperCharacterShipment.ShipmentRecID == 192 || wrapperCharacterShipment.ShipmentRecID == 194 || wrapperCharacterShipment.ShipmentRecID == 195) { flag4 = true; } if (flag3 || flag4) { CharShipmentRec record = StaticDB.charShipmentDB.GetRecord(wrapperCharacterShipment.ShipmentRecID); if (record != null) { GameObject gameObject2 = Object.Instantiate <GameObject>(this.m_troopsListItemPrefab); gameObject2.transform.SetParent(this.m_troopsListContents.transform, false); TroopsListItem component3 = gameObject2.GetComponent <TroopsListItem>(); component3.SetCharShipment(null, true, record); } } } } }