Exemplo n.º 1
0
    /// <summary>
    /// 修养协程
    /// </summary>
    /// <returns></returns>
    private IEnumerator useRest()
    {
        //开始选择兵种控制器

        //isNeedGetArmyCtrl = true;
        if (selectOrderCardCtrl == null)
        {
            Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "请先选择指令卡");
            yield break;
        }
        if (selectArmyCtrl == null)
        {
            //yield return new WaitUntil(isGetArmyCtrl);
            Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "请先选择使用单位");
            yield break;

            /*if (selectOrderCardCtrl == null)
             * {
             *  yield break;
             * }*/
        }


        /*if (isSelectMulArmy && SelectUseArmy())
         * {
         *  //如果有两个单位
         *  isSelectMulArmy = false;
         *  isContinueProcessID = 1;
         *  yield break;
         * }*/

        if (selectArmyCtrl.armyState.Hp >= selectArmyCtrl.armyState.MaxHp)
        {
            Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "已达到血量上限");
            //isNeedGetArmyCtrl = false;
            selectArmyCtrl      = null;
            selectOrderCardCtrl = null;
            yield break;
        }

        foreach (var item in myArmyCtrlManager.CardCtrllist)
        {
            if (item.armyState.Name == selectArmyCtrl.armyState.Name && item.ArmymapPointCtrl == selectArmyCtrl.ArmymapPointCtrl)
            {
                //血量加一
                item.armyState.Hp++;
                //发送消息给其他人
                if (item.armyState.MoveType == ArmyMoveType.SKY)
                {
                    //如果是飞行单位
                    mapPointDto.Change(item.armyState.Position, -1, -1, item.armyState.Race, item.armyState.Name);
                }
                else
                {
                    //如果是陆地单位
                    mapPointDto.Change(item.armyState.Position, item.armyState.Race, item.armyState.Name, -1, -1);
                }
                socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_REST_CREQ, mapPointDto);
                Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);
                Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "回复血量成功");
                break;
            }
        }
        //移除修养卡牌
        Dispatch(AreoCode.CHARACTER, CharacterEvent.REMOVE_MY_CARDS, selectOrderCardCtrl.cardDto);
        //状态重置
        //isNeedGetArmyCtrl = false;
        selectArmyCtrl      = null;
        selectOrderCardCtrl = null;
        //isSelectMulArmy = true;
        //isContinueProcessID = -1;
        //Dispatch(AreoCode.UI, UIEvent.CLOSE_ARMY_MENU_PANEL, "关闭面板");
    }
Exemplo n.º 2
0
    /// <summary>
    /// 地图上设置兵种
    /// </summary>
    private void Build()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (!EventSystem.current.IsPointerOverGameObject())
            {
                //没有点在UI上
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                /*bool hasArmy = Physics.Raycast(ray, out hit, 1000, LayerMask.GetMask("MyArmy"));
                 * Queue<Collider> colliders = new Queue<Collider>();
                 * while (hasArmy)
                 * {
                 *  Collider collider = hit.collider.GetComponent<Collider>();
                 *  collider.enabled = false;
                 *  colliders.Enqueue(collider);
                 *  hasArmy = Physics.Raycast(ray, out hit, 1000, LayerMask.GetMask("MapPoint"));
                 * }*/

                bool isCollider = Physics.Raycast(ray, out hit, 1000, LayerMask.GetMask("MapPoint"));
                if (isCollider)
                {
                    turnDelegate.Invoke(ref TurnCount);//获取回合数
                    MapPointCtrl mapPointCtrl = hit.collider.GetComponent <MapPointCtrl>();
                    if (selectArmyCard != null && armyPrefab != null)
                    {
                        if (selectArmyCard.Class == ArmyClassType.Hero && hit.collider.tag != "BossStart")
                        {
                            //如果是英雄单位只能箭头处
                            Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "英雄单位只能箭头处");
                            return;
                        }
                        else if (selectArmyCard.Class != ArmyClassType.Hero && hit.collider.tag == "BossStart")
                        {
                            Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "非英雄单位不能箭头处");
                            return;
                        }

                        if (TurnCount <= 1)
                        {
                            if (hit.collider.tag != "StartAreo" && hit.collider.tag != "Winline" && hit.collider.tag != "BossStart")
                            {
                                //如果第一回合不在屯兵区放置
                                Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "初始阶段只能后三排");
                                return;
                            }
                        }
                        else
                        {
                            if (hit.collider.tag != "StartAreo" && hit.collider.tag != "Winline" && hit.collider.tag != "BossStart" && hit.collider.tag != "FeatureArea")
                            {
                                Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "只能放置在后五排");
                                return;
                            }
                        }

                        switch (selectArmyCard.MoveType)
                        {
                        case ArmyMoveType.LAND:    //陆地单位
                            if (mapPointCtrl.HasLandArmy())
                            {
                                Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "此处已有陆地单位");
                                return;
                            }
                            //放置陆地单位
                            GameObject army;
                            army = mapPointCtrl.SetLandArmy(armyPrefab, true);
                            mapPointCtrl.LandArmyRace = selectArmyCard.Race;
                            mapPointCtrl.LandArmyName = selectArmyCard.Name;
                            //向我的兵种控制器集合添加兵种管理器
                            ArmyCtrl armyctrl = army.GetComponent <ArmyCtrl>();

                            armyctrl.Init(selectArmyCard, mapPointCtrl, army);
                            armyctrl.armyState.MoveType = (ushort)selectArmyCard.MoveType;
                            //更新地图点控制器
                            mapPointCtrl.UpdateLandArmy(army);
                            myArmyCtrls.Add(armyctrl);

                            //向发送发送出牌消息,让其他人消除卡牌
                            socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_ARMYCARD_CREQ, selectArmyCard);
                            Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);
                            //移除卡牌
                            Dispatch(AreoCode.CHARACTER, CharacterEvent.REMOVE_MY_CARDS, selectArmyCard);
                            //向服务器发送消息
                            pointDto.Change(mapPointCtrl.mapPoint, mapPointCtrl.LandArmyRace, mapPointCtrl.LandArmyName, mapPointCtrl.SkyArmyRace, mapPointCtrl.SkyArmyName);
                            socketMsg.Change(OpCode.FIGHT, FightCode.MAP_SET_ARMY_CREQ, pointDto);
                            Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);
                            //向发送发送出牌消息,让其他人消除卡牌
                            //socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_CARD_CREQ, "出牌请求");
                            //socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_ARMYCARD_CREQ, selectArmyCard);
                            //Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);
                            break;

                        case ArmyMoveType.SKY:
                            if (mapPointCtrl.HasSkyArmy())
                            {
                                Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "此处已有飞行单位");
                                return;
                            }
                            //放置飞行单位
                            army = mapPointCtrl.SetSkyArmy(armyPrefab, true);
                            //mapPointCtrl.SkyArmyCard = selectArmyCard;
                            mapPointCtrl.SkyArmyRace = selectArmyCard.Race;
                            mapPointCtrl.SkyArmyName = selectArmyCard.Name;

                            //向我的兵种控制器集合添加兵种管理器
                            armyctrl = army.GetComponent <ArmyCtrl>();

                            armyctrl.Init(selectArmyCard, mapPointCtrl, army);
                            armyctrl.armyState.MoveType = (ushort)selectArmyCard.MoveType;
                            //更新地图点控制器
                            mapPointCtrl.UpdateSkyArmy(army);
                            myArmyCtrls.Add(armyctrl);

                            //向发送发送出牌消息,让其他人消除卡牌
                            socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_ARMYCARD_CREQ, selectArmyCard);
                            Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);
                            //移除卡牌
                            Dispatch(AreoCode.CHARACTER, CharacterEvent.REMOVE_MY_CARDS, selectArmyCard);
                            //向服务器发送消息
                            pointDto.Change(mapPointCtrl.mapPoint, mapPointCtrl.LandArmyRace, mapPointCtrl.LandArmyName, mapPointCtrl.SkyArmyRace, mapPointCtrl.SkyArmyName);
                            socketMsg.Change(OpCode.FIGHT, FightCode.MAP_SET_ARMY_CREQ, pointDto);
                            Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);

                            /*//向发送发送出牌消息,让其他人消除卡牌
                             * socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_ARMYCARD_CREQ, selectArmyCard);
                             * Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);*/

                            break;
                        }

                        /*while(colliders.Count != 0)
                         * {
                         *  colliders.Dequeue().enabled = true;
                         * }*/
                        foreach (var item in MyArmyCtrlManager.Instance.CardCtrllist)
                        {
                            item.canBeSeletced = true;//所有单位可交互
                        }
                    }
                }
            }
        }
    }