Ejemplo n.º 1
0
 public SpeedPotion(CharacterStatType type, float factor, float flat, float duration)
 {
     this.factor   = factor;
     this.flat     = flat;
     this.duration = duration;
     this.type     = type;
 }
Ejemplo n.º 2
0
    public Stat GetStat(CharacterStatType statType)
    {
        switch (statType)
        {
        case CharacterStatType.Strength:
            return(Strength);

        case CharacterStatType.Accuracy:
            return(Accuracy);

        case CharacterStatType.Agility:
            return(Agility);

        case CharacterStatType.Fortitude:
            return(Fortitude);

        case CharacterStatType.Intelligence:
            return(Intelligence);

        case CharacterStatType.Charisma:
            return(Charisma);

        case CharacterStatType.NONE:
        default:
            Debug.LogError("Stat not found");
            return(null);
        }
    }
Ejemplo n.º 3
0
    public void OnStatButtonPressed(string stat)
    {
        CharacterStatType statSelected = CharacterStatistics.StatTypeFromString(stat);

        int currentLevel = Game.instance.playerStats.BaseStatValue(statSelected);
        int cost         = UpgradeCost(statSelected);

        if (Game.instance.playerData.numHearts >= cost)
        {
            Game.instance.playerData.numHearts -= cost;
            NumberPopupGenerator.instance.GeneratePopup(Game.instance.avatar.gameObject, cost, NumberPopupReason.RemoveHearts);

            if (statSelected == CharacterStatType.MaxHealth)
            {
                Game.instance.playerStats.ChangeBaseStat(statSelected, currentLevel + mHealthPerLevel);
                Game.instance.playerData.health = Game.instance.avatar.GetComponent <CharacterStatistics>().ModifiedStatValue(CharacterStatType.MaxHealth, Game.instance.avatar.gameObject);
            }
            else
            {
                Game.instance.playerStats.ChangeBaseStat(statSelected, currentLevel + 1);
            }

            Game.instance.cinematicDirector.PostCinematicEvent("trainer_success");

            Game.instance.soundManager.PlaySound("confirm_special");
        }
        else
        {
            Game.instance.cinematicDirector.PostCinematicEvent("trainer_fail");
        }

        Close();
    }
Ejemplo n.º 4
0
    private int MaximumPassiveStatBoost(CharacterStatType statType)
    {
        // Look at the player's current level in that area
        int baseLevel = Game.instance.avatar.GetComponent <CharacterStatistics>().BaseStatValue(statType);

        return(baseLevel / 5);
    }
Ejemplo n.º 5
0
    public virtual int BaseStatValue(CharacterStatType statType)
    {
        int value = 0;

        if (statType == CharacterStatType.MaxHealth)
        {
            value = _maxHealth;
        }
        else if (statType == CharacterStatType.Strength)
        {
            value = _strength;
        }
        else if (statType == CharacterStatType.Defense)
        {
            value = _defense;
        }
        else if (statType == CharacterStatType.Magic)
        {
            value = _magic;
        }
        else if (statType == CharacterStatType.Speed)
        {
            value = _speed;
        }
        else
        {
            value = _luck;
        }

        return(value);
    }
Ejemplo n.º 6
0
    public virtual void ChangeBaseStat(CharacterStatType statType, int newValue)
    {
        if (statType == CharacterStatType.MaxHealth)
        {
            _maxHealth = newValue;
        }
        else if (statType == CharacterStatType.Strength)
        {
            _strength = newValue;
        }
        else if (statType == CharacterStatType.Defense)
        {
            _defense = newValue;
        }
        else if (statType == CharacterStatType.Magic)
        {
            _magic = newValue;
        }
        else if (statType == CharacterStatType.Speed)
        {
            _speed = newValue;
        }
        else
        {
            _luck = newValue;
        }

        if (onCharacterStatisticsChanged != null)
        {
            onCharacterStatisticsChanged(this);
        }
    }
Ejemplo n.º 7
0
 public int GetStat(CharacterStatType statType)
 {
     if (Stats.TryGetValue(statType, out var stat))
     {
         return(stat.MaxValue);
     }
     return(0);
 }
Ejemplo n.º 8
0
    private void CheckFailStateStatChanged(CharacterStatType stat, float value)
    {
        if (stat != CharacterStatType.RESOURCES)
        {
            return;
        }

        CheckFailState();
    }
Ejemplo n.º 9
0
    public override int ModifiedStatValue(CharacterStatType statType, GameObject entity)
    {
        int valueOnThisEntity    = externalReference.ModifiedStatValue(statType, entity);
        int valueOnExternalRef   = externalReference.ModifiedStatValue(statType, externalReference.gameObject);
        int doubleBaseCorrection = externalReference.BaseStatValue(statType);
        int total = valueOnThisEntity + valueOnExternalRef - doubleBaseCorrection;

        return(total);
    }
Ejemplo n.º 10
0
    public int GetStatValue(CharacterStatType statType)
    {
        Stat stat = GetStat(statType);

        if (stat != null)
        {
            return(stat.CurrentValue);
        }
        return(int.MinValue);
    }
Ejemplo n.º 11
0
    public CharacterStatData DataForStat(CharacterStatType stat)
    {
        for (int i = 0; i < data.Count; ++i)
        {
            if (stat == data[i].stat)
            {
                return(data[i]);
            }
        }

        return(new CharacterStatData());
    }
Ejemplo n.º 12
0
    public void Multiply(CharacterStatType statType, float statMultiplier)
    {
        switch (statType)
        {
        case CharacterStatType.Attack:
            attack *= statMultiplier;
            break;

        case CharacterStatType.Health:
            health *= statMultiplier;
            break;

        case CharacterStatType.MoveSpeed:
            moveSpeed *= statMultiplier;
            break;
        }
    }
Ejemplo n.º 13
0
    void OnStatUpdate(CharacterStatType stat, float value)
    {
        switch (stat)
        {
        case CharacterStatType.RESOURCES:
            OnResourcesUpdated(value);
            break;

        case CharacterStatType.HUNGER:
            OnProgressStatUpdate(hungerProgressImage, value / 100f);
            break;

        case CharacterStatType.HAPPINESS:
            OnProgressStatUpdate(happinessProgressImage, value / 100f);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 14
0
    private int UpgradeCost(CharacterStatType statType)
    {
        int level = Game.instance.playerStats.BaseStatValue(statType);

        if (statType == CharacterStatType.MaxHealth)
        {
            level = (level - mStartingHealth + mHealthPerLevel) / mHealthPerLevel;
        }

        int cost = Mathf.RoundToInt(Mathf.Pow(2, level));

        // Slow the cost ramp at higher levels
        if (level > 8)
        {
            int overage = level - 8;
            cost = Mathf.RoundToInt(Mathf.Pow(2, 8)) + 128 * overage;
        }

        return(cost);
    }
Ejemplo n.º 15
0
    public void Add(CharacterStatType statType, int statAddend)
    {
        switch (statType)
        {
        case CharacterStatType.Attack:
            attack += statAddend;
            break;

        case CharacterStatType.Health:
            health += statAddend;
            if (health > originalStats.health)
            {
                health = originalStats.health;
            }
            break;

        case CharacterStatType.MoveSpeed:
            moveSpeed += statAddend;
            break;
        }
    }
Ejemplo n.º 16
0
    public float GetStat(CharacterStatType statType)
    {
        switch (statType)
        {
        case CharacterStatType.Attack:
            return(attack);

        case CharacterStatType.Health:
            return(health);

        case CharacterStatType.MaxHealth:
            return(maxHealth);

        case CharacterStatType.MoveSpeed:
            return(moveSpeed);

        case CharacterStatType.EXP:
            return(exp);
        }
        return(-1);
    }
Ejemplo n.º 17
0
    /// <summary>
    /// Returns a stat value including all equipment, perks, bonuses, etc that may apply.
    /// </summary>
    /// <param name="statType"></param>
    /// <returns></returns>
    public virtual int ModifiedStatValue(CharacterStatType statType, GameObject entity)
    {
        int value = BaseStatValue(statType);

        CharacterStatModifier[] modifiers = entity.GetComponentsInChildren <CharacterStatModifier>();

        // Absolute modifications take preference over relative ones
        for (int i = 0; i < modifiers.Length; ++i)
        {
            if (modifiers[i].statType == statType && modifiers[i].isRelative)
            {
                value += modifiers[i].modification;
            }
        }

        for (int i = 0; i < modifiers.Length; ++i)
        {
            if (modifiers[i].statType == statType && modifiers[i].isAbsolute)
            {
                value = modifiers[i].modification;
            }
        }

        PlayerController pc = entity.GetComponent <PlayerController>();

        if (pc != null)
        {
            // Apply relevant character stat boost
            if (Game.instance.playerData.followerUid != null)
            {
                CharacterData followerData = Game.instance.characterDataList.CharacterWithUID(Game.instance.playerData.followerUid);
                if (followerData != null && followerData.statBoost == statType)
                {
                    value += followerData.statBoostAmount;
                }
            }
        }

        return(value);
    }
Ejemplo n.º 18
0
 public bool ModifyStat(CharacterStatType type, float multiplier)
 {
     stats.Multiply(type, multiplier);
     return(true);
 }
Ejemplo n.º 19
0
 public float GetStat(CharacterStatType type)
 {
     return(stats.GetStat(type));
 }
Ejemplo n.º 20
0
 public StatBuff(int buff, CharacterStatType statType, int duration, bool useOnHostile, bool useOnFriendly) : base((int)EffectIndex.StatBuff, useOnHostile, useOnFriendly, duration)
 {
     this.buff     = buff;
     this.statType = statType;
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Gets the specified <see cref="stat"/> value.
 /// </summary>
 /// <param name="stat"></param>
 /// <returns></returns>
 public ushort this[CharacterStatType stat] => Stats[(int)stat];
Ejemplo n.º 22
0
 public void Multiply(CharacterStatType statType, float statMultiplier)
 {
 }
Ejemplo n.º 23
0
 internal void FireCharacterStatChangedEvent(CharacterStatType stat, float value)
 {
     CharacterStatChangedEvent?.Invoke(stat, value);
 }
Ejemplo n.º 24
0
 public override int BaseStatValue(CharacterStatType statType)
 {
     return(externalReference.BaseStatValue(statType));
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Gets the attribute definition of a <see cref="CharacterStatType"/>.
 /// </summary>
 /// <param name="statType">Type of the stat.</param>
 /// <returns>The corrsponding <see cref="AttributeDefinition"/>.</returns>
 public static AttributeDefinition GetAttributeDefinition(this CharacterStatType statType)
 {
     return(StatTypesToAttributes[statType]);
 }
Ejemplo n.º 26
0
 public Challenge(Type challengeType, CharacterStatType skillcheckType, int challengeLevel)
 {
     this.challengeType  = challengeType;
     this.skillcheckType = skillcheckType;
     this.challengeLevel = challengeLevel;
 }
Ejemplo n.º 27
0
 public void Add(CharacterStatType statType, int statAddend)
 {
 }
Ejemplo n.º 28
0
 public void SetAbsoluteModification(CharacterStatType statType, int modification)
 {
     mStatType             = statType;
     mRelativeModification = -1;
     mAbsoluteModification = modification;
 }
Ejemplo n.º 29
0
 public CharacterStatsNode(CharacterStatType statType)
 {
     this.statType = statType;
     this.name     = statType.ToString();
 }
Ejemplo n.º 30
0
 public override void ChangeBaseStat(CharacterStatType statType, int newValue)
 {
     externalReference.ChangeBaseStat(statType, newValue);
 }