Esempio n. 1
0
    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;
    }
Esempio n. 2
0
 public float GetStat(PlayerStatType type)
 {
     if (stats == null || !stats.ContainsKey(type))
     {
         return(0);
     }
     return(stats[type]);
 }
Esempio n. 3
0
    public void SetPlayerStat(PlayerStatType type, float val)
    {
        if (stats == null)
        {
            stats = new Dictionary <PlayerStatType, float>();
        }
        stats[type] = val;

        OnChangeEvent?.Invoke();
    }
Esempio n. 4
0
    /*
     * 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);
    }
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
    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();
    }
Esempio n. 7
0
    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);
    }
Esempio n. 8
0
    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);
    }
Esempio n. 9
0
    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);
    }
Esempio n. 10
0
    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;
        }
    }
Esempio n. 11
0
    public void DecrementTier(PlayerStatType type)
    {
        int nextTier = GetTier(type) - 1;

        SetTier(type, nextTier);
    }
Esempio n. 12
0
    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);
 }
Esempio n. 16
0
 public float this[PlayerStatType statType] => _first[statType] + _second[statType];
Esempio n. 17
0
 public void Init(CardModel cardModel)
 {
     gainType   = cardModel.statGainType;
     gainAmount = cardModel.statGainAmount;
 }