예제 #1
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 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);
            }
        }