예제 #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);
    }
예제 #2
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);
            }
        }
    }