Esempio n. 1
0
    public void AddItem(Item newItem, int number, bool displayRemove, SlotType slotType)
    {
        item = newItem;
        itemButton.interactable = true;
        icon.sprite             = item.sprite;
        icon.enabled            = true;
        this.slotType           = slotType;
        numbers.text            = number.ToString();

        if (newItem.itemType == ItemType.ARMOR)
        {
            ArmorPiece ap = (ArmorPiece)newItem;
            icon.color = ap.color;
            ResetRot();
        }

        if (newItem.itemType == ItemType.WEAPON)
        {
            Weapon weap = (Weapon)newItem;
            if (weap.type == WeaponType.TOME)
            {
                ResetRot();
            }
        }

        if (newItem.itemType != ItemType.ARMOR)
        {
            numbers.enabled = true;
        }
        if (displayRemove)
        {
            removeButton.interactable = true;
        }
    }
 public void UnequipArmor(ArmorPiece piece)
 {
     for (int i = 0; i < armors.Count; i++)
     {
         if (armors[i].armor.aPiece == piece)
         {
             armors[i].owner = null;
             armors.Remove(armors[i]);
             CalculateBattleStat();
             return;
         }
     }
 }
Esempio n. 3
0
    private void Start()
    {
        inventory = Inventory.instance;
        gameObject.GetComponent <SpriteRenderer>().sprite = item.sprite;

        if (item.itemType == ItemType.WEAPON)
        {
            Weapon weap = (Weapon)item;
            transform.localScale = transform.localScale * weap.sizeModifier;
        }

        if (item.itemType == ItemType.ARMOR)
        {
            ArmorPiece ap = (ArmorPiece)item;
            gameObject.GetComponent <SpriteRenderer>().color = ap.color;
        }
    }
Esempio n. 4
0
    public void switchBars(Item itemToSwitch, int number, SlotType type, bool isActiveItem)
    {
        switch (type)
        {
        case SlotType.INVENTORY:

            if (itemToSwitch.itemType == ItemType.ARMOR)
            {
                ArmorPiece armor = (ArmorPiece)itemToSwitch;
                switch (armor.armorPart)
                {
                case ArmorPart.HEAD:
                    if (headArmorSlot == null)
                    {
                        headArmorSlot = armor;
                        onHeadArmorChangedCallback.Invoke();
                        RemoveAllInInventory(itemToSwitch);
                    }
                    break;

                case ArmorPart.TORSO:
                    if (torsoArmorSlot == null)
                    {
                        torsoArmorSlot = armor;
                        onTorsoArmorChangedCallback.Invoke();
                        RemoveAllInInventory(itemToSwitch);
                    }
                    break;

                default:
                    break;
                }
                break;
            }

            if (AddToHotbar(itemToSwitch, number))
            {
                RemoveAllInInventory(itemToSwitch);
            }
            return;

        case SlotType.HOTBAR:

            if (AddToInventory(itemToSwitch, number))
            {
                RemoveAllInHotbar(itemToSwitch);
            }
            return;

        case SlotType.ARMOR_HEAD:
            if (AddToInventory(itemToSwitch, 0))
            {
                headArmorSlot = null;
                onHeadArmorChangedCallback.Invoke();
            }
            return;

        case SlotType.ARMOR_TORSO:
            if (AddToInventory(itemToSwitch, 0))
            {
                torsoArmorSlot = null;
                onTorsoArmorChangedCallback.Invoke();
            }
            return;

        default:
            Debug.LogWarning($"No behaviour for SlotType: {type}");
            break;
        }
    }
Esempio n. 5
0
 public void AddArmorPiece(ArmorPiece piece)
 {
     armorPieces.Add(piece);
 }
Esempio n. 6
0
        public SupersetInfo CreateSupersetModel(IList <IEquipment> equipments, IAbility[] desiredAbilities)
        {
            EquipmentType type            = equipments.FirstOrDefault()?.Type ?? EquipmentType.Charm; // No equipment probably means charm
            var           desiredSkillIDs = new HashSet <int>(desiredAbilities.Select(x => x.Skill.Id));

            int[] slots     = new int[CutoffSearchConstants.Slots];
            int   maxSkills = 0;

            foreach (IEquipment eq in equipments)
            {
                for (int i = 0; i < eq.Slots.Length; i++)
                {
                    if (slots[i] < eq.Slots[i])
                    {
                        slots[i] = eq.Slots[i];
                    }
                }

                int skillCount = 0;
                foreach (IAbility ability in eq.Abilities)
                {
                    if (!desiredSkillIDs.Contains(ability.Skill.Id))
                    {
                        continue;
                    }
                    skillCount += ability.Level;
                }
                if (skillCount > maxSkills)
                {
                    maxSkills = skillCount;
                }
            }

            IAbility[] abilities = equipments
                                   .SelectMany(x => x.Abilities)
                                   .GroupBy(x => x.Skill.Id)
                                   .Select(x => x.OrderByDescending(y => y.Level).First())
                                   .ToArray();

            string name     = $"{type} superset";
            var    nameDict = new Dictionary <string, string>()
            {
                { "EN", name }
            };
            var        craftMaterials = new CraftMaterial[0];
            IEvent     ev             = null;
            IEquipment equipment;

            if (type == EquipmentType.Charm)
            {
                equipment = new CharmLevel(-1, 0, nameDict, 0, slots, abilities, ev, craftMaterials);
            }
            else
            {
                var armorPieces            = equipments.Cast <IArmorPiece>().ToList();
                IArmorSetSkill[] setSkills = armorPieces
                                             .Where(x => x.ArmorSetSkills != null)
                                             .SelectMany(x => x.ArmorSetSkills)
                                             .Distinct()
                                             .ToArray();
                IArmorPiece firstArmor = armorPieces.First();
                equipment = new ArmorPiece(-1, nameDict, firstArmor.Type, 0, slots, abilities, setSkills, firstArmor.Defense, firstArmor.Resistances, firstArmor.Attributes, firstArmor.Assets, firstArmor.FullArmorSet, ev, craftMaterials);
            }
            var info = new SupersetInfo(equipment, maxSkills);

            return(info);
        }