private void SetTroopSlotForPendingShipment(TroopSlot[] troopSlots, ulong shipmentDBID)
 {
     TroopSlot[] troopSlotArray = troopSlots;
     for (int i = 0; i < (int)troopSlotArray.Length; i++)
     {
         if (troopSlotArray[i].GetDBID() == shipmentDBID)
         {
             return;
         }
     }
     TroopSlot[] troopSlotArray1 = troopSlots;
     for (int j = 0; j < (int)troopSlotArray1.Length; j++)
     {
         TroopSlot troopSlot = troopSlotArray1[j];
         if (troopSlot.IsPendingCreate())
         {
             troopSlot.SetCharShipment(this.m_charShipmentRec.ID, shipmentDBID, 0, true, 0);
             return;
         }
     }
     TroopSlot[] troopSlotArray2 = troopSlots;
     for (int k = 0; k < (int)troopSlotArray2.Length; k++)
     {
         TroopSlot troopSlot1 = troopSlotArray2[k];
         if (troopSlot1.IsEmpty())
         {
             troopSlot1.SetCharShipment(this.m_charShipmentRec.ID, shipmentDBID, 0, true, 0);
             return;
         }
     }
 }
 public void Recruit()
 {
     if (this.m_charShipmentRec.GarrFollowerID > 0)
     {
         TroopSlot   troopSlot            = null;
         TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
         int         num = 0;
         while (num < (int)componentsInChildren.Length)
         {
             TroopSlot troopSlot1 = componentsInChildren[num];
             if (!troopSlot1.IsEmpty())
             {
                 num++;
             }
             else
             {
                 troopSlot = troopSlot1;
                 break;
             }
         }
         if (troopSlot == null)
         {
             return;
         }
         troopSlot.SetPendingCreate();
         this.UpdateRecruitButtonState();
     }
     LegionCompanionWrapper.CreateShipment(this.m_charShipmentRec.ID, 1);
     Main.instance.m_UISound.Play_RecruitTroop();
 }
        public void SetCharShipment(WrapperShipmentType?shipmentType, bool isSealOfFateHack = false, CharShipmentRec sealOfFateHackCharShipmentRec = null)
        {
            this.m_akHintText.gameObject.SetActive(false);
            if (!isSealOfFateHack)
            {
                this.m_shipmentCost = shipmentType.Value.CurrencyCost;
            }
            else
            {
                this.m_shipmentCost = 0;
            }
            Transform[] componentsInChildren = this.m_troopHeartContainer.GetComponentsInChildren <Transform>(true);
            for (int i = 0; i < (int)componentsInChildren.Length; i++)
            {
                Transform transforms = componentsInChildren[i];
                if (transforms != this.m_troopHeartContainer.transform)
                {
                    transforms.transform.SetParent(null);
                    UnityEngine.Object.Destroy(transforms.gameObject);
                }
            }
            AbilityDisplay[] abilityDisplayArray = this.m_traitsAndAbilitiesRootObject.GetComponentsInChildren <AbilityDisplay>(true);
            for (int j = 0; j < (int)abilityDisplayArray.Length; j++)
            {
                AbilityDisplay abilityDisplay = abilityDisplayArray[j];
                abilityDisplay.transform.SetParent(null);
                UnityEngine.Object.Destroy(abilityDisplay.gameObject);
            }
            TroopSlot[] troopSlotArray = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
            for (int k = 0; k < (int)troopSlotArray.Length; k++)
            {
                TroopSlot troopSlot = troopSlotArray[k];
                troopSlot.transform.SetParent(null);
                UnityEngine.Object.Destroy(troopSlot.gameObject);
            }
            CharShipmentRec charShipmentRec = (!isSealOfFateHack ? StaticDB.charShipmentDB.GetRecord(shipmentType.Value.CharShipmentID) : sealOfFateHackCharShipmentRec);

            if (charShipmentRec == null)
            {
                WrapperShipmentType value = shipmentType.Value;
                Debug.LogError(string.Concat("Invalid Shipment ID: ", value.CharShipmentID));
                Text mTroopName = this.m_troopName;
                WrapperShipmentType wrapperShipmentType = shipmentType.Value;
                mTroopName.text = string.Concat("Invalid Shipment ID: ", wrapperShipmentType.CharShipmentID);
                return;
            }
            if (charShipmentRec.GarrFollowerID > 0)
            {
                this.SetCharShipmentTroop(shipmentType.Value, charShipmentRec);
            }
            else if (charShipmentRec.DummyItemID > 0)
            {
                this.SetCharShipmentItem(shipmentType.Value, (!isSealOfFateHack ? charShipmentRec : sealOfFateHackCharShipmentRec), isSealOfFateHack);
            }
        }
 private void SetTroopSlotForExistingFollower(TroopSlot[] troopSlots, WrapperGarrisonFollower follower)
 {
     if (follower.Durability <= 0)
     {
         return;
     }
     TroopSlot[] troopSlotArray = troopSlots;
     for (int i = 0; i < (int)troopSlotArray.Length; i++)
     {
         int ownedFollowerID = troopSlotArray[i].GetOwnedFollowerID();
         if (ownedFollowerID != 0 && ownedFollowerID == follower.GarrFollowerID)
         {
             return;
         }
     }
     TroopSlot[] troopSlotArray1 = troopSlots;
     for (int j = 0; j < (int)troopSlotArray1.Length; j++)
     {
         TroopSlot troopSlot = troopSlotArray1[j];
         if (troopSlot.IsCollected())
         {
             GarrFollowerRec record = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
             int             num    = (GarrisonStatus.Faction() != PVP_FACTION.HORDE ? record.AllianceIconFileDataID : record.HordeIconFileDataID);
             troopSlot.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, follower.GarrFollowerID, false, num);
             return;
         }
     }
     TroopSlot[] troopSlotArray2 = troopSlots;
     for (int k = 0; k < (int)troopSlotArray2.Length; k++)
     {
         TroopSlot troopSlot1 = troopSlotArray2[k];
         if (troopSlot1.IsPendingCreate())
         {
             GarrFollowerRec garrFollowerRec = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
             int             num1            = (GarrisonStatus.Faction() != PVP_FACTION.HORDE ? garrFollowerRec.AllianceIconFileDataID : garrFollowerRec.HordeIconFileDataID);
             troopSlot1.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, follower.GarrFollowerID, false, num1);
             return;
         }
     }
     TroopSlot[] troopSlotArray3 = troopSlots;
     for (int l = 0; l < (int)troopSlotArray3.Length; l++)
     {
         TroopSlot troopSlot2 = troopSlotArray3[l];
         if (troopSlot2.IsEmpty())
         {
             GarrFollowerRec record1 = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
             int             num2    = (GarrisonStatus.Faction() != PVP_FACTION.HORDE ? record1.AllianceIconFileDataID : record1.HordeIconFileDataID);
             troopSlot2.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, follower.GarrFollowerID, false, num2);
             return;
         }
     }
 }
 private void HandleShipmentAdded(int charShipmentID, ulong shipmentDBID)
 {
     if (charShipmentID == this.m_charShipmentRec.ID)
     {
         TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
         TroopSlot[] troopSlotArray       = componentsInChildren;
         for (int i = 0; i < (int)troopSlotArray.Length; i++)
         {
             if (troopSlotArray[i].GetDBID() == shipmentDBID)
             {
                 return;
             }
         }
         TroopSlot[] troopSlotArray1 = componentsInChildren;
         for (int j = 0; j < (int)troopSlotArray1.Length; j++)
         {
             TroopSlot troopSlot = troopSlotArray1[j];
             if (troopSlot.IsPendingCreate())
             {
                 troopSlot.SetCharShipment(charShipmentID, shipmentDBID, 0, true, 0);
                 this.UpdateRecruitButtonState();
                 return;
             }
         }
         TroopSlot[] troopSlotArray2 = componentsInChildren;
         for (int k = 0; k < (int)troopSlotArray2.Length; k++)
         {
             TroopSlot troopSlot1 = troopSlotArray2[k];
             if (troopSlot1.IsEmpty())
             {
                 troopSlot1.SetCharShipment(charShipmentID, shipmentDBID, 0, true, 0);
                 this.UpdateRecruitButtonState();
                 return;
             }
         }
     }
 }
Esempio n. 6
0
 public void Recruit()
 {
     if (this.m_charShipmentRec.GarrFollowerID > 0)
     {
         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();
     }
     LegionCompanionWrapper.CreateShipment(this.m_charShipmentRec.ID, 1);
     Main.instance.m_UISound.Play_RecruitTroop();
 }
Esempio n. 7
0
        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.Destroy(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 = (uint)((GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID);

            foreach (WrapperGarrisonFollower follower in PersistentFollowerData.followerDictionary.Values)
            {
                GarrFollowerRec record = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
                uint            num2   = (uint)((GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record.AllianceGarrClassSpecID : record.HordeGarrClassSpecID);
                if (num2 == num && follower.Durability > 0)
                {
                    this.SetTroopSlotForExistingFollower(componentsInChildren, follower);
                }
            }
            CharShipmentRec record2 = StaticDB.charShipmentDB.GetRecord(this.m_charShipmentRec.ID);

            foreach (WrapperCharacterShipment wrapperCharacterShipment in PersistentShipmentData.shipmentDictionary.Values)
            {
                if (wrapperCharacterShipment.ShipmentRecID == this.m_charShipmentRec.ID)
                {
                    this.SetTroopSlotForPendingShipment(componentsInChildren, wrapperCharacterShipment.ShipmentID);
                }
                else
                {
                    CharShipmentRec record3 = StaticDB.charShipmentDB.GetRecord(wrapperCharacterShipment.ShipmentRecID);
                    if (record3.ContainerID == record2.ContainerID)
                    {
                        this.SetTroopSlotForPendingShipment(componentsInChildren, wrapperCharacterShipment.ShipmentID);
                    }
                }
            }
        }
Esempio n. 8
0
        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 UpdateTroopSlots()
        {
            if (this.m_followerRec == null || this.m_charShipmentRec == null)
            {
                return;
            }
            int maxTroops = this.GetMaxTroops((GarrisonStatus.Faction() != PVP_FACTION.HORDE ? (int)this.m_followerRec.AllianceGarrClassSpecID : (int)this.m_followerRec.HordeGarrClassSpecID));

            TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
            if ((int)componentsInChildren.Length < maxTroops)
            {
                for (int i = (int)componentsInChildren.Length; i < maxTroops; i++)
                {
                    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)componentsInChildren.Length > maxTroops)
            {
                for (int j = maxTroops; j < (int)componentsInChildren.Length; j++)
                {
                    UnityEngine.Object.Destroy(componentsInChildren[j].gameObject);
                }
            }
            componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
            TroopSlot[] troopSlotArray = componentsInChildren;
            for (int k = 0; k < (int)troopSlotArray.Length; k++)
            {
                TroopSlot troopSlot       = troopSlotArray[k];
                int       ownedFollowerID = troopSlot.GetOwnedFollowerID();
                if (ownedFollowerID != 0 && (!PersistentFollowerData.followerDictionary.ContainsKey(ownedFollowerID) || PersistentFollowerData.followerDictionary[ownedFollowerID].Durability == 0))
                {
                    troopSlot.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, 0, false, 0);
                }
            }
            uint num = (GarrisonStatus.Faction() != PVP_FACTION.HORDE ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID);

            foreach (WrapperGarrisonFollower value in PersistentFollowerData.followerDictionary.Values)
            {
                GarrFollowerRec record = StaticDB.garrFollowerDB.GetRecord(value.GarrFollowerID);
                if ((GarrisonStatus.Faction() != PVP_FACTION.HORDE ? record.AllianceGarrClassSpecID : record.HordeGarrClassSpecID) != num || value.Durability <= 0)
                {
                    continue;
                }
                this.SetTroopSlotForExistingFollower(componentsInChildren, value);
            }
            CharShipmentRec charShipmentRec = StaticDB.charShipmentDB.GetRecord(this.m_charShipmentRec.ID);

            foreach (WrapperCharacterShipment wrapperCharacterShipment in PersistentShipmentData.shipmentDictionary.Values)
            {
                if (wrapperCharacterShipment.ShipmentRecID != this.m_charShipmentRec.ID)
                {
                    if (StaticDB.charShipmentDB.GetRecord(wrapperCharacterShipment.ShipmentRecID).ContainerID != charShipmentRec.ContainerID)
                    {
                        continue;
                    }
                    this.SetTroopSlotForPendingShipment(componentsInChildren, wrapperCharacterShipment.ShipmentID);
                }
                else
                {
                    this.SetTroopSlotForPendingShipment(componentsInChildren, wrapperCharacterShipment.ShipmentID);
                }
            }
        }
        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);
            }
        }