Esempio n. 1
0
    public GameBattleUnit summonUnit(GameBattleUnit u, int id, int x, int y)
    {
        GameBattleUnit battleUnit = getUnitByID(id);

        if (battleUnit == null)
        {
            return(null);
        }

        if (battleUnit.IsShow || battleUnit.IsKilled)
        {
            return(null);
        }

        GameUnit unit = GameUnitData.instance.getData(battleUnit.UnitID);

        battleUnit.IsShow   = true;
        battleUnit.IsSummon = true;

        GameUnitBase unitBaseU = u.getUnitBase();
        GameUnitBase unitBase  = battleUnit.getUnitBase();

        unitBase.LV = unitBaseU.LV;

        unitBase.HP  = (short)(unitBaseU.HP * unit.HP / 100.0f);
        unitBase.MP  = (short)(unitBaseU.MP * unit.MP / 100.0f);
        unitBase.Str = (short)(unitBaseU.Str * unit.Str / 100.0f);
        unitBase.Vit = (short)(unitBaseU.Vit * unit.Vit / 100.0f);
        unitBase.Avg = (short)(unitBaseU.Avg * unit.Avg / 100.0f);
        unitBase.Int = (short)(unitBaseU.Int * unit.Int / 100.0f);
        unitBase.Luk = (short)(unitBaseU.Luk * unit.Luk / 100.0f);

        battleUnit.updateUnitData();

        battleUnit.initHPMP();
        battleUnit.clearMove();

        battleUnit.setPos(x, y);
        battleUnit.updateAnimation(GameAnimationDirection.South);
        battleUnit.updateAlive();

        return(battleUnit);
    }
Esempio n. 2
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();
    }
Esempio n. 3
0
    public void initUnits()
    {
        GameBattleStage stage = GameBattleManager.instance.ActiveBattleStage;


        units = new GameBattleUnit[stage.Man.Length];

        for (int i = 0; i < stage.Man.Length; i++)
        {
            GameUnit unit = GameUnitData.instance.getData(stage.Man[i].UnitBase.UnitID);

            string path = "Prefab/Sprite/man" + GameDefine.getString3(unit.Sprite) + "/";
            path += (GameDefine.getString3(unit.Sprite) + "man");

            GameObject    obj = Instantiate <GameObject>(Resources.Load <GameObject>(path));
            GameAnimation ani = obj.GetComponent <GameAnimation>();
            obj.name = "man" + GameDefine.getString3(unit.Sprite) + " " + i + " " + stage.Man[i].UnitBase.UnitID;

            Transform trans = obj.transform;
            trans.SetParent(unitTransform);
            trans.localScale = new Vector3(1.0f, 1.0f, 1.0f);

            GameBattleMovement movement   = obj.AddComponent <GameBattleMovement>();
            GameBattleUnit     battleUnit = obj.AddComponent <GameBattleUnit>();

            battleUnit.init(unit, stage.Man[i].clone());

            if (battleUnit.UnitID < GameDefine.MAX_USER)
            {
                battleUnit.setUnitBase(GameUserData.instance.getUnitBase(battleUnit.UnitID));
            }

            battleUnit.updateUnitData();
            battleUnit.initHPMP();
            battleUnit.clearMove();

            if (battleUnit.IsUser)
            {
                addUser(battleUnit);
            }
            else if (battleUnit.IsEnemy)
            {
                addEnemy(battleUnit);
            }
            else if (battleUnit.IsNpc)
            {
                addNpc(battleUnit);
            }

            units[i] = battleUnit;

            if (stage.XY.Length <= i)
            {
            }
            else
            {
                GameBattleXY xy = stage.XY[i];
                movement.setPos(xy.X, xy.Y);
            }
        }
    }