Exemple #1
0
    public bool CheckAchievementMet()
    {
        StatTracker st       = FindObjectOfType <StatTracker>();
        string      withName = "";

        if (WithObject != null)
        {
            if (WithObject.GetComponent <Score>() != null)
            {
                withName = WithObject.GetComponent <Score>().TrackName;
            }
            else if (WithObject.GetComponent <WeaponStats>() != null)
            {
                withName = WithObject.GetComponent <WeaponStats>().name;
            }
        }
        if (typeOfAchievement == AchievementType.SCORE)
        {
            if (InOneLife)
            {
                if (WithObject == null)
                {
                    return(st.maxScore > value);
                }
                else
                {
                    return(st.IsAchievementMet(st.MaxWeaponScores, withName, (int)value));
                }
            }
            else
            {
                if (WithObject == null)
                {
                    return(st.SumStat(st.LifetimeWeaponScores) >= value);
                }
                else
                {
                    return(st.IsAchievementMet(st.LifetimeWeaponScores, withName, (int)value));
                }
            }
        }
        else if (typeOfAchievement == AchievementType.WEAPON_KILLS)
        {
            if (InOneLife)
            {
                if (WithObject == null)
                {
                    return(st.maxKills >= value);
                }
                else
                {
                    return(st.IsAchievementMet(st.MaxWeaponKills, withName, (int)value));
                }
            }
            else
            {
                if (WithObject == null)
                {
                    return(st.SumStat(st.LifetimeWeaponKills) >= value);
                }
                else
                {
                    return(st.IsAchievementMet(st.LifetimeWeaponScores, withName, (int)value));
                }
            }
        }
        else if (typeOfAchievement == AchievementType.LEVEL)
        {
            if (WithObject == null)
            {
                return(st.MaxVal(st.MaxWeaponUsedAtLevel) >= value);
            }
            else
            {
                return(st.IsAchievementMet(st.MaxWeaponUsedAtLevel, withName, (int)value));
            }
        }
        else if (typeOfAchievement == AchievementType.WEAPON_SWITCHES)
        {
            if (InOneLife)
            {
                if (WithObject == null)
                {
                    return(false);
                }
                else
                {
                    return(st.IsAchievementMet(st.MaxWeaponSwitches, withName, (int)value));
                }
            }
            else
            {
                if (WithObject == null)
                {
                    return(st.SumStat(st.LifetimeWeaponSwitches) >= value);
                }
                else
                {
                    return(st.IsAchievementMet(st.LifetimeWeaponSwitches, withName, (int)value));
                }
            }
        }
        else if (typeOfAchievement == AchievementType.ENEMY_KILLED)
        {
            if (InOneLife)
            {
                if (WithObject == null)
                {
                    return(st.maxKills >= value);
                }
                else
                {
                    if (WithObject2 != null)
                    {
                        return(st.IsAchievementMet(st.MaxEnemyWeaponKills, withName, WithObject2.GetComponent <WeaponStats>().name, (int)value));
                    }
                    else
                    {
                        return(st.IsAchievementMet(st.MaxEnemyKills, withName, (int)value));
                    }
                }
            }
            else
            {
                if (WithObject == null)
                {
                    return(st.SumStat(st.LifetimeEnemyKills) >= value);
                }
                else
                {
                    if (WithObject2 != null)
                    {
                        return(st.IsAchievementMet(st.LifetimeEnemyKills, withName, WithObject2.GetComponent <WeaponStats>().name, (int)value));
                    }
                    else
                    {
                        return(st.IsAchievementMet(st.LifetimeEnemyKills, withName, (int)value));
                    }
                }
            }
        }
        else if (typeOfAchievement == AchievementType.POWER_UP)
        {
            if (WithObject == null)
            {
                return(false);
            }
            else
            {
                return(st.IsAchievementMet(st.MaxPowerUps, WithObject.GetComponent <PowerUpBase>().PowerUpID, (int)value));
            }
        }
        return(false);
    }