public void Recruit() { if (this.m_charShipmentRec.GarrFollowerID == 0u) { TroopSlot troopSlot = null; TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); foreach (TroopSlot troopSlot2 in componentsInChildren) { if (troopSlot2.IsEmpty()) { troopSlot = troopSlot2; break; } } if (troopSlot == null) { return; } troopSlot.SetPendingCreate(); this.UpdateRecruitButtonState(); } MobilePlayerCreateShipment mobilePlayerCreateShipment = new MobilePlayerCreateShipment(); mobilePlayerCreateShipment.CharShipmentID = this.m_charShipmentRec.ID; mobilePlayerCreateShipment.NumShipments = 1; Login.instance.SendToMobileServer(mobilePlayerCreateShipment); Main.instance.m_UISound.Play_RecruitTroop(); }
private void HandleShipmentAdded(int charShipmentID, ulong shipmentDBID) { if (charShipmentID == this.m_shipmentType.CharShipmentID) { TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(); TroopSlot[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { TroopSlot troopSlot = array[i]; if (troopSlot.GetDBID() == shipmentDBID) { return; } } TroopSlot[] array2 = componentsInChildren; for (int j = 0; j < array2.Length; j++) { TroopSlot troopSlot2 = array2[j]; if (troopSlot2.IsEmpty()) { troopSlot2.SetCharShipment(charShipmentID, shipmentDBID, 0, true, 0); break; } } this.UpdateRecruitButtonState(); } }
private void UpdateItemSlots() { int maxShipments = (int)this.m_charShipmentRec.MaxShipments; TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); if (componentsInChildren.Length < maxShipments) { for (int i = componentsInChildren.Length; i < maxShipments; i++) { GameObject gameObject = Object.Instantiate <GameObject>(this.m_troopSlotPrefab); gameObject.get_transform().SetParent(this.m_troopSlotsRootObject.get_transform(), false); TroopSlot component = gameObject.GetComponent <TroopSlot>(); component.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, 0, false, 0); } } if (componentsInChildren.Length > maxShipments) { for (int j = maxShipments; j < componentsInChildren.Length; j++) { Object.DestroyImmediate(componentsInChildren[j].get_gameObject()); } } componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); TroopSlot[] array = componentsInChildren; for (int k = 0; k < array.Length; k++) { TroopSlot troopSlot = array[k]; if (troopSlot.GetDBID() != 0uL && !PersistentShipmentData.shipmentDictionary.ContainsKey(troopSlot.GetDBID())) { troopSlot.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, 0, false, 0); } } IEnumerator enumerator = PersistentShipmentData.shipmentDictionary.get_Values().GetEnumerator(); try { while (enumerator.MoveNext()) { JamCharacterShipment jamCharacterShipment = (JamCharacterShipment)enumerator.get_Current(); if (jamCharacterShipment.ShipmentRecID == this.m_shipmentType.CharShipmentID) { this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID); } } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } }
public void SetCharShipment(MobileClientShipmentType shipmentType, bool isSealOfFateHack = false, CharShipmentRec sealOfFateHackCharShipmentRec = null) { if (isSealOfFateHack) { this.m_shipmentCost = 0; } else { this.m_shipmentCost = shipmentType.CurrencyCost; } Transform[] componentsInChildren = this.m_troopHeartContainer.GetComponentsInChildren <Transform>(true); Transform[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { Transform transform = array[i]; if (transform != this.m_troopHeartContainer.get_transform()) { Object.DestroyImmediate(transform.get_gameObject()); } } AbilityDisplay[] componentsInChildren2 = this.m_traitsAndAbilitiesRootObject.GetComponentsInChildren <AbilityDisplay>(true); AbilityDisplay[] array2 = componentsInChildren2; for (int j = 0; j < array2.Length; j++) { AbilityDisplay abilityDisplay = array2[j]; Object.DestroyImmediate(abilityDisplay.get_gameObject()); } TroopSlot[] componentsInChildren3 = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); TroopSlot[] array3 = componentsInChildren3; for (int k = 0; k < array3.Length; k++) { TroopSlot troopSlot = array3[k]; Object.DestroyImmediate(troopSlot.get_gameObject()); } CharShipmentRec charShipmentRec = (!isSealOfFateHack) ? StaticDB.charShipmentDB.GetRecord(shipmentType.CharShipmentID) : sealOfFateHackCharShipmentRec; if (charShipmentRec == null) { Debug.LogError("Invalid Shipment ID: " + shipmentType.CharShipmentID); this.m_troopName.set_text("Invalid Shipment ID: " + shipmentType.CharShipmentID); return; } if (charShipmentRec.GarrFollowerID > 0u) { this.SetCharShipmentTroop(shipmentType, charShipmentRec); } else if (charShipmentRec.DummyItemID > 0) { this.SetCharShipmentItem(shipmentType, (!isSealOfFateHack) ? charShipmentRec : sealOfFateHackCharShipmentRec, isSealOfFateHack); } }
private void UpdateRecruitButtonState() { TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(); bool flag = false; TroopSlot[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { TroopSlot troopSlot = array[i]; if (troopSlot.IsEmpty()) { flag = true; break; } } bool flag2 = GarrisonStatus.Resources() >= this.m_shipmentCost; this.m_itemResourceCostText.set_color((!flag2) ? Color.get_red() : Color.get_white()); this.m_recruitButtonText.set_color(new Color(1f, 0.82f, 0f, 1f)); if (!flag) { this.m_recruitButtonText.set_text(StaticDB.GetString("SLOTS_FULL", null)); this.m_recruitButtonText.set_color(new Color(0.5f, 0.5f, 0.5f, 1f)); } else if (!flag2) { this.m_recruitButtonText.set_text(StaticDB.GetString("CANT_AFFORD", "Can't Afford")); this.m_recruitButtonText.set_color(new Color(0.5f, 0.5f, 0.5f, 1f)); } else if (this.m_isTroop) { this.m_recruitButtonText.set_text(StaticDB.GetString("RECRUIT", null)); } else { this.m_recruitButtonText.set_text(StaticDB.GetString("PLACE_ORDER", null)); } if (flag && flag2) { this.m_recruitTroopsButton.set_interactable(true); } else { this.m_recruitTroopsButton.set_interactable(false); } }
private void SetTroopSlotForPendingShipment(TroopSlot[] troopSlots, ulong shipmentDBID) { for (int i = 0; i < troopSlots.Length; i++) { TroopSlot troopSlot = troopSlots[i]; if (troopSlot.GetDBID() == shipmentDBID) { return; } } for (int j = 0; j < troopSlots.Length; j++) { TroopSlot troopSlot2 = troopSlots[j]; if (troopSlot2.IsEmpty()) { troopSlot2.SetCharShipment(this.m_shipmentType.CharShipmentID, shipmentDBID, 0, true, 0); return; } } }
private void SetTroopSlotForExistingFollower(TroopSlot[] troopSlots, JamGarrisonFollower follower) { if (follower.Durability <= 0) { return; } for (int i = 0; i < troopSlots.Length; i++) { TroopSlot troopSlot = troopSlots[i]; int ownedFollowerID = troopSlot.GetOwnedFollowerID(); if (ownedFollowerID != 0 && ownedFollowerID == follower.GarrFollowerID) { return; } } for (int j = 0; j < troopSlots.Length; j++) { TroopSlot troopSlot2 = troopSlots[j]; if (troopSlot2.IsCollected()) { GarrFollowerRec record = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID); int iconFileDataID = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record.AllianceIconFileDataID : record.HordeIconFileDataID; troopSlot2.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, follower.GarrFollowerID, false, iconFileDataID); return; } } for (int k = 0; k < troopSlots.Length; k++) { TroopSlot troopSlot3 = troopSlots[k]; if (troopSlot3.IsEmpty()) { GarrFollowerRec record2 = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID); int iconFileDataID2 = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record2.AllianceIconFileDataID : record2.HordeIconFileDataID; troopSlot3.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, follower.GarrFollowerID, false, iconFileDataID2); return; } } }
private void UpdateTroopSlots() { int maxTroops = this.GetMaxTroops((int)((GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID)); TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); if (componentsInChildren.Length < maxTroops) { for (int i = componentsInChildren.Length; i < maxTroops; i++) { GameObject gameObject = Object.Instantiate <GameObject>(this.m_troopSlotPrefab); gameObject.get_transform().SetParent(this.m_troopSlotsRootObject.get_transform(), false); TroopSlot component = gameObject.GetComponent <TroopSlot>(); component.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, 0, false, 0); } } if (componentsInChildren.Length > maxTroops) { for (int j = maxTroops; j < componentsInChildren.Length; j++) { Object.DestroyImmediate(componentsInChildren[j].get_gameObject()); } } componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); TroopSlot[] array = componentsInChildren; for (int k = 0; k < array.Length; k++) { TroopSlot troopSlot = array[k]; int ownedFollowerID = troopSlot.GetOwnedFollowerID(); if (ownedFollowerID != 0 && (!PersistentFollowerData.followerDictionary.ContainsKey(ownedFollowerID) || PersistentFollowerData.followerDictionary.get_Item(ownedFollowerID).Durability == 0)) { troopSlot.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, 0, false, 0); } } uint num = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID; using (Dictionary <int, JamGarrisonFollower> .ValueCollection.Enumerator enumerator = PersistentFollowerData.followerDictionary.get_Values().GetEnumerator()) { while (enumerator.MoveNext()) { JamGarrisonFollower current = enumerator.get_Current(); GarrFollowerRec record = StaticDB.garrFollowerDB.GetRecord(current.GarrFollowerID); uint num2 = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record.AllianceGarrClassSpecID : record.HordeGarrClassSpecID; if (num2 == num && current.Durability > 0) { this.SetTroopSlotForExistingFollower(componentsInChildren, current); } } } CharShipmentRec record2 = StaticDB.charShipmentDB.GetRecord(this.m_shipmentType.CharShipmentID); IEnumerator enumerator2 = PersistentShipmentData.shipmentDictionary.get_Values().GetEnumerator(); try { while (enumerator2.MoveNext()) { JamCharacterShipment jamCharacterShipment = (JamCharacterShipment)enumerator2.get_Current(); if (jamCharacterShipment.ShipmentRecID == this.m_shipmentType.CharShipmentID) { this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID); } else { CharShipmentRec record3 = StaticDB.charShipmentDB.GetRecord(jamCharacterShipment.ShipmentRecID); if (record3.ContainerID == record2.ContainerID) { this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID); } } } } finally { IDisposable disposable = enumerator2 as IDisposable; if (disposable != null) { disposable.Dispose(); } } }
private void UpdateTroopSlots() { if (this.m_followerRec == null || this.m_charShipmentRec == null) { return; } int maxTroops = this.GetMaxTroops((int)((GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID)); TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); if (componentsInChildren.Length < maxTroops) { for (int i = componentsInChildren.Length; i < maxTroops; i++) { 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 (componentsInChildren.Length > maxTroops) { for (int j = maxTroops; j < componentsInChildren.Length; j++) { Object.DestroyImmediate(componentsInChildren[j].gameObject); } } componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); foreach (TroopSlot troopSlot in componentsInChildren) { int ownedFollowerID = troopSlot.GetOwnedFollowerID(); if (ownedFollowerID != 0 && (!PersistentFollowerData.followerDictionary.ContainsKey(ownedFollowerID) || PersistentFollowerData.followerDictionary[ownedFollowerID].Durability == 0)) { troopSlot.SetCharShipment(this.m_charShipmentRec.ID, 0UL, 0, false, 0); } } uint num = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID; foreach (JamGarrisonFollower jamGarrisonFollower in PersistentFollowerData.followerDictionary.Values) { GarrFollowerRec record = StaticDB.garrFollowerDB.GetRecord(jamGarrisonFollower.GarrFollowerID); uint num2 = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record.AllianceGarrClassSpecID : record.HordeGarrClassSpecID; if (num2 == num && jamGarrisonFollower.Durability > 0) { this.SetTroopSlotForExistingFollower(componentsInChildren, jamGarrisonFollower); } } CharShipmentRec record2 = StaticDB.charShipmentDB.GetRecord(this.m_charShipmentRec.ID); IEnumerator enumerator2 = PersistentShipmentData.shipmentDictionary.Values.GetEnumerator(); try { while (enumerator2.MoveNext()) { object obj = enumerator2.Current; JamCharacterShipment jamCharacterShipment = (JamCharacterShipment)obj; if (jamCharacterShipment.ShipmentRecID == this.m_charShipmentRec.ID) { this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID); } else { CharShipmentRec record3 = StaticDB.charShipmentDB.GetRecord(jamCharacterShipment.ShipmentRecID); if (record3.ContainerID == record2.ContainerID) { this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID); } } } } finally { IDisposable disposable; if ((disposable = (enumerator2 as IDisposable)) != null) { disposable.Dispose(); } } }
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.DestroyImmediate(componentsInChildren[i].gameObject); } return; } bool flag = true; if (this.m_charShipmentRec != null && !PersistentShipmentData.CanPickupShipmentType(this.m_charShipmentRec.ID)) { flag = false; } int num = 0; IEnumerator enumerator = PersistentShipmentData.shipmentDictionary.Values.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; JamCharacterShipment jamCharacterShipment = (JamCharacterShipment)obj; if (jamCharacterShipment.ShipmentRecID == this.m_charShipmentRec.ID) { num++; break; } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } if ((num > 0 && !flag) || (this.m_isArtifactResearch && ArtifactKnowledgeData.s_artifactKnowledgeInfo != null && ArtifactKnowledgeData.s_artifactKnowledgeInfo.CurrentLevel >= ArtifactKnowledgeData.s_artifactKnowledgeInfo.MaxLevel)) { 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 num2 = (int)this.m_charShipmentRec.MaxShipments; if (this.m_isArtifactResearch && ArtifactKnowledgeData.s_artifactKnowledgeInfo != null) { int num3 = ArtifactKnowledgeData.s_artifactKnowledgeInfo.MaxLevel - ArtifactKnowledgeData.s_artifactKnowledgeInfo.CurrentLevel; if (num3 > 0 && num3 < num2) { num2 = num3; } } TroopSlot[] componentsInChildren2 = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true); if (componentsInChildren2.Length < num2) { for (int j = componentsInChildren2.Length; j < num2; 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 > num2) { for (int k = num2; k < componentsInChildren2.Length; k++) { Object.DestroyImmediate(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); } } IEnumerator enumerator2 = PersistentShipmentData.shipmentDictionary.Values.GetEnumerator(); try { while (enumerator2.MoveNext()) { object obj2 = enumerator2.Current; JamCharacterShipment jamCharacterShipment2 = (JamCharacterShipment)obj2; if (jamCharacterShipment2.ShipmentRecID == this.m_charShipmentRec.ID) { this.SetTroopSlotForPendingShipment(componentsInChildren2, jamCharacterShipment2.ShipmentID); } } } finally { IDisposable disposable2; if ((disposable2 = (enumerator2 as IDisposable)) != null) { disposable2.Dispose(); } } }