示例#1
0
    void updateItemUI()
    {
        if (!GameBattleItemUI.instance.IsShow)
        {
            return;
        }

        if (confirm)
        {
            confirm = false;

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

            GameBattleUnit unit = GameBattleSelection.instance.SelectionUnit;

            if (item == null)
            {
                return;
            }

            switch (GameBattleItemUI.instance.Mode)
            {
            case GameBattleUnitActionItemMode.Use:
            {
                GameBattleUnitItemSelection.instance.showUse(unit.PosX, unit.PosY, item, unit.UnitCampType, true);

                GameBattleCursor.instance.moveTo(GameBattleUnitItemSelection.instance.AttackCell.x,
                                                 GameBattleUnitItemSelection.instance.AttackCell.y,
                                                 GameBattleCursor.SpeedX / 2,
                                                 GameBattleCursor.SpeedY / 2,
                                                 true,
                                                 onCursorMoveOver, false);

                GameBattleItemUI.instance.unShowFade();

                GameBattleUnitActionItemUI.instance.unShowFade();
                GameBattleUnitActionUI.instance.unShowFade();
            }
            break;

            case GameBattleUnitActionItemMode.Give:
            {
                GameBattleUnitItemSelection.instance.showGive(unit.PosX, unit.PosY, GameDefine.INVALID_ID, 1, GameAttackRangeType.Circle, 0, unit.UnitCampType, true);

                GameBattleItemUI.instance.unShowFade();

                GameBattleUnitActionItemUI.instance.unShowFade();
                GameBattleUnitActionUI.instance.unShowFade();
            }
            break;

            case GameBattleUnitActionItemMode.Equip:
            {
                unit.equipItem(item);

                GameBattleItemUI.instance.setData(unit, GameBattleItemUI.instance.Mode);

                if (GameEquipInfoUI.instance.IsShow)
                {
                    GameEquipInfoUI.instance.unShowFade();
                }
            }
            break;

            case GameBattleUnitActionItemMode.Drop:
            {
                if (GameBattleItemUI.instance.IsShowAskUI)
                {
                    GameBattleItemUI.instance.unShowAskUI();

                    if (GameBattleItemUI.instance.IsOKAskUI)
                    {
                        // drop item

                        unit.removeItem(itemSlot);

                        GameBattleItemUI.instance.setData(unit, GameBattleItemUI.instance.Mode);
                    }
                }
                else
                {
                    GameBattleItemUI.instance.showAskUI();
                }
            }
            break;
            }

            return;
        }

        if (cancel)
        {
            cancel = false;

            if (GameBattleItemUI.instance.IsShowAskUI)
            {
                GameBattleItemUI.instance.unShowAskUI();
                return;
            }

            GameEquipInfoUI.instance.unShowFade();

            GameBattleItemUI.instance.unShowFade();

            GameBattleUnitActionItemUI.instance.show();
            GameBattleUnitActionItemUI.instance.showFade();

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

            return;
        }

        moveItemUI();
    }