Ejemplo n.º 1
0
        public StatTable(StatTable other)
        {
            id = nextId++;

            // Base values must be copied
            BaseValues = new StatMap(other.BaseValues);

            // Don't need to copy these directly, as changing level will propagate changes
            LeveledValues  = new StatMap();
            ModifiedValues = new StatMap();

            // Progressions, modifiers, dependants must be copied
            Progressions = new StatMap(other.Progressions);
            Dependants   = new StatDependantMap(other.Dependants);

            // Modifiers need extra care, as they need to refer to other objects
            Modifiers = new Dictionary <string, ModifierMap>();
            foreach (KeyValuePair <string, ModifierMap> modMap in other.Modifiers)
            {
                foreach (KeyValuePair <ModifierType, HashSet <StatModifier> > modSet in modMap.Value)
                {
                    foreach (StatModifier mod in modSet.Value)
                    {
                        AddModifier(new StatModifier(mod, this));
                    }
                }
            }

            // Using property fills out leveled and modified values
            Level = other.Level;
        }
Ejemplo n.º 2
0
        public Item UnequipItem(SlotType slot, StatTable heroStats)
        {
            Item removedItem = null;

            if (!Items.TryGetValue(slot, out removedItem) ||
                removedItem is null || removedItem.Name == Item.EmptyItemText)
            {
                return(null);
            }

            // DON'T actually remove - breaks bindings
            Items[slot] = new Item();

            // Handle two-handed weapons
            if (removedItem.slot == SlotType.BothHands)
            {
                if (slot == SlotType.MainHand)
                {
                    Items[SlotType.OffHand] = new Item();
                }
                else if (slot == SlotType.OffHand)
                {
                    Items[SlotType.MainHand] = new Item();
                }
            }

            RemoveItemModsFromHeroStats(removedItem, heroStats);

            return(removedItem);
        }
Ejemplo n.º 3
0
 public GameObject(GameObject other)
 {
     Name        = other.Name;
     Archetype   = other.Archetype;
     Description = other.Description;
     stats       = new StatTable(other.stats);
 }
Ejemplo n.º 4
0
        //------------------------------------------------------------------------------
        // Private Functions:
        //------------------------------------------------------------------------------

        private void AddItemModsToHeroStats(Item itemToEquip, StatTable heroStats)
        {
            // Add stats from item to hero stat mods
            foreach (KeyValuePair <string, float> moddedStat in itemToEquip.Stats.ModifiedValues)
            {
                heroStats.AddModifier(new StatModifier(moddedStat.Key,
                                                       null, ModifierType.Additive, moddedStat.Value, itemToEquip));
            }
        }
Ejemplo n.º 5
0
 private void RemoveItemModsFromHeroStats(Item unequipped, StatTable heroStats)
 {
     // Remove stats from item from hero stat mods
     foreach (KeyValuePair <string, float> moddedStat in unequipped.Stats.ModifiedValues)
     {
         heroStats.RemoveModifier(new StatModifier(moddedStat.Key,
                                                   null, ModifierType.Additive, moddedStat.Value, unequipped));
     }
 }
Ejemplo n.º 6
0
 public StatModifier(StatModifier other, StatTable newTable)
 {
     statName        = other.statName;
     modSourceStat   = other.modSourceStat;
     type            = other.type;
     ModValue        = other.ModValue;
     ModSourceObject = other.ModSourceObject;
     if (ModSourceObject != null)
     {
         modSourceTable = newTable;
     }
 }
Ejemplo n.º 7
0
        public void EquipItem(Item item, StatTable heroStats)
        {
            // Handle two-handed weapons
            if (item.slot == SlotType.BothHands)
            {
                Items[SlotType.MainHand] = item;
                Items[SlotType.OffHand]  = item;
            }
            // Handle other slots
            else
            {
                Items[item.slot] = item;
            }

            AddItemModsToHeroStats(item, heroStats);
        }
Ejemplo n.º 8
0
        //------------------------------------------------------------------------------
        // Public Functions:
        //------------------------------------------------------------------------------

        public GameObject(string name_, string archetype_ = "")
        {
            Name      = name_;
            Archetype = archetype_;
            stats     = new StatTable();
        }