public void Initialize(PlayerStats playerStats, ModifiableStat stat, Action <PlayerStatWithModifiers> callback) { this.playerStats = playerStats; this.theStat = (PlayerStatWithModifiers)playerStats.GetStat(stat); this.callback = callback; this.UpdateUIValues(); }
// Setup stat pairs for like hp/max hp and mana/max mana private void SetupStatPair(PlayerRawStat curStat, PlayerStatWithModifiers maxStat) { curStat.SetMinMax(0, maxStat.GetBaseValue()); //curStat.SetValue(maxStat.GetBaseValue()); maxStat.SetCallback((int maxValue) => curStat.SetMinMax(0, maxValue)); //maxStat.divisor = 3; }
public void RefreshStatsBasedOnLevel() { foreach (KeyValuePair <ModifiableStat, PlayerStatWithModifiers> statPair in this.modifiableStats) { PlayerStatWithModifiers statWithModifiers = statPair.Value; statWithModifiers.ApplyBaseValueBasedOnLevel(this.level); } }
public void LevelUpStat(PlayerStatWithModifiers stat) { // Nothing for now heroPlayer.stats.LevelUpStat(stat.stat); this.UpdateStatText(); foreach (StatRewardUI rewardUI in this.statRewardUIs) { rewardUI.UpdateUIValues(); } }
// Resetter ------------------// public void ResetStats() { foreach (KeyValuePair <ModifiableStat, PlayerStatWithModifiers> statPair in this.modifiableStats) { PlayerStatWithModifiers stat = statPair.Value; stat.ClearModifiers(); stat.GetValue(); } this.SetHPMPToMax(); }
public object Clone() { PlayerStatWithModifiers stat = new PlayerStatWithModifiers(this.stat, this.baseValue, this.growth, this.divisor, this.callback); PriorityList <StatModifier> clonedModifiers = new PriorityList <StatModifier>(); foreach (StatModifier modifier in this.modifiers) { clonedModifiers.Add((StatModifier)modifier.Clone()); } stat.modifiers = clonedModifiers; return(stat); }
public override void ApplyTo(Fighter p) { this.playerStat = p.stats.GetStat(stat); //TODO: Possible Animation Modifications switch (type) { case Type.PERCENTAGE: _flatChange = (int)Mathf.Ceil(playerStat.GetValue() * modifier); this.statModifier = playerStat.ApplyDeltaModifier(_flatChange, StatModifier.Type.FLAT); break; case Type.FLAT: _flatChange = (int)modifier; this.statModifier = playerStat.ApplyDeltaModifier(_flatChange, StatModifier.Type.ADD_PERCENTAGE); break; } Debug.Log("Defending: " + _flatChange + " damage"); }
// Level up stat. Used for hero. public bool LevelUpStat(ModifiableStat stat) { // TODO: FIX THIS if (!this.modifiableStats.ContainsKey(stat)) { Debug.LogError("ERROR: Not assignable stat"); return(false); } PlayerStatWithModifiers theStat = this.modifiableStats[stat]; int costToLevelUp = StatLevelHelpers.GetCostToLevelUpStat(theStat.growth, theStat.divisor); theStat.growth += StatLevelHelpers.LEVEL_UP_GROWTH_INCREASE; theStat.ApplyBaseValueBasedOnLevel(this.level); this.statPoints -= costToLevelUp; return(true); }
public void Initialize(Action callback) { this.callback = callback; this.heroPlayer = GameManager.Instance.gameState.playerParty.GetHeroFighter(); // TODO: move this somewhere else more appropriate this.heroPlayer.stats.LevelUp(); this.UpdateStatText(); Dictionary <ModifiableStat, PlayerStatWithModifiers> modifiableStats = this.heroPlayer.stats.GetModifiableStats(); foreach (KeyValuePair <ModifiableStat, PlayerStatWithModifiers> statPair in modifiableStats) { PlayerStatWithModifiers stat = statPair.Value; StatRewardUI rewardInstance = Instantiate(statRewardUIPrefab, statRewardUIParent); rewardInstance.Initialize(heroPlayer.stats, stat.stat, this.LevelUpStat); this.statRewardUIs.Add(rewardInstance); } StartCoroutine(this.WaitForInput()); }