Exemplo n.º 1
0
    void updateItemSelection()
    {
        if (!GameBattleUnitItemSelection.instance.IsShow)
        {
            return;
        }

        if (confirm)
        {
            confirm = false;

            int x = GameBattleCursor.instance.PosX;
            int y = GameBattleCursor.instance.PosY;

            GameBattleAttackMapDirection dir;

            if (!GameBattleUnitItemSelection.instance.checkCell(x, y, out dir))
            {
                return;
            }

            GameBattleUnit unit = GameBattleSelection.instance.SelectionUnit;

            int      itemSlot = GameBattleItemUI.instance.Selection;
            GameItem item     = GameBattleItemUI.instance.getSelectionItem();

            switch (GameBattleItemUI.instance.Mode)
            {
            case GameBattleUnitActionItemMode.Use:
            {
                GameBattleSelection.instance.getUnits(unit, item, dir);

                if (GameBattleSelection.instance.SelectionUnits.Count == 0)
                {
                    return;
                }

                GameBattleUnitSkillSelection.instance.unShow();

                GameTouchCenterUI.instance.unShowUI();

                GameBattleAttackResult.instance.itemAttack(item, unit,
                                                           GameBattleSelection.instance.SelectionUnits, dir, GameBattleAttackResultSide.Right, onItemOver);

                GameBattleUnitItemSelection.instance.unShow();

                GameBattleCursor.instance.unShow();
            }
            break;

            case GameBattleUnitActionItemMode.Give:
            {
                GameBattleUnit unit2 = GameBattleUnitManager.instance.getUnit(x, y);

                if (unit2 == null)
                {
                    return;
                }

                if (!unit2.IsUser)
                {
                    return;
                }

                if (!unit2.canAddItem())
                {
                    // item full

                    return;
                }

                unit.giveItem(itemSlot, unit2);

                GameBattleUnitItemSelection.instance.unShow();

//                        GameBattleCursor.instance.show();

                unit.action();

                GameBattleSelection.instance.clearSelection();
            }
            break;
            }

            return;
        }

        if (cancel)
        {
            cancel = false;

            GameBattleUnitActionUI.instance.show();
            GameBattleUnitActionUI.instance.enable(true);
            GameBattleUnitActionUI.instance.showFade();

            GameBattleUnit unit = GameBattleSelection.instance.SelectionUnit;

            GameBattleUnitItemSelection.instance.unShow();

            GameBattleCursor.instance.moveTo(unit.PosX, unit.PosY, true);
            GameBattleCursor.instance.unShow();

            return;
        }
    }
Exemplo n.º 2
0
    public void checkMapEvent(GameBattleUnit unit, OnEventOver over)
    {
        onEventOver = over;

        GameBattleDTL.Point point = getPoint(unit.PosX, unit.PosY);

        if (!mapEvent.ContainsKey(point.MapEvent))
        {
            onCheckMapEvent();
            return;
        }

        GameBattleMEVT evt = mapEvent[point.MapEvent];

        switch (evt.EventType)
        {
        case GameBattleMapEventType.Event:
        {
            switch (evt.EventParm1)
            {
            // what ghost !?

            case 0:
                break;

            case 1:
                break;

            case 2:
                break;

            case 3:
                onCheckMapEvent();
                return;

            case 4:
                if (GameUserData.instance.Stage == 31)
                {
                    // fix stage 30 bug. so many bugs.

                    if (GameUserData.instance.getGameData(10) == 0)
                    {
                        onCheckMapEvent();
                        return;
                    }

                    if (unit.UnitID > 1)
                    {
                        onCheckMapEvent();
                        return;
                    }

                    if (unit.UnitID == 0 && unit.WeaponID != 14)
                    {
                        onCheckMapEvent();
                        return;
                    }

                    if (unit.UnitID == 0 && GameUserData.instance.Proficiency < 25 - PlayerPrefs.GetInt("review", 0))
                    {
                        onCheckMapEvent();
                        return;
                    }

                    if (unit.UnitID == 1 && unit.BattleAIType == GameBattleAIType.None)
                    {
                        onCheckMapEvent();
                        return;
                    }
                }
                break;

            case 5:
                onCheckMapEvent();
                return;

            case 6:
                break;
            }

            GameUserData.instance.setGameData((int)GameUserDataType.MapEvent6, unit.BattleManID);

            GameBattleEventManager.instance.showEvent(evt.EventParm2, 0, onCheckMapEvent);
        }
        break;

        case GameBattleMapEventType.Item:
        {
            switch (evt.ItemGetType)
            {
            case GameBattleMapEventType.Item:
            {
                if (unit.canAddItem())
                {
                    unit.addItem(evt.ItemGetParm1);
                }
                else
                {
                    GameUserData.instance.addItem(evt.ItemGetParm1);
                }

                GameBattleGetItemUI.instance.show(evt.ItemGetParm1, 0, null);
                onCheckMapEvent();
            }
            break;

            case GameBattleMapEventType.Gold:
            {
                GameUserData.instance.addGold(evt.ItemGetParm1);

                GameBattleGetItemUI.instance.show(GameDefine.INVALID_ID, evt.ItemGetParm1, null);
                onCheckMapEvent();
            }
            break;
            }

            mapEvent.Remove(point.MapEvent);
        }
        break;
        }



        for (int i = 0; i < transTreasures.childCount; ++i)
        {
            if (transTreasures.GetChild(i).gameObject.name == point.MapEvent.ToString())
            {
                Destroy(transTreasures.transform.GetChild(i).gameObject);
            }
        }

        //         clearTreasures();
        //         updateTreasures();
    }