private void ChangeColorToType(PlayerStatType cardType) { Color newColor = Color.white; switch (cardType) { case PlayerStatType.CHARM: newColor = new Color(255f / 255f, 130f / 255f, 189f / 255f); break; case PlayerStatType.FASHION: newColor = new Color(190f / 255f, 70f / 255f, 230f / 255f); break; case PlayerStatType.MONEY: newColor = new Color(255f / 255f, 255f / 255f, 113f / 255f); break; case PlayerStatType.SPORTS: newColor = new Color(170f / 255f, 255f / 255f, 75f / 255f); break; case PlayerStatType.STUDY: newColor = new Color(103f / 255f, 199f / 255f, 254f / 255f); break; } cardBack.color = newColor; }
public float GetStat(PlayerStatType type) { if (stats == null || !stats.ContainsKey(type)) { return(0); } return(stats[type]); }
public void SetPlayerStat(PlayerStatType type, float val) { if (stats == null) { stats = new Dictionary <PlayerStatType, float>(); } stats[type] = val; OnChangeEvent?.Invoke(); }
/* * Helper function that takes the stat type and specific base stat and iterates over the modifiers, * sums up the stat changes, and returns the final stats value */ private float StatHelper(PlayerStatType type, float stat_base) { float final = stat_base; foreach (IPlayerStatModifier mod in persistentModifiers) { if (mod.GetType() == type) { final += mod.GetAmount(); } } return(final); }
public CardModel(CardPrototype prototype) { this.prototype = prototype; id = prototype.id; name = prototype.name; description = prototype.description.Replace("\\n", "\n"); // Allow newlines animation = prototype.animation; rarity = prototype.rarity; cost = prototype.cost; effect = prototype.effect; statGainType = prototype.statGainType; statGainAmount = prototype.statGainAmount; numCardsToDraw = prototype.numCardsToDraw; }
public void SetTier(PlayerStatType type, int tier) { tier = ClampTier(tier); if (indexesHelper == null || !indexesHelper.ContainsKey(type)) { ComputeIndexes(); } int index = indexesHelper[type]; tiers[index].tier = tier; OnStatsChangeEvent?.Invoke(); }
public static StatTier[] GetFilledList(int tier) { tier = ClampTier(tier); Array tierTypes = Enum.GetValues(typeof(PlayerStatType)); StatTier[] newTiers = new StatTierList.StatTier[tierTypes.Length]; for (int i = 0; i < tierTypes.Length; i++) { PlayerStatType type = (PlayerStatType)tierTypes.GetValue(i); newTiers[i].type = type; newTiers[i].tier = tier; } return(newTiers); }
public int GetTier(PlayerStatType type) { if (indexesHelper == null || !indexesHelper.ContainsKey(type)) { ComputeIndexes(); } int index = indexesHelper[type]; if (tiers[index].type != type) { ComputeIndexes(); index = indexesHelper[type]; } return(tiers[index].tier); }
private AnimationCurve GetCurve(PlayerStatType type) { if (computedIndexes == null || !computedIndexes.ContainsKey(type)) { ComputeIndexes(); } if (!computedIndexes.ContainsKey(type)) { return(null); } if (statCurves[computedIndexes[type]].type != type) { ComputeIndexes(); } PlayerStatBalance stat = statCurves[computedIndexes[type]]; return(isAssistMode.Value? stat.assistStatCurve : stat.statCurve); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (statTier == null) { return; } EditorGUILayout.Space(); if (GUILayout.Button("Regenerate Tiers")) { Dictionary <PlayerStatType, int> storedTiers = new Dictionary <PlayerStatType, int>(); if (statTier.Tiers != null && statTier.Tiers.Length > 0) { foreach (StatTierList.StatTier tier in statTier.Tiers) { if (storedTiers.ContainsKey(tier.type)) { Debug.LogError("Aborting regenerating stat tiers due to collision with " + tier.type); break; } storedTiers.Add(tier.type, tier.tier); } } Array tierTypes = Enum.GetValues(typeof(PlayerStatType)); StatTierList.StatTier[] newTiers = new StatTierList.StatTier[tierTypes.Length]; for (int i = 0; i < tierTypes.Length; i++) { PlayerStatType type = (PlayerStatType)tierTypes.GetValue(i); newTiers[i].type = type; newTiers[i].tier = storedTiers.ContainsKey(type)? storedTiers[type] : 0; } statTier.Tiers = newTiers; } }
public void DecrementTier(PlayerStatType type) { int nextTier = GetTier(type) - 1; SetTier(type, nextTier); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (balancer == null) { return; } EditorGUILayout.Space(); if (GUILayout.Button("Regenerate Tiers")) { Dictionary <PlayerStatType, AnimationCurve> storedTiers = new Dictionary <PlayerStatType, AnimationCurve>(); if (balancer.StatCurves != null && balancer.StatCurves.Length > 0) { foreach (PlayerStatsBalancer.PlayerStatBalance stat in balancer.StatCurves) { if (storedTiers.ContainsKey(stat.type)) { Debug.LogError("Aborting regenerating stat curves due to collision with " + stat.type); break; } storedTiers.Add(stat.type, stat.statCurve); } } Array tierTypes = Enum.GetValues(typeof(PlayerStatType)); PlayerStatsBalancer.PlayerStatBalance[] newStats = new PlayerStatsBalancer.PlayerStatBalance[tierTypes.Length]; for (int i = 0; i < tierTypes.Length; i++) { PlayerStatType type = (PlayerStatType)tierTypes.GetValue(i); newStats[i].type = type; newStats[i].statCurve = storedTiers.ContainsKey(type)? storedTiers[type] : new AnimationCurve(); } balancer.StatCurves = newStats; } if (GUILayout.Button("Update Stats")) { balancer.ResetStats(); } if (GUILayout.Button("Copy to empty Assist Stats")) { PlayerStatsBalancer.PlayerStatBalance[] curves = balancer.StatCurves; foreach (PlayerStatsBalancer.PlayerStatBalance curve in curves) { if (curve.assistStatCurve.keys.Length > 0) { continue; } foreach (Keyframe key in curve.statCurve.keys) { curve.assistStatCurve.AddKey(key); } } balancer.StatCurves = curves; } }
public void AdjustStatBy(PlayerStatType stat, int change) { model.statMap[stat] += change; view.UpdateStatsPanel(); }
private bool IsMinStat(PlayerStatType stat) { return(statTierList.GetTier(stat) <= StatTierList.MinTier); }
private bool IsMaxStat(PlayerStatType stat) { return(statTierList.GetTier(stat) >= StatTierList.MaxTier); }
public float this[PlayerStatType statType] => _first[statType] + _second[statType];
public void Init(CardModel cardModel) { gainType = cardModel.statGainType; gainAmount = cardModel.statGainAmount; }