Ejemplo 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;
        }
    }