예제 #1
0
    public void levelUp(GameBattleUnit unit)
    {
        GameUnit     gameUnit = unit.getGameUnit();
        GameUnitBase unitBase = unit.getUnitBase();

        GameUnitLevelUp d = getData(unitBase.UnitID);

        if (d == null)
        {
            return;
        }

        if (unitBase.Exp < GameDefine.MAX_EXP)
        {
            return;
        }

        unitBase.Exp -= GameDefine.MAX_EXP;
        unitBase.LV++;

        if (unitBase.LV == GameDefine.MAX_LEVEL)
        {
            unitBase.Exp = 0;
        }

        lastData = new GameUnitLevelUp();

        lastData.HP = gameUnit.HPGrow;
        lastData.MP = gameUnit.MPGrow;

        lastData.StrBase = d.StrBase;
        lastData.StrRand = (short)UnityEngine.Random.Range(1, d.StrRand);
        lastData.VitBase = d.VitBase;
        lastData.VitRand = (short)UnityEngine.Random.Range(1, d.VitRand);
        lastData.IntBase = d.IntBase;
        lastData.IntRand = (short)UnityEngine.Random.Range(1, d.IntRand);
        lastData.AvgBase = d.AvgBase;
        lastData.AvgRand = (short)UnityEngine.Random.Range(1, d.AvgRand);
        lastData.LukBase = d.LukBase;
        lastData.LukRand = (short)UnityEngine.Random.Range(1, d.LukRand);

        lastData.HP += (short)(unitBase.Vit / 35.0f + UnityEngine.Random.Range(1, d.HP + 1));
        lastData.MP += (short)(unitBase.Int / 35.0f + UnityEngine.Random.Range(1, d.MP + 1));

        unitBase.HP  += lastData.HP;
        unitBase.MP  += lastData.MP;
        unitBase.Str += lastData.StrBase;
        unitBase.Str += lastData.StrRand;
        unitBase.Vit += lastData.VitBase;
        unitBase.Vit += lastData.VitRand;
        unitBase.Int += lastData.IntBase;
        unitBase.Int += lastData.IntRand;
        unitBase.Avg += lastData.AvgBase;
        unitBase.Avg += lastData.AvgRand;
        unitBase.Luk += lastData.LukBase;
        unitBase.Luk += lastData.LukRand;

        unitBase.BaseSpiritPower += 2;

        for (int i = 0; i < GameDefine.MAX_SLOT; i++)
        {
            if (d.Skill[i].SkillID == GameDefine.INVALID_ID)
            {
                continue;
            }

            if (unitBase.hasSkill(d.Skill[i].SkillID))
            {
                continue;
            }

            if (unit.SpiritPower[0] < d.Skill[i].SpiritRequest[0] ||
                unit.SpiritPower[1] < d.Skill[i].SpiritRequest[1] ||
                unit.SpiritPower[2] < d.Skill[i].SpiritRequest[2] ||
                unit.SpiritPower[3] < d.Skill[i].SpiritRequest[3] ||
                unit.SpiritPower[4] < d.Skill[i].SpiritRequest[4])
            {
                continue;
            }

            if (unit.LV < d.Skill[i].LV)
            {
                continue;
            }

            unitBase.addSkill(d.Skill[i].SkillID);

            lastData.Skill[0]         = new GameUnitLevelUpSkillLearn();
            lastData.Skill[0].SkillID = d.Skill[i].SkillID;
        }

        unit.updateUnitData();
    }