예제 #1
0
        public void RemoveItem(EquipSlot slot)
        {
            // Already nothing in that slot.
            if (Items[(int)slot - 1] == null)
            {
                // TODO: generate warning?
                return;
            }

            // Subtract the item's stats from the summary.
            GearItem item = Items[(int)slot - 1];

            foreach (Materia materia in item.Materia)
            {
                StatSummary[materia.Stat] -= materia.Value;
            }
            foreach (CharacterStat stat in item.Stats.Keys)
            {
                StatSummary[stat] -= item.Stats[stat];
            }

            // Remove the item.
            Items[(int)slot - 1] = null;

            return;
        }
예제 #2
0
        public GearSet(GearItem[] equipment)
        {
            // Put each item in its correct slot in the array.  So that we can't equip 10 weapons.
            // TODO: A configuration with overwriting slots should generate a warning.

            Items       = new GearItem[Enum.GetNames(typeof(EquipSlot)).Length - 1];
            StatSummary = new Dictionary <CharacterStat, double>();

            // Add each initial piece to the set.
            foreach (GearItem e in equipment)
            {
                if (!(e == null))
                {
                    AddItem(e);
                }
            }
        }
예제 #3
0
        public void AddItem(GearItem item)
        {
            EquipSlot slot = item.Slot;

            // Properly remove any item already in that slot.
            if (Items[(int)slot - 1] != null)
            {
                RemoveItem(slot);
            }

            // Add the item.
            Items[(int)slot - 1] = item;

            // Sum the stats on the item into the set's stat summary.
            foreach (CharacterStat stat in item.Stats.Keys)
            {
                if (!StatSummary.ContainsKey(stat))
                {
                    StatSummary.Add(stat, item.Stats[stat]);
                }
                else
                {
                    StatSummary[stat] += item.Stats[stat];
                }
            }

            // Sum the stats from Materia into the set's stat summary.
            foreach (Materia materia in item.Materia)
            {
                if (!StatSummary.ContainsKey(materia.Stat))
                {
                    StatSummary.Add(materia.Stat, materia.Value);
                }
                else
                {
                    StatSummary[materia.Stat] += materia.Value;
                }
            }

            return;
        }
예제 #4
0
 public GearSet()
 {
     Items       = new GearItem[Enum.GetNames(typeof(EquipSlot)).Length - 1];
     StatSummary = new Dictionary <CharacterStat, double>();
 }