Esempio n. 1
0
 /// <summary>
 /// constructor
 /// </summary>
 public TargetStatEffect(TargetStatEffectAsset asset) : base(asset)
 {
     Modifier   = asset.Modifier;
     StatBase   = (RPGStatType)asset.StatBase;
     FlatValue  = asset.FlatValue;
     TargetStat = (RPGStatType)asset.TargetStat;
 }
        /// <summary>
        /// Creates the stat.
        /// </summary>
        /// <returns>The stat.</returns>
        /// <param name="statType">Stat type.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        protected T CreateStat <T>(RPGStatType statType) where T : RPGStat
        {
            T stat = System.Activator.CreateInstance <T>();

            StatDict.Add(statType, (RPGStat)stat);
            return(stat);
        }
 /// <summary>
 /// Gets the stat.
 /// </summary>
 /// <returns>The stat.</returns>
 /// <param name="statType">Stat type.</param>
 public RPGStat GetStat(RPGStatType statType)
 {
     if (ContainStat(statType))
     {
         return(StatDict [statType]);
     }
     return(null);
 }
Esempio n. 4
0
        public void ModifyStat(RPGStatType statName, float value)
        {
            RPGVital stat = null;

            if (StatCollection.TryGetStat <RPGVital> (statName, out stat))
            {
                stat.StatValueCurrent += value;
            }
        }
Esempio n. 5
0
    public RPGStat GetStat(RPGStatType type)
    {
        RPGStat stat;

        if (_stats.TryGetValue(type, out stat))
        {
            return(stat);
        }
        return(null);
    }
Esempio n. 6
0
        /// <summary>
        /// constructor taking an effect asset
        /// </summary>
        public StatGlobalEffect(StatGlobalEffectAsset asset) : base(asset)
        {
            TargetType  = asset.TargetType;
            IncludeSelf = asset.IncludeSelf;

            Modifier   = asset.Modifier;
            StatBase   = (RPGStatType)asset.StatBase;
            FlatValue  = asset.FlatValue;
            TargetStat = (RPGStatType)asset.TargetStat;
        }
        /// <summary>
        /// Creates the or get stat.
        /// </summary>
        /// <returns>The or get stat.</returns>
        /// <param name="statType">Stat type.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        protected T CreateOrGetStat <T>(RPGStatType statType) where T : RPGStat
        {
            T stat = GetStat <T>(statType);

            if (stat == null)
            {
                stat = CreateStat <T>(statType);
            }
            return(stat);
        }
Esempio n. 8
0
 protected T CreateOrGetStat <T>(RPGStatType type) where T : RPGStat
 {
     if (Contains(type))
     {
         return(GetStat <T>(type));
     }
     else
     {
         return(CreateStat <T>(type));
     }
 }
        /// <summary>
        /// constructor
        /// </summary>
        public PositionAOEStatEffect(PositionAOEStatEffectAsset asset) : base(asset)
        {
            IncludeSelf = asset.IncludeSelf;
            TargetType  = asset.TargetType;
            Radius      = asset.Radius;

            Modifier   = asset.Modifier;
            StatBase   = (RPGStatType)asset.StatBase;
            FlatValue  = asset.FlatValue;
            TargetStat = (RPGStatType)asset.TargetStat;
        }
Esempio n. 10
0
        public bool TryGetStatPercentValue(RPGStatType statName, out float value)
        {
            RPGVital stat = null;

            value = 0;
            if (StatCollection.TryGetStat <RPGVital> (statName, out stat))
            {
                value = stat.StatValueCurrent / stat.StatValue;
                return(true);
            }
            return(false);
        }
Esempio n. 11
0
        public bool TryGetStatValue(RPGStatType statName, out int value)
        {
            RPGStat stat = null;

            value = 0;
            if (StatCollection.TryGetStat(statName, out stat))
            {
                value = stat.StatValue;
                return(true);
            }
            return(false);
        }
Esempio n. 12
0
    protected T CreateStat <T>(RPGStatType type) where T : RPGStat
    {
        T t = Activator.CreateInstance <T>();

        _stats.Add(type, t);
        var change = t as IStatValueChange;

        if (change != null)
        {
            change.OnValueChange += OnStatValueChanged;
        }
        return(t);
    }
Esempio n. 13
0
 protected T CreateOrGetStat <T>(RPGStatType type) where T : RPGStat
 {
     if (Contains(type))
     {
         return(GetStat <T>(type));
     }
     else
     {
         T stat = CreateStat <T>(type);
         _stats.Add(type, stat);
         return(stat);
     }
 }
Esempio n. 14
0
    public virtual RPGAttribute GetAttributeStat(RPGStatType stat)
    {
        switch (stat)
        {
        case RPGStatType.Alive:
            return(alive);

        case RPGStatType.Speed:
            return(speed);

        default:
            return(speed);    ///TODO what should be the default for this?
        }
    }
Esempio n. 15
0
    public virtual RPGVital GetVitalStat(RPGStatType stat)
    {
        switch (stat)
        {
        case RPGStatType.Stamina:
            return(stamina);

        case RPGStatType.Health:
            return(health);

        case RPGStatType.Willpower:
            return(willpower);

        default:
            return(stamina);    ///TODO what should be the default for this?
        }
    }
Esempio n. 16
0
    public RPGAttribute GetRPGAttributeStat(RPGStatType stat)
    {
        switch (gameObject.name)
        {
        case "Player":
            return(gameObject.GetComponent <StatsPlayer>().GetAttributeStat(stat));

        case "Chace":
            return(gameObject.GetComponent <StatsChace>().GetAttributeStat(stat));

        case "Guard":
            return(gameObject.GetComponent <StatsGuard>().GetAttributeStat(stat));

        default:
            return(gameObject.GetComponent <StatsGuard>().GetAttributeStat(stat));
        }
    }
Esempio n. 17
0
 /// <summary>
 /// Scales the target stat in the collection to the target level
 /// </summary>
 public void ScaleStat(RPGStatType target, int level)
 {
     if (ContainStat(target))
     {
         var stat = GetStat(target) as IStatScalable;
         if (stat != null)
         {
             stat.ScaleStat(level);
         }
         else
         {
             Debug.Log("[RPGStats] Trying to Scale Stat with a non scalable stat \"" + target.ToString() + "\"");
         }
     }
     else
     {
         Debug.Log("[RPGStats] Trying to Scale Stat for \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat");
     }
 }
 /// <summary>
 /// Scales the stat.
 /// </summary>
 /// <param name="target">Target.</param>
 /// <param name="level">Level.</param>
 public void ScaleStat(RPGStatType target, int level)
 {
     if (ContainStat(target))
     {
         var modStat = GetStat(target) as IStatScalable;
         if (modStat != null)
         {
             modStat.ScaleStat(level);
         }
         else
         {
             Debug.Log("[RPGStatCollection] Trying to scale Stat Modifiers to non modifiable stat\"" + target.ToString() + "\"");
         }
     }
     else
     {
         Debug.Log("[RPGStatCollection] Trying to scale Stat Modifiers to \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat");
     }
 }
 /// <summary>
 /// Updates the stat modifier.
 /// </summary>
 /// <param name="target">Target.</param>
 public void UpdateStatModifier(RPGStatType target)
 {
     if (ContainStat(target))
     {
         var modStat = GetStat(target) as IStatModifiable;
         if (modStat != null)
         {
             modStat.UpdateModifiers();
         }
         else
         {
             Debug.Log("[RPGStatCollection] Trying to update Stat Modifiers to non modifiable stat\"" + target.ToString() + "\"");
         }
     }
     else
     {
         Debug.Log("[RPGStatCollection] Trying to update Stat Modifiers to \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat");
     }
 }
Esempio n. 20
0
 /// <summary>
 /// Adds a Stat Modifier to the Target stat and then updates the stat's value.
 /// </summary>
 public void AddStatModifier(RPGStatType target, RPGStatModifier mod, bool update)
 {
     if (ContainStat(target))
     {
         var modStat = GetStat(target) as IStatModifiable;
         if (modStat != null)
         {
             modStat.AddModifier(mod);
             if (update == true)
             {
                 modStat.UpdateModifiers();
             }
         }
         else
         {
             Debug.Log("[RPGStats] Trying to add Stat Modifier to non modifiable stat \"" + target.ToString() + "\"");
         }
     }
     else
     {
         Debug.Log("[RPGStats] Trying to add Stat Modifier to \"" + target.ToString() + "\", but RPGStats does not contain that stat");
     }
 }
Esempio n. 21
0
 /// <summary>
 /// Clears all stat modifiers from the target stat then updates the stat's value.
 /// </summary>
 public void ClearStatModifier(RPGStatType target, bool update)
 {
     if (ContainStat(target))
     {
         var modStat = GetStat(target) as IStatModifiable;
         if (modStat != null)
         {
             modStat.ClearModifiers();
             if (update == true)
             {
                 modStat.UpdateModifiers();
             }
         }
         else
         {
             Debug.Log("[RPGStats] Trying to clear Stat Modifiers from non modifiable stat \"" + target.ToString() + "\"");
         }
     }
     else
     {
         Debug.Log("[RPGStats] Trying to clear Stat Modifiers from \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat");
     }
 }
Esempio n. 22
0
    public virtual void UpdateModifiedStat(RPGStatType stat, int newAmount)
    {
        switch (stat)
        {
        case RPGStatType.Stamina:
            stamina.StatCurrentValue = newAmount;
            break;

        case RPGStatType.Alive:
            alive.StatBaseValue = newAmount;
            break;

        case RPGStatType.Health:
            health.StatCurrentValue = newAmount;
            break;

        case RPGStatType.Willpower:
            willpower.StatCurrentValue = newAmount;
            break;

        default:
            break;
        }
    }
Esempio n. 23
0
        public void ModifyStat(RPGStatType sourceStat, RPGStatType targetStat, float modifier, float flatValue, float baseValue)
        {
            float rawValue    = flatValue + modifier * baseValue;
            float bufferValue = 1.0f;

            if (sourceStat == RPGStatType.Power)
            {
                RPGStat stat = null;
                if (StatCollection.TryGetStat(RPGStatType.Defense, out stat))
                {
                    bufferValue = stat.StatValue;
                }
            }
            else if (sourceStat == RPGStatType.Mind)
            {
                RPGStat stat = null;
                if (StatCollection.TryGetStat(RPGStatType.Spirit, out stat))
                {
                    bufferValue = stat.StatValue;
                }
            }

            ModifyStat(targetStat, (int)((rawValue < 0) ? (-1) : (1) * rawValue * rawValue / bufferValue));
        }
 public RPGStatModifier()
 {
     _type = Types.None;
     _value = 0;
     _statType = RPGStatType.None;
 }
Esempio n. 25
0
 static public void ScaleStat(this RPGStatCollection collection, RPGStatType statType, int level)
 {
     collection.ScaleStat((int)statType, level);
 }
 /// <summary>
 /// Gets the stat.
 /// </summary>
 /// <returns>The stat.</returns>
 /// <param name="type">Type.</param>
 /// <typeparam name="T">The 1st type parameter.</typeparam>
 public T GetStat <T>(RPGStatType type) where T : RPGStat
 {
     return(GetStat(type) as T);
 }
Esempio n. 27
0
 static public bool ContainStat(this RPGStatCollection collection, RPGStatType statType)
 {
     return(collection.ContainStat((int)statType));
 }
 /// <summary>
 /// Contains the stat.
 /// </summary>
 /// <returns><c>true</c>, if stat was contained, <c>false</c> otherwise.</returns>
 /// <param name="statType">Stat type.</param>
 public bool ContainStat(RPGStatType statType)
 {
     return(StatDict.ContainsKey(statType));
 }
 /// <summary>
 /// Clears the stat modifier.
 /// </summary>
 /// <param name="target">Target.</param>
 public void ClearStatModifier(RPGStatType target)
 {
     ClearStatModifier(target, false);
 }
 /// <summary>
 /// Removes the stat modifier.
 /// </summary>
 /// <param name="target">Target.</param>
 /// <param name="mod">Mod.</param>
 public void RemoveStatModifier(RPGStatType target, RPGStatModifier mod)
 {
     RemoveStatModifier(target, mod, false);
 }
 /// <summary>
 /// Adds the modifier.
 /// </summary>
 /// <param name="target">Target.</param>
 /// <param name="mod">Mod.</param>
 public void AddModifier(RPGStatType target, RPGStatModifier mod)
 {
     AddModifier(target, mod, false);
 }
 public RPGStatModifier(RPGStatType targetStat, Types modType, float value)
 {
     _type = modType;
     _statType = targetStat;
     _value = value;
 }