Esempio n. 1
0
    /// <summary>
    /// Using the dice defined for each stats growth returns Stats with
    /// the results of the rolls for each growth dice
    /// </summary>
    /// <returns></returns>
    StatData GetStatsGrowth()
    {
        StatData stats = new StatData();

        foreach (KeyValuePair <StatsId, Dice> growth in Stats.Growths)
        {
            StatsId id   = growth.Key;
            Dice    dice = growth.Value;
            stats[id] = dice.Roll();
        }

        return(stats);
    }
Esempio n. 2
0
    /// <summary>
    /// Forces all current stats to be a zero value
    /// </summary>
    public void SetStatsToZero()
    {
        Dictionary <StatsId, int> stats = new Dictionary <StatsId, int>();

        foreach (KeyValuePair <StatsId, int> item in m_stats)
        {
            StatsId id    = item.Key;
            int     value = item.Value;
            stats[id] = 0;
        }

        m_stats = stats;
    }
Esempio n. 3
0
    /// <summary>
    /// Applies the level and stats changes presented in the level up metadata
    /// Increases the total experience points required to level up for the next level
    /// The increment of the current experience point happens prior to this call
    /// </summary>
    /// <param name="data"></param>
    public void LevelUp(LevelUpMetada data)
    {
        Stats.Level       += data.level;
        Stats.Exp          = Stats.NextLevelExp;
        Stats.NextLevelExp = EXPManager.instance.NextLevelEXP(Stats.Level, BaseExperience);

        foreach (KeyValuePair <StatsId, int> item in data.stats)
        {
            StatsId id    = item.Key;
            int     value = item.Value;
            Stats[id] += value;
        }

        OnStatsChanged();
    }
Esempio n. 4
0
    /// <summary>
    /// Gets/Sets the given stat id
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public int this[StatsId id]
    {
        get {
            int stat = 0;

            if (m_stats.ContainsKey(id))
            {
                stat = m_stats[id];
            }

            return(stat);
        }
        set {
            m_stats[id] = value;
        }
    }
Esempio n. 5
0
    /// <summary>
    /// Returns the information that represents the stats changes for adding
    /// the given level number to the current level.
    /// </summary>
    /// <param name="level">How many levels to increase the unit by</param>
    /// <returns></returns>
    public LevelUpMetada CreateLevelUp(int level)
    {
        StatData stats = new StatData();

        // Increase the stats for each level
        for (int i = 0; i < level; i++)
        {
            foreach (KeyValuePair <StatsId, Dice> growth in Stats.Growths)
            {
                StatsId id   = growth.Key;
                Dice    dice = growth.Value;
                stats[id] = dice.Roll();
            }
        }

        LevelUpMetada data = new LevelUpMetada(level, stats);

        return(data);
    }
Esempio n. 6
0
    /// <summary>
    /// Returns the value of the given stats with its modifiers applied
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public int GetStat(StatsId id)
    {
        int stats      = this[id];
        int multiplier = 0;

        foreach (StatsModifier modifier in m_modifiers)
        {
            StatData incrementalStats = modifier[ModifierType.Incremental];
            StatData multiplierStats  = modifier[ModifierType.Multiplier];

            int incremental = incrementalStats[id];
            int multiply    = multiplierStats[id];

            stats      += incremental;
            multiplier += multiply;
        }

        int total = stats + (stats * multiplier);

        return(total);
    }
Esempio n. 7
0
    /// <summary>
    /// Resets all the base stats to zero or to a growth roll if it has one
    /// </summary>
    void ResetStats()
    {
        Dictionary <StatsId, int> stats = new Dictionary <StatsId, int>();

        foreach (KeyValuePair <StatsId, int> item in m_stats)
        {
            StatsId id    = item.Key;
            int     value = item.Value;

            if (m_statsGrowths.ContainsKey(id))
            {
                stats[id] = m_statsGrowths[id].Roll();
            }
            else
            {
                stats[id] = 0;
            }
        }

        // Reset current health to max health
        stats[StatsId.HP_Cur] = stats[StatsId.HP_Max];
        m_stats = stats;
    }