Beispiel #1
0
    public void UpdateData(ICharacterData character)
    {
        this.character = character;
        var slots = CacheEquipItemSlots.Values;

        // Clear slots data
        foreach (var slot in slots)
        {
            slot.Setup(GetEmptyUIData(), this.character, -1, string.Empty);
            slot.Show();
        }

        if (character == null)
        {
            return;
        }

        string          tempPosition;
        UICharacterItem tempSlot;
        var             equipItems = character.EquipItems;

        for (var i = 0; i < equipItems.Count; ++i)
        {
            var equipItem = equipItems[i];
            var armorItem = equipItem.GetArmorItem();
            if (armorItem == null)
            {
                continue;
            }

            tempPosition = armorItem.EquipPosition;
            if (CacheEquipItemSlots.TryGetValue(tempPosition, out tempSlot))
            {
                tempSlot.Setup(new CharacterItemLevelTuple(equipItem, equipItem.level), this.character, -1, tempPosition);
            }
        }

        var equipWeapons       = character.EquipWeapons;
        var rightHand          = equipWeapons.rightHand;
        var leftHand           = equipWeapons.leftHand;
        var rightHandEquipment = rightHand.GetEquipmentItem();
        var leftHandEquipment  = leftHand.GetEquipmentItem();

        tempPosition = GameDataConst.EQUIP_POSITION_RIGHT_HAND;
        if (CacheEquipItemSlots.TryGetValue(tempPosition, out tempSlot))
        {
            if (rightHandEquipment != null)
            {
                tempSlot.Setup(new CharacterItemLevelTuple(rightHand, rightHand.level), this.character, -1, tempPosition);
            }
        }
        tempPosition = GameDataConst.EQUIP_POSITION_LEFT_HAND;
        if (CacheEquipItemSlots.TryGetValue(tempPosition, out tempSlot))
        {
            if (leftHandEquipment != null)
            {
                tempSlot.Setup(new CharacterItemLevelTuple(leftHand, leftHand.level), this.character, -1, tempPosition);
            }
        }
    }
        public void UpdateData(ICharacterData character)
        {
            this.character = character;
            // Clear slots data
            foreach (UICharacterItem slot in CacheEquipItemSlots.Values)
            {
                slot.Setup(GetEmptyUIData(slot.InventoryType), character, -1);
                slot.Show();
            }

            if (character == null)
            {
                return;
            }

            string                tempPosition;
            UICharacterItem       tempSlot;
            IList <CharacterItem> equipItems = character.EquipItems;

            for (int i = 0; i < equipItems.Count; ++i)
            {
                CharacterItem equipItem = equipItems[i];
                Item          armorItem = equipItem.GetArmorItem();
                if (armorItem == null)
                {
                    continue;
                }

                tempPosition = armorItem.EquipPosition;
                if (CacheEquipItemSlots.TryGetValue(tempPosition, out tempSlot))
                {
                    tempSlot.Setup(new CharacterItemTuple(equipItem, equipItem.level, InventoryType.EquipItems), character, i);
                }
            }

            EquipWeapons  equipWeapons       = character.EquipWeapons;
            CharacterItem rightHand          = equipWeapons.rightHand;
            CharacterItem leftHand           = equipWeapons.leftHand;
            Item          rightHandEquipment = rightHand.GetEquipmentItem();
            Item          leftHandEquipment  = leftHand.GetEquipmentItem();

            tempPosition = GameDataConst.EQUIP_POSITION_RIGHT_HAND;
            if (CacheEquipItemSlots.TryGetValue(tempPosition, out tempSlot))
            {
                if (rightHandEquipment != null)
                {
                    tempSlot.Setup(new CharacterItemTuple(rightHand, rightHand.level, InventoryType.EquipWeaponRight), character, 0);
                }
            }
            tempPosition = GameDataConst.EQUIP_POSITION_LEFT_HAND;
            if (CacheEquipItemSlots.TryGetValue(tempPosition, out tempSlot))
            {
                if (leftHandEquipment != null)
                {
                    tempSlot.Setup(new CharacterItemTuple(leftHand, leftHand.level, InventoryType.EquipWeaponLeft), character, 0);
                }
            }
        }