Exemplo n.º 1
0
    public void UpdateEnterBattlePopupMsg(Model_Formation.RESULT result)
    {
        string path = "profab/ui/public/TextPromptPanel";

        string msg = "";

        switch (result)
        {
        case Model_Formation.RESULT.SUCCESS:
            msg = "成功";
            break;

        case Model_Formation.RESULT.SAME:
            msg = "队伍中已经包含该类型Unit";
            break;

        case Model_Formation.RESULT.LACK:
            msg = "可战斗unit不足";
            break;

        case Model_Formation.RESULT.MAX:
            msg = "达到最大战斗数";
            break;
        }

        // 弹出提示
        UIHelper.ShowTextPromptPanel(battlePanel.gameObject,msg);
    }
Exemplo n.º 2
0
    // 从scrollView中 上阵 slot中包含item
    public Model_Formation.RESULT EnterExchangeBattleFormation(Model_UnitGroup model_UnitGroup)
    {
        Model_Formation.RESULT reslut = Model_Formation.RESULT.SUCCESS;

        FormationScrollViewItemUI scViewItem = this.GetComponent <FormationScrollViewItemUI>();
        int unitId      = scViewItem.unitId;
        int battleCount = 0;

        Model_Unit model_Unit;

        InstancePlayer.instance.model_User.unlockUnits.TryGetValue(unitId,out model_Unit);
        if (model_Unit != null)
        {
            battleCount = Mathf.Min(model_Unit.num,model_UnitGroup.maxNum);
        }

        Model_UnitGroup new_UnitGroup = new Model_UnitGroup();

        new_UnitGroup.unitId = unitId;
        new_UnitGroup.num    = battleCount;
        new_UnitGroup.teamId = model_UnitGroup.teamId;
        new_UnitGroup.posId  = model_UnitGroup.posId;

        reslut = battlePanel.model_Formation.AddExchange(new_UnitGroup,model_UnitGroup);

        return(reslut);
    }
Exemplo n.º 3
0
    // 下阵Hero
    public Model_Formation.RESULT ExitBattleHero()
    {
        Model_Formation.RESULT result = Model_Formation.RESULT.SUCCESS;

        Model_UnitGroup model_UnitGroup = attachSlotUI.model_UnitGroup;

        _heroPanel._battleFormationPanel.model_Formation.RemoveHero(model_UnitGroup);

        return(result);
    }
Exemplo n.º 4
0
    // 交换Hero
    public Model_Formation.RESULT ExchangeBattleHero(Model_UnitGroup target)
    {
        Model_Formation.RESULT result = Model_Formation.RESULT.SUCCESS;

        Model_UnitGroup source = attachSlotUI.model_UnitGroup;

        result = _heroPanel._battleFormationPanel.model_Formation.ExchangeHero(source,target);

        return(result);
    }
Exemplo n.º 5
0
    // 交换Unit
    public Model_Formation.RESULT ExchageFormation(Model_UnitGroup target)
    {
        Model_Formation.RESULT result = Model_Formation.RESULT.SUCCESS;

        Model_UnitGroup source = attachSlotUI.model_UnitGroup;

        result = battlePanel.model_Formation.Exchange(source,target);


        return(result);
    }
Exemplo n.º 6
0
    // 从scrollView中 上阵Hero
    public Model_Formation.RESULT EnterBattleHero(Model_UnitGroup model_UnitGroup)
    {
        Model_Formation.RESULT result = Model_Formation.RESULT.SUCCESS;

        UIHeroBodyItem bodyItem = this.GetComponent <UIHeroBodyItem>();
        int            heroId   = bodyItem.heroId;

        Model_UnitGroup new_UnitGroup = new Model_UnitGroup();

        new_UnitGroup.teamId = model_UnitGroup.teamId;
        new_UnitGroup.posId  = model_UnitGroup.posId;
        new_UnitGroup.heroId = heroId;

        result = _heroPanel._battleFormationPanel.model_Formation.AddHero(new_UnitGroup);

        return(result);
    }
Exemplo n.º 7
0
    public void UpdateErrorPopupMsg(Model_Formation.RESULT result)
    {
        string path = "profab/ui/public/TextPromptPanel";

        string msg = "";

        switch (result)
        {
        case Model_Formation.RESULT.SUCCESS:
            msg = "成功";
            break;

        case Model_Formation.RESULT.SAME_HERO:
            msg = "队伍中已经包含该类型Hero";
            break;
        }

        // 弹出提示
        UIHelper.ShowTextPromptPanel(_heroPanel.gameObject,msg);
    }
Exemplo n.º 8
0
    // 一键补兵
    public void OnReplenish()
    {
        int teamId = model_Formation.GetSelectTeamId();

        Model_Formation.RESULT result = model_Formation.TeamReplenish(teamId);

        if (result != Model_Formation.RESULT.SUCCESS)
        {
            string msg = "没有可战斗Unit";
            UIHelper.ShowTextPromptPanel(this.gameObject, msg);
        }
        else
        {
            slotUIManager.UpdateUnitSlotUI(teamId);

            if (_state == STATE.UNIT)
            {
                UpdateCurrectUnitList();
            }
        }
    }
Exemplo n.º 9
0
    protected override void OnDragDropRelease(GameObject surface)
    {
        SetBoxColliderEnabled();
        ResetTeamSlotItemUI();

        if (surface != null)
        {
            switch (state)
            {
            case STATE.SCROLLVIEW:
            {
                // scrollView 移动空slot
                FormationSlotUI surfaceSlotUI = surface.GetComponent <FormationSlotUI>();
                if (surfaceSlotUI != null && surfaceSlotUI.model_UnitGroup.isEmpty)
                {
                    Model_UnitGroup model_UnitGroup = surfaceSlotUI.model_UnitGroup;

                    //上阵
                    Model_Formation.RESULT result = EnterBattleFormation(model_UnitGroup);
                    if (result == Model_Formation.RESULT.SUCCESS)
                    {
                        this.transform.position = surface.transform.position;
                        attachSlotUI            = surfaceSlotUI;
                        state = STATE.SLOT;
                        surfaceSlotUI.dragItemUI = gameObject.GetComponent <FormationDragItemUI>();
                        this.GetComponent <FormationSlotItemUI>().UpdateUI(model_UnitGroup);

                        // 首次进入 上阵Unit 如果teamId = 0 强制修改为1
                        int teamId = InstancePlayer.instance.model_User.model_Formation.GetSelectTeamId();
                        if (teamId == 0)
                        {
                            InstancePlayer.instance.model_User.model_Formation.SetSelectTeamId(1);
                        }

                        // 更新scrollView列表
                        UpdateUnitScrollView();

                        // 播放粒子特效
                        StartCoroutine(PlayEffect(this.gameObject));
                    }
                    else
                    {
                        base.OnDragDropRelease(surface);
                        UpdateEnterBattlePopupMsg(result);
                    }
                    return;
                }

                // scrollView 移动到包含 item slot
                FormationDragItemUI dragItemUI = surface.GetComponent <FormationDragItemUI>();
                if (dragItemUI != null && dragItemUI.attachSlotUI != null)
                {
                    FormationSlotUI slotUI          = dragItemUI.attachSlotUI;
                    Model_UnitGroup model_UnitGroup = slotUI.model_UnitGroup;

                    Model_Formation.RESULT result = EnterExchangeBattleFormation(model_UnitGroup);
                    if (result == Model_Formation.RESULT.SUCCESS)
                    {
                        dragItemUI.GetComponent <FormationSlotItemUI>().UpdateUI(model_UnitGroup);

                        // 替换spine tankicon
                        dragItemUI.ReplaceTankIcon();

                        // 更新scrollView列表
                        UpdateUnitScrollView();

                        // 播放粒子特效
                        StartCoroutine(PlayEffect(dragItemUI.gameObject));
                    }
                    else
                    {
                        UpdateEnterBattlePopupMsg(result);
                    }

                    // 删除当前拖动 GameObject
                    base.OnDragDropRelease(surface);
                    return;
                }
            }
            break;

            case STATE.SLOT:

                /*
                 * 1 移动另一个slot
                 *   (1) slot 区域没有item
                 *   (2) slot 区域有item
                 * 2 移动到scrollView
                 * 3 移动到空白区
                 */

                // 1 移动另一个slot
                // (1)slot区域没有item
            {
                FormationSlotUI surfaceSlotUI = surface.GetComponent <FormationSlotUI>();
                if (surfaceSlotUI != null && surfaceSlotUI.model_UnitGroup.isEmpty)
                {
                    Model_Formation.RESULT result = ExchageFormation(surfaceSlotUI.model_UnitGroup);
                    if (result == Model_Formation.RESULT.SUCCESS)
                    {
                        this.transform.position = surfaceSlotUI.transform.position;

                        this.attachSlotUI.dragItemUI = null;
                        this.attachSlotUI            = surfaceSlotUI;
                        this.attachSlotUI.dragItemUI = this.GetComponent <FormationDragItemUI>();

                        this.GetComponent <FormationSlotItemUI>().UpdateUI(surfaceSlotUI.model_UnitGroup);

                        // 播放粒子特效
                        StartCoroutine(PlayEffect(this.gameObject));
                    }
                    else
                    {
                        base.OnDragDropRelease(surface);
                    }
                    UpdateUnitScrollView();

                    return;
                }
            }

                // (2) slot区域有item
                {
                    FormationDragItemUI surfaceDragItemUI = surface.GetComponent <FormationDragItemUI>();

                    if (surfaceDragItemUI != null && surfaceDragItemUI.attachSlotUI != null)
                    {
                        FormationSlotUI surfaceSlotUI = surfaceDragItemUI.attachSlotUI;

                        Model_Formation.RESULT result = ExchageFormation(surfaceSlotUI.model_UnitGroup);
                        if (result == Model_Formation.RESULT.SUCCESS)
                        {
                            // 更显UI显示数据
                            FormationSlotUI     sourceSlotUI = this.attachSlotUI;
                            FormationDragItemUI sourceDragUI = this.GetComponent <FormationDragItemUI>();

                            FormationSlotUI     targetSlotUI = surfaceDragItemUI.attachSlotUI;
                            FormationDragItemUI targetDragUI = surfaceDragItemUI;

                            FormationSlotItemUI sourceSlotItemUI = sourceDragUI.gameObject.GetComponent <FormationSlotItemUI>();
                            FormationSlotItemUI targetSlotItemUI = targetDragUI.gameObject.GetComponent <FormationSlotItemUI>();

                            Model_UnitGroup source = attachSlotUI.model_UnitGroup;
                            Model_UnitGroup target = targetSlotUI.model_UnitGroup;

                            sourceSlotItemUI.UpdateUI(source);
                            targetSlotItemUI.UpdateUI(target);

                            this.transform.position = sourceSlotUI.transform.position;

                            // 交换 spine tank icon
                            surfaceDragItemUI.ReplaceTankIcon();
                            sourceDragUI.ReplaceTankIcon();

                            // 播放粒子特效
                            StartCoroutine(PlayEffect(sourceSlotItemUI.gameObject));
                            StartCoroutine(PlayEffect(targetSlotItemUI.gameObject));
                        }
                        else
                        {
                            base.OnDragDropRelease(surface);
                        }
                        UpdateUnitScrollView();

                        return;
                    }
                }

                // 2 移动到scrollView 下阵
                {
                    FormationDragItemUI surfaceDragItemUI = surface.GetComponent <FormationDragItemUI>();
                    bool isScrllViewCollider = surface.gameObject.name.Equals("scrollView_bg_unit");

                    if ((surfaceDragItemUI != null && surfaceDragItemUI.attachSlotUI == null) ||
                        isScrllViewCollider)
                    {
                        ExitBattleFormation();

                        attachSlotUI.dragItemUI = null;
                        UpdateUnitScrollView();
                        DestroyImmediate(this.gameObject);
                        return;
                    }
                }

                // 拖动到其他区域
                if (attachSlotUI != null)
                {
                    this.transform.position = attachSlotUI.transform.position;
                    StartCoroutine(PlayEffect(this.gameObject));

                    return;
                }

                break;
            }
        }
        base.OnDragDropRelease(surface);
    }
Exemplo n.º 10
0
    protected override void OnDragDropRelease(GameObject surface)
    {
        SetBoxColliderEnabled();
        ResetTeamSlotItemUI();

        if (surface != null)
        {
            switch (state)
            {
            case STATE.SCROLLVIEW:
            {
                // scrollView 移动空slot
                UIHeroSlot surfaceSlotUI = surface.GetComponent <UIHeroSlot>();
                if (surfaceSlotUI != null && !surfaceSlotUI.model_UnitGroup.HasHero())
                {
                    Model_UnitGroup model_UnitGroup = surfaceSlotUI.model_UnitGroup;

                    //上阵
                    Model_Formation.RESULT result = EnterBattleHero(model_UnitGroup);

                    if (result == Model_Formation.RESULT.SUCCESS)
                    {
                        this.transform.position = surface.transform.position;
                        attachSlotUI            = surfaceSlotUI;
                        state = STATE.SLOT;
                        surfaceSlotUI.dragItemUI = this;

                        // 更新上阵Unit显示数量
                        _slotUIManager.UpdateBattleUnitNum(model_UnitGroup);

                        // 更新scrollView列表
                        UpdateHeroScrollView();

                        // 更新Unit列表
                        _heroPanel._battleFormationPanel.UpdateCurrectUnitList();
                    }
                    else
                    {
                        base.OnDragDropRelease(surface);
                        UpdateErrorPopupMsg(result);
                    }
                    return;
                }

//					// scrollView 移动到包含 item slot
                UIHeroDragItem dragItemUI = surface.GetComponent <UIHeroDragItem>();
                if (dragItemUI != null && dragItemUI.attachSlotUI != null)
                {
                    UIHeroSlot      slotUI          = dragItemUI.attachSlotUI;
                    Model_UnitGroup model_UnitGroup = slotUI.model_UnitGroup;

                    Model_Formation.RESULT result = EnterBattleHero(model_UnitGroup);
                    if (result == Model_Formation.RESULT.SUCCESS)
                    {
                        dragItemUI.GetComponent <UIHeroHeadItem>().UpdateUI(model_UnitGroup.heroId);

                        // 更新上阵Unit显示数量
                        _slotUIManager.UpdateBattleUnitNum(model_UnitGroup);

                        // 更新scrollView列表
                        UpdateHeroScrollView();

                        // 更新Unit列表
                        _heroPanel._battleFormationPanel.UpdateCurrectUnitList();
                    }
                    else
                    {
                        UpdateErrorPopupMsg(result);
                    }

                    // 删除当前拖动 GameObject
                    base.OnDragDropRelease(surface);
                    return;
                }
            }
            break;

            case STATE.SLOT:

                /*
                 * 1 移动另一个slot
                 *   (1) slot 区域没有item
                 *   (2) slot 区域有item
                 * 2 移动到scrollView
                 * 3 移动到空白区
                 */

                // 1 移动另一个slot
                // (1)slot区域没有item
            {
                UIHeroSlot surfaceSlotUI = surface.GetComponent <UIHeroSlot>();
                if (surfaceSlotUI != null && !surfaceSlotUI.model_UnitGroup.HasHero())
                {
                    Model_Formation.RESULT result = ExchangeBattleHero(surfaceSlotUI.model_UnitGroup);
                    if (result == Model_Formation.RESULT.SUCCESS)
                    {
                        // 更新上阵Unit显示数量 交换之前更新
                        _slotUIManager.UpdateBattleUnitNum(surfaceSlotUI.model_UnitGroup);
                        _slotUIManager.UpdateBattleUnitNum(attachSlotUI.model_UnitGroup);

                        this.transform.position = surfaceSlotUI.transform.position;

                        this.attachSlotUI.dragItemUI = null;
                        this.attachSlotUI            = surfaceSlotUI;
                        this.attachSlotUI.dragItemUI = this;

                        this.GetComponent <UIHeroHeadItem>().UpdateUI(surfaceSlotUI.model_UnitGroup.heroId);

                        // 更新Unit列表
                        _heroPanel._battleFormationPanel.UpdateCurrectUnitList();
                    }
                    else
                    {
                        base.OnDragDropRelease(surface);
                    }

                    UpdateHeroScrollView();
                    return;
                }
            }

                // (2) slot区域有item
                {
                    UIHeroDragItem surfaceDragItemUI = surface.GetComponent <UIHeroDragItem>();

                    if (surfaceDragItemUI != null && surfaceDragItemUI.attachSlotUI != null)
                    {
                        UIHeroSlot surfaceSlotUI = surfaceDragItemUI.attachSlotUI;

                        Model_Formation.RESULT result = ExchangeBattleHero(surfaceSlotUI.model_UnitGroup);
                        if (result == Model_Formation.RESULT.SUCCESS)
                        {
                            // 更显UI显示数据
                            UIHeroSlot     sourceSlotUI = this.attachSlotUI;
                            UIHeroDragItem sourceDragUI = this;

                            UIHeroSlot     targetSlotUI = surfaceDragItemUI.attachSlotUI;
                            UIHeroDragItem targetDragUI = surfaceDragItemUI;

                            UIHeroHeadItem sourceSlotItemUI = sourceDragUI.gameObject.GetComponent <UIHeroHeadItem>();
                            UIHeroHeadItem targetSlotItemUI = targetDragUI.gameObject.GetComponent <UIHeroHeadItem>();

                            Model_UnitGroup source = attachSlotUI.model_UnitGroup;
                            Model_UnitGroup target = targetSlotUI.model_UnitGroup;

                            sourceSlotItemUI.UpdateUI(source.heroId);
                            targetSlotItemUI.UpdateUI(target.heroId);

                            this.transform.position = sourceSlotUI.transform.position;

                            // 更新上阵Unit显示数量
                            _slotUIManager.UpdateBattleUnitNum(source);
                            _slotUIManager.UpdateBattleUnitNum(target);

                            // 更新Unit列表
                            _heroPanel._battleFormationPanel.UpdateCurrectUnitList();
                        }
                        else
                        {
                            base.OnDragDropRelease(surface);
                        }

                        UpdateHeroScrollView();

                        return;
                    }
                }

                // 2 移动到scrollView 下阵
                {
                    UIHeroDragItem surfaceDragItemUI   = surface.GetComponent <UIHeroDragItem>();
                    bool           isScrllViewCollider = surface.gameObject.name.Equals("scrollView_bg_hero");

                    if ((surfaceDragItemUI != null && surfaceDragItemUI.attachSlotUI == null) ||
                        isScrllViewCollider)
                    {
                        ExitBattleHero();

                        attachSlotUI.dragItemUI = null;

                        UpdateHeroScrollView();

                        _slotUIManager.UpdateBattleUnitNum(attachSlotUI.model_UnitGroup);

                        DestroyImmediate(this.gameObject);
                        return;
                    }
                }

                // 拖动到其他区域
                if (attachSlotUI != null)
                {
                    this.transform.position = attachSlotUI.transform.position;
                    return;
                }

                break;
            }
        }
        base.OnDragDropRelease(surface);
    }