예제 #1
0
 // Start is called before the first frame update
 void Start()
 {
     Bind(ArmyEvent.SET_MY_LAND_SKY);
     //ArmyPrefab = gameObject;
     socketMsg = new SocketMsg();
     attackDto = new MapAttackDto();
 }
예제 #2
0
    /// <summary>
    /// 获取防御和攻击兵种的信息
    /// </summary>
    private void getArmy(out ArmyCtrl defenseCtrl, out OtherArmyCtrl attackCtrl, MapAttackDto mapAttackDto)
    {
        //镜像对称
        int totalX = 12;
        int totalZ = 8;

        MapPoint     attackpoint      = new MapPoint(totalX - mapAttackDto.AttacklMapPoint.X, totalZ - mapAttackDto.AttacklMapPoint.Z);
        MapPoint     defensepoint     = new MapPoint(totalX - mapAttackDto.DefenseMapPoint.X, totalZ - mapAttackDto.DefenseMapPoint.Z);;
        int          attackmovetype   = mapAttackDto.AttackMoveType;
        int          defensemovetype  = mapAttackDto.DefenseMoveType;
        MapPointCtrl attackPointCtrl  = null;
        MapPointCtrl defensePointCtrl = null;

        //OtherArmyCtrl attackCtrl;
        //ArmyCtrl defenseCtrl;

        foreach (var item in MapManager.mapPointCtrls)
        {
            if (item.mapPoint.X == attackpoint.X && item.mapPoint.Z == attackpoint.Z)
            {
                attackPointCtrl = item;
            }
            else if (item.mapPoint.X == defensepoint.X && item.mapPoint.Z == defensepoint.Z)
            {
                defensePointCtrl = item;
            }

            if (attackPointCtrl != null && defensePointCtrl != null)
            {
                break;
            }
        }

        if (attackmovetype == ArmyMoveType.LAND && attackPointCtrl.LandArmy != null)
        {
            attackCtrl = attackPointCtrl.LandArmy.GetComponent <OtherArmyCtrl>();
        }
        else if (attackmovetype == ArmyMoveType.SKY && attackPointCtrl.SkyArmy != null)
        {
            attackCtrl = attackPointCtrl.SkyArmy.GetComponent <OtherArmyCtrl>();
        }
        else
        {
            attackCtrl = null;
        }

        if (defensemovetype == ArmyMoveType.LAND && defensePointCtrl.LandArmy != null)
        {
            defenseCtrl = defensePointCtrl.LandArmy.GetComponent <ArmyCtrl>();
        }
        else if (defensemovetype == ArmyMoveType.SKY && defensePointCtrl.SkyArmy != null)
        {
            defenseCtrl = defensePointCtrl.SkyArmy.GetComponent <ArmyCtrl>();
        }
        else
        {
            defenseCtrl = null;
        }
    }
예제 #3
0
        /// <summary>
        /// 处理兵种攻击请求
        /// </summary>
        private void processArmyAttack(ClientPeer clientPeer, MapAttackDto mapAttackDto)
        {
            SingleExecute.Instance.processSingle(
                () =>
            {
                if (!UserCache.Instance.IsOnline(clientPeer))
                {
                    return;
                }

                int uid             = UserCache.Instance.GetId(clientPeer);
                FightRoom fightRoom = FightRoomCache.Instance.GetRoomByUid(uid);
                fightRoom.Broadcast(OpCode.FIGHT, FightCode.ARMY_ATTACK_SBOD, mapAttackDto, clientPeer);
                //向房间内其他人发送攻击请求
            }
                );
        }
예제 #4
0
 /// <summary>
 /// 处理其他人兵种攻击自己兵种的请求
 /// </summary>
 private void processArmyAttack(MapAttackDto mapAttackDto)
 {
     Dispatch(AreoCode.CHARACTER, CharacterEvent.INQUIRY_DEAL_DODGE, mapAttackDto);
 }
예제 #5
0
    /// <summary>
    /// 询问是我方否出闪避
    /// </summary>
    private void pcoessdealDodge(MapAttackDto mapAttackDto)
    {
        if (mapAttackDto == null)
        {
            socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_DODGE_CREQ, false);
            Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);
            return;
        }

        bool hasDodge = false;//手牌中是否有闪避

        dodgeCardctrl = hasCardType(CardType.ORDERCARD, OrderCardType.DODGE);
        if (dodgeCardctrl != null)
        {
            hasDodge = true;
        }
        else
        {
            hasDodge = false;
        }

        //获取攻击和防御的兵种
        getArmy(out defenseCtrl, out attackCtrl, mapAttackDto);

        if (defenseCtrl == null || attackCtrl == null)
        {
            //发送消息
            socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_DODGE_CREQ, false);
            Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);
            return;
        }


        //如果没有闪避或是普通兵种直接减血
        if (!hasDodge || defenseCtrl.armyState.Class == ArmyClassType.Ordinary)
        {
            defenseCtrl.armyState.Hp -= attackCtrl.armyState.Damage;
            //发送消息
            socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_DODGE_CREQ, false);
            Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);
            //关闭箭头
            //Dispatch(AreoCode.UI, UIEvent.CLOSE_ATTACK_ARROW, "关闭箭头");
            //关闭隐藏面板
            //Dispatch(AreoCode.UI, UIEvent.CLOSE_HIDE_PLANE, "关闭隐藏面板");
            //发送提示
            Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "我方(" + defenseCtrl.armyState.Position.X + "," + defenseCtrl.armyState.Position.Z + ")" + "单位被攻击");

            if (defenseCtrl.armyState.Race == RaceType.ORC &&
                defenseCtrl.armyState.Name == OrcArmyCardType.Pangolin)
            {
                Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "穿山甲发动反击背刺");
                //如果是兽族穿山甲
                attackCtrl.armyState.Hp--;//受到技能伤害
                SkillDto skillDto = new SkillDto(defenseCtrl.armyState.Race, defenseCtrl.armyState.Name
                                                 , attackCtrl.armyState.Name, attackCtrl.armyState.Position);

                socketMsg.Change(OpCode.FIGHT, FightCode.ARMY_USE_SKILL_CREQ, skillDto);
                Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);
            }


            if (defenseCtrl.armyState.Class == ArmyClassType.Ordinary)
            {
                //发送反击消息
                socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_BACKATTACK_CREQ, false);
                Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);
                return;//普通兵种不能反击
            }

            //其他阶级兵种可以反击
            backAttackCardCtrl = hasCardType(CardType.ORDERCARD, OrderCardType.BACKATTACK);
            if (backAttackCardCtrl != null && defenseCtrl.armyState.Hp > 0)
            {
                //反击
                Dispatch(AreoCode.UI, UIEvent.SHOW_HIDE_PLANE, "显示遮挡平面");
                Dispatch(AreoCode.UI, UIEvent.SHOW_DEAL_BACKATTACK_PANEL, "你的单位在敌人的攻击中存活下来了,是否进行反击?");
            }
            else//不反击
            {
                //关闭箭头
                Dispatch(AreoCode.UI, UIEvent.CLOSE_ATTACK_ARROW, "关闭箭头");
                //关闭隐藏面板
                Dispatch(AreoCode.UI, UIEvent.CLOSE_HIDE_PLANE, "关闭隐藏面板");
                //发送反击消息
                socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_BACKATTACK_CREQ, false);
                Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg);

                defenseCtrl = null;
                attackCtrl  = null;

                Dispatch(AreoCode.UI, UIEvent.SHOW_HIDE_PLANE, "显示遮挡面板");
                Dispatch(AreoCode.UI, UIEvent.SHOW_WAIT_PANEL, "");
            }
            return;
        }


        //有闪避且被攻击单位为非普通阶级单位
        //显示箭头
        Vector3 pos = new Vector3(defenseCtrl.armyState.Position.X, 1, defenseCtrl.armyState.Position.Z);

        Dispatch(AreoCode.UI, UIEvent.SHOW_ATTACK_ARROW, pos);
        //显示出闪避面板
        string str = "";

        if (defenseCtrl.armyState.MoveType == ArmyMoveType.SKY)
        {
            str = "我方位于箭头所指处的飞行单位被攻击,是否进行闪避?";
        }
        else if (defenseCtrl.armyState.MoveType == ArmyMoveType.LAND)
        {
            str = "我方位于箭头所指处的陆地单位被攻击,是否进行闪避?";
        }

        Dispatch(AreoCode.UI, UIEvent.SHOW_DEAL_DODGE_PANEL, str);
        Dispatch(AreoCode.UI, UIEvent.SHOW_HIDE_PLANE, "显示遮挡平面");
    }