Exemplo n.º 1
0
        public static string ToCustomString(this LevelUpType levelUpType)
        {
            switch (levelUpType)
            {
            case LevelUpType.Evolve:
                return("EVOLVE");

            case LevelUpType.Normal:
                return("NORMAL");

            default:
                return(string.Empty);
            }
        }
Exemplo n.º 2
0
        public static int GetLevelFromExp(int exp, LevelUpType ltype)
        {
            double level = 0;

            switch (ltype)
            {
            case LevelUpType.MediumFast:
                level = Math.Pow(exp, (1 / 3.0));
                break;

            case LevelUpType.Erratic:
            case LevelUpType.Fluctuating:
            case LevelUpType.MediumSlow:
                for (level = 1; level < 100; level++)
                {
                    if (GetCeilingExpFromLevel((int)level, ltype) > exp)
                    {
                        break;
                    }
                }

                break;

            case LevelUpType.Fast:
                level = (5 * exp) / 4.0;
                level = Math.Pow(level, 1 / 3.0);
                break;

            case LevelUpType.Slow:
                level = exp * 0.8;
                level = Math.Pow(level, 1 / 3.0);
                break;
            }

            if (level < 1)
            {
                level = 1;
            }
            if (level > 99.99999)
            {
                level = 100;                 // yes, it's f*****g 100
            }
            return((int)(level));
        }
Exemplo n.º 3
0
    /// <summary>
    /// 提升角色能力等級
    /// </summary>
    /// <param name="role">角色名</param>
    /// <param name="type">提升能力類型</param>
    public void LevelUp(GameDefinition.Role role, LevelUpType type)
    {
        int currentLV = -1;
        int cost = -1;
        GameDefinition.RoleData getData;

        switch (type)
        {
            case LevelUpType.生命:
                currentLV = PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_HP_LV");
                //如果該能力已經升至最大等級,則不進行升級
                if (currentLV >= GameDefinition.AbilityCostLevel.Count)
                    return;

                //將目前金幣數扣除升級能力所需的費用
                if (0 > (cost = PlayerPrefsDictionary.script.GetValue("Money") - PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_HP_M")))
                    return;
                PlayerPrefsDictionary.script.SetValue("Money", cost);

                //將能力升一級
                PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_HP_LV", currentLV + 1);

                //如果該能力在升級後,達最大等級,則升級所需金額設為0
                if ((currentLV + 1) == GameDefinition.AbilityCostLevel.Count)
                    PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_HP_M", 0);
                else
                    PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_HP_M", GameDefinition.AbilityCostLevel[currentLV + 1]);

                //讀取系統儲存的角色屬性資料
                getData = GameDefinition.RoleList.Find((GameDefinition.RoleData data) => { return data.RoleName == role; });
                //儲存升級後的能力至系統
                PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_HP", getData.Life + getData.LifeAdd);
                getData.UpdateAbilityValue(PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_HP"), getData.Damage, getData.Defence);
                break;

            case LevelUpType.攻擊:
                currentLV = PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_ATK_LV");
                //如果該能力已經升至最大等級,則不進行升級
                if (currentLV >= GameDefinition.AbilityCostLevel.Count)
                    return;

                //將目前金幣數扣除升級能力所需的費用
                if (0 > (cost = PlayerPrefsDictionary.script.GetValue("Money") - PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_ATK_M")))
                    return;
                PlayerPrefsDictionary.script.SetValue("Money", cost);

                //將能力升一級
                PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_ATK_LV", currentLV + 1);

                //如果該能力在升級後,達最大等級,則升級所需金額設為0
                if ((currentLV + 1) == GameDefinition.AbilityCostLevel.Count)
                    PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_ATK_M", 0);
                else
                    PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_ATK_M", GameDefinition.AbilityCostLevel[currentLV + 1]);

                //讀取系統儲存的角色屬性資料
                getData = GameDefinition.RoleList.Find((GameDefinition.RoleData data) => { return data.RoleName == role; });
                //儲存升級後的能力至系統
                PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_ATK", getData.Damage + getData.DamageAdd);
                getData.UpdateAbilityValue(getData.Life, PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_ATK"), getData.Defence);
                break;

            case LevelUpType.防禦:
                currentLV = PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_DEF_LV");
                //如果該能力已經升至最大等級,則不進行升級
                if (currentLV >= GameDefinition.AbilityCostLevel.Count)
                    return;

                //將目前金幣數扣除升級能力所需的費用
                if (0 > (cost = PlayerPrefsDictionary.script.GetValue("Money") - PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_DEF_M")))
                    return;
                PlayerPrefsDictionary.script.SetValue("Money", cost);

                //將能力升一級
                PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_DEF_LV", currentLV + 1);

                //如果該能力在升級後,達最大等級,則升級所需金額設為0
                if ((currentLV + 1) == GameDefinition.AbilityCostLevel.Count)
                    PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_DEF_M", 0);
                else
                    PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_DEF_M", GameDefinition.AbilityCostLevel[currentLV + 1]);

                //讀取系統儲存的角色屬性資料
                getData = GameDefinition.RoleList.Find((GameDefinition.RoleData data) => { return data.RoleName == role; });
                //儲存升級後的能力至系統
                PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_DEF", getData.Defence + getData.DefenceAdd);
                getData.UpdateAbilityValue(getData.Life, getData.Damage, PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_DEF"));
                break;

            case LevelUpType.普攻等級:
                currentLV = PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_BASIC_LV");
                //如果該能力已經升至最大等級,則不進行升級
                if (currentLV >= GameDefinition.AttackLVCostLevel.Count)
                    return;

                //將目前金幣數扣除升級能力所需的費用
                if (0 > (cost = PlayerPrefsDictionary.script.GetValue("Money") - PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_BASIC_LV_M")))
                    return;
                PlayerPrefsDictionary.script.SetValue("Money", cost);

                //將能力升一級
                PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_BASIC_LV", currentLV + 1);

                //如果該能力在升級後,達最大等級,則升級所需金額設為0
                if ((currentLV + 1) == GameDefinition.AttackLVCostLevel.Count)
                    PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_BASIC_LV_M", 0);
                else
                    PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_BASIC_LV_M", GameDefinition.AttackLVCostLevel[currentLV + 1]);
                break;

            case LevelUpType.絕技等級:
                currentLV = PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_ULT_LV");
                //如果該能力已經升至最大等級,則不進行升級
                if (currentLV >= GameDefinition.UltimateSkillCostLevel.Count)
                    return;

                //將目前金幣數扣除升級能力所需的費用
                if (0 > (cost = PlayerPrefsDictionary.script.GetValue("Money") - PlayerPrefsDictionary.script.GetValue(this.RoleNameDictionary[role] + "_ULT_LV_M")))
                    return;
                PlayerPrefsDictionary.script.SetValue("Money", cost);

                //將能力升一級
                PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_ULT_LV", currentLV + 1);

                //如果該能力在升級後,達最大等級,則升級所需金額設為0
                if ((currentLV + 1) == GameDefinition.UltimateSkillCostLevel.Count)
                    PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_ULT_LV_M", 0);
                else
                    PlayerPrefsDictionary.script.SetValue(this.RoleNameDictionary[role] + "_ULT_LV_M", GameDefinition.UltimateSkillCostLevel[currentLV + 1]);
                break;
        }
    }
Exemplo n.º 4
0
 public LevelUpCommand(LevelUpType levelUpType)
 {
     _levelUpType = levelUpType;
 }
Exemplo n.º 5
0
        public static int GetFloorExpFromLevel(int level, LevelUpType ltype)
        {
            if (level > 100)
            {
                level = 100;
            }
            if (level < 2)
            {
                return(2);
            }

            double exp = 0;

            switch (ltype)
            {
            case LevelUpType.MediumFast:
                exp = Math.Pow(level, 3);
                break;

            case LevelUpType.Erratic:
                if (level > 0 && level <= 50)
                {
                    exp = ((100 - level) / 50.0) * Math.Pow(level, 3);
                }
                else if (level > 50 && level <= 68)
                {
                    exp = ((150 - level) / 100.0) * Math.Pow(level, 3);
                }
                else if (level > 68 && level <= 98)
                {
                    double x = level % 3;
                    double p = 0;
                    if (x == 0)
                    {
                        p = 0;
                    }
                    if (x == 1)
                    {
                        p = 0.008;
                    }
                    if (x == 2)
                    {
                        p = 0.014;
                    }
                    exp = ((level / 3.0) - p) / 50;
                    exp = 1.274 - exp;
                    exp = exp * Math.Pow(level, 3);
                    // Third function still has issues
                    exp = Math.Pow(level, 3) * (1.274 - (1 / 50) * (level / 3) - p);
                }
                else if (level > 98 && level <= 100)
                {
                    exp = ((160 - level) / 100.0) * Math.Pow(level, 3);
                }
                break;

            case LevelUpType.Fluctuating:
                if (level > 0 && level <= 15)
                {
                    // First fluctuation
                    exp = (level + 1) / 3.0;
                    exp = (exp + 24) / 50;
                    exp = exp * Math.Pow(level, 3);
                }
                else if (level > 15 && level <= 35)
                {
                    // Second fluctuation
                    exp = (level + 14) / 50.0;
                    exp = exp * Math.Pow(level, 3);
                }
                else if (level > 25 && level <= 100)
                {
                    // Third fluctuation
                    exp = 32 + (level / 2);
                    exp = exp / 50;
                    exp = exp * Math.Pow(level, 3);
                }

                break;

            case LevelUpType.MediumSlow:
                exp = ((6 * Math.Pow(level, 3)) / 5) - (15 * Math.Pow(level, 2)) + (100 * level) - 140;
                break;

            case LevelUpType.Fast:
                exp = (4 * Math.Pow(level, 3)) / 5.0;
                break;

            case LevelUpType.Slow:
                exp = (5 * Math.Pow(level, 3)) / 4.0;
                break;
            }
            return((int)(exp));
        }
Exemplo n.º 6
0
 public static int GetCeilingExpFromLevel(int level, LevelUpType ltype)
 {
     return(GetFloorExpFromLevel(level + 1, ltype) - 1);
 }