/// <summary> /// 处理反击结果 /// </summary> /// <param name="active"></param> private void processBackAttackResult(bool active) { if (active)//如果选择了反击 { //减血 attackCtrl.armyState.Hp -= defenseCtrl.armyState.Damage; socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_BACKATTACK_CREQ, true); Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg); //移除反击手牌 Dispatch(AreoCode.CHARACTER, CharacterEvent.REMOVE_MY_CARDS, backAttackCardCtrl.cardDto); } else { socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_BACKATTACK_CREQ, false); Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg); } //关闭箭头 Dispatch(AreoCode.UI, UIEvent.CLOSE_ATTACK_ARROW, "关闭箭头"); //关闭隐藏面板 Dispatch(AreoCode.UI, UIEvent.CLOSE_HIDE_PLANE, "关闭隐藏面板"); defenseCtrl = null; attackCtrl = null; Dispatch(AreoCode.UI, UIEvent.SHOW_HIDE_PLANE, "显示遮挡面板"); Dispatch(AreoCode.UI, UIEvent.SHOW_WAIT_PANEL, "");//显示等待面板 }
private bool processOtherArmySelect(OtherArmyCtrl otherArmyCtrl) { if (otherArmyCtrl == null) { return(false); } if (LastSelectArmy == null) { //如果是第一次选择 otherArmyCtrl.isSelect = true; LastSelectArmy = otherArmyCtrl; return(true); } else if (LastSelectArmy != otherArmyCtrl) { //和上一次不相等 LastSelectArmy.isSelect = false; otherArmyCtrl.isSelect = true; LastSelectArmy = otherArmyCtrl; return(true); } else { //和上一次相等 LastSelectArmy.isSelect = false; LastSelectArmy = null; return(false); } }
private void processIsBackAttack(bool active) { if (active)//对方反击 { //自己掉血 armyCtrl.armyState.Hp -= defenseArmy.armyState.Damage; //提示消息 Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "对方反击了"); Dispatch(AreoCode.UI, UIEvent.CLOSE_WAIT_PANEL, "关闭等待面板"); Dispatch(AreoCode.UI, UIEvent.CLOSE_HIDE_PLANE, "关闭隐藏平面"); //移除卡牌 Dispatch(AreoCode.CHARACTER, CharacterEvent.REMOVE_OTHER_CARDS, "移除手牌"); //防御单位置空 defenseArmy = null; } else//对方不反击 { Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "对方没有反击"); Dispatch(AreoCode.UI, UIEvent.CLOSE_WAIT_PANEL, "关闭等待面板"); Dispatch(AreoCode.UI, UIEvent.CLOSE_HIDE_PLANE, "关闭隐藏平面"); //防御单位置空 defenseArmy = null; } }
/// <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; } }
/// <summary> /// 选择兵种协程 /// </summary> /// <returns></returns> private IEnumerator selectArmy() { yield return(new WaitUntil(isSelectArmyType)); if (SelectArmyType == ArmyMoveType.LAND) { //选择了陆地兵种 if (OtherMapPintctrl.LandArmy == null) { yield break; } OtherArmyCtrl armyCtrl = OtherMapPintctrl.LandArmy.GetComponent <OtherArmyCtrl>(); if (armyCtrl == null) { yield break; } if (ArmySelectDelegate.Invoke(armyCtrl) && iscanShowStatePanel) { //第一次或和上一次不一样 Dispatch(AreoCode.UI, UIEvent.SHOW_ARMY_STATE_PANEL, armyCtrl.armyState); } else if (iscanShowStatePanel) { //和上次一样 Dispatch(AreoCode.UI, UIEvent.SHOW_ARMY_STATE_PANEL, armyCtrl.armyState); } SelectArmyType = -1; } else { //如果选择了飞行单位 if (OtherMapPintctrl.SkyArmy == null) { yield break; } OtherArmyCtrl armyCtrl = OtherMapPintctrl.SkyArmy.GetComponent <OtherArmyCtrl>(); if (armyCtrl == null) { yield break; } if (ArmySelectDelegate.Invoke(armyCtrl) && iscanShowStatePanel) { //第一次或和上一次不一样 Dispatch(AreoCode.UI, UIEvent.SHOW_ARMY_STATE_PANEL, armyCtrl.armyState); } else if (iscanShowStatePanel) { //和上次一样 Dispatch(AreoCode.UI, UIEvent.SHOW_ARMY_STATE_PANEL, armyCtrl.armyState); } SelectArmyType = -1; } SelectArmyType = -1; }
/// <summary> /// 选择防御兵种 /// </summary> /// <returns></returns> private IEnumerator selectDenfenseArmy() { if (clickMapPointCtrl == null) { yield break; } if (armyCtrl.armyState.MoveType == ArmyMoveType.LAND && clickMapPointCtrl.LandArmy != null) { //如果攻击方是陆地单位 if (clickMapPointCtrl.LandArmy != armyCtrl.ArmyPrefab) { //如果攻击的不是自己 defenseArmy = clickMapPointCtrl.LandArmy.GetComponent <OtherArmyCtrl>(); } } else if (armyCtrl.armyState.MoveType == ArmyMoveType.SKY && clickMapPointCtrl != null && clickMapPointCtrl.LandArmy != null && clickMapPointCtrl.SkyArmy != null) { if (clickMapPointCtrl.SkyArmy != armyCtrl.ArmyPrefab) { //如果攻击方是飞行单位,且地图点上同时有陆地和飞行单位 MapPointCtrl mapPointCtrl = clickMapPointCtrl; Dispatch(AreoCode.UI, UIEvent.SHOW_SELECT_ATTACK_PANEL, true); yield return(new WaitUntil(isSetDefenseArmyType)); //打开面板后会清空选择的地图点控制器 clickMapPointCtrl = mapPointCtrl; if (defenseArmyType == ArmyMoveType.LAND) { defenseArmy = clickMapPointCtrl.LandArmy.GetComponent <OtherArmyCtrl>(); } else if (defenseArmyType == ArmyMoveType.SKY) { defenseArmy = clickMapPointCtrl.SkyArmy.GetComponent <OtherArmyCtrl>(); } defenseArmyType = -1; } } else if (armyCtrl.armyState.MoveType == ArmyMoveType.SKY && clickMapPointCtrl.LandArmy != null) { //如果攻击方位飞行单位,且地图点上只有陆地单位 if (armyCtrl.ArmyPrefab != clickMapPointCtrl.SkyArmy) { defenseArmy = clickMapPointCtrl.LandArmy.GetComponent <OtherArmyCtrl>(); } } else if (armyCtrl.armyState.MoveType == ArmyMoveType.SKY && clickMapPointCtrl.SkyArmy != null) { //如果攻击方位飞行单位,且地图点上只有飞行单位 if (armyCtrl.ArmyPrefab != clickMapPointCtrl.SkyArmy) { defenseArmy = clickMapPointCtrl.SkyArmy.GetComponent <OtherArmyCtrl>(); } } }
/// <summary> /// 处理添加单位 /// </summary> /// <param name="army"></param> private void processAddArmy(GameObject army) { OtherArmyCtrl otherArmyCtrl = army.gameObject.GetComponent <OtherArmyCtrl>(); //therArmyCtrl.Init(); otherArmyCtrl.ArmySelectDelegate = processOtherArmySelect; OtherArmyCtrlList.Add(otherArmyCtrl); ArmyList.Add(army); }
private IEnumerator EatOther() { eatArmyctrl = null; //isStartSelect = true; Dispatch(AreoCode.UI, UIEvent.CURSOR_SET_HEART, "治疗光标"); List <MapPoint> caneatPoints = MapAttackType.Instance.GetAttakRange(armyCtrl.armyState); List <MapPointCtrl> caneatMapCtrls = MapTools.getMapCtrlByMapPoint(caneatPoints); MapTools.setMappointCtrlColor(caneatMapCtrls, eatcolor); yield return(new WaitUntil(isSelecteateArmy)); bool caneat = false; foreach (var item in caneatMapCtrls) { if (eatArmyctrl.armyState.Position.X == item.mapPoint.X && eatArmyctrl.armyState.Position.Z == item.mapPoint.Z) { caneat = true; break; } } if (!caneat) { Dispatch(AreoCode.UI, UIEvent.CURSOR_SET_NORMAL, "正常光标"); Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "不在吞噬范围内"); MapTools.setMappointCtrlColor(caneatMapCtrls); eatArmyctrl = null; yield break; } if (eatArmyctrl.armyState.Class == ArmyClassType.HighClass || eatArmyctrl.armyState.Class == ArmyClassType.Hero) { Dispatch(AreoCode.UI, UIEvent.CURSOR_SET_NORMAL, "正常光标"); Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "无法吞噬髙阶或英雄单位"); MapTools.setMappointCtrlColor(caneatMapCtrls); eatArmyctrl = null; yield break; } eatArmyctrl.armyState.Hp = 0; Dispatch(AreoCode.UI, UIEvent.CURSOR_SET_NORMAL, "正常光标"); Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "吞噬成功"); Dispatch(AreoCode.UI, UIEvent.CLOSE_ARMY_MENU_PANEL, "关闭单位功能面板"); Dispatch(AreoCode.UI, UIEvent.SHOW_ARMY_MENU_PANEL, armyCtrl); isUsed = true; //给对方发送消息 MapPoint targetMappoint = eatArmyctrl.armyState.Position; skillDto.Change(armyCtrl.armyState.Race, armyCtrl.armyState.Name, eatArmyctrl.armyState.Name, targetMappoint); socketMsg.Change(OpCode.FIGHT, FightCode.ARMY_USE_SKILL_CREQ, skillDto); Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg); MapTools.setMappointCtrlColor(caneatMapCtrls); }
// Update is called once per frame void Update() { eatArmyctrl = getOtherArmyCtrlByMouse(); }
/// <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, "显示遮挡平面"); }
/// <summary> /// 处理出闪面板发来的消息 /// </summary> /// <param name="active"></param> private void processDodgeResult(bool active) { if (active)//出闪 { //移除手牌 Dispatch(AreoCode.CHARACTER, CharacterEvent.REMOVE_MY_CARDS, dodgeCardctrl.cardDto); //defenseCtrl = null; //attackCtrl = null; //发送消息 socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_DODGE_CREQ, true); Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg); //关闭箭头 //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); } else//不出闪 { //减血 defenseCtrl.armyState.Hp -= attackCtrl.armyState.Damage; //发送消息 socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_DODGE_CREQ, false); Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg); 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); } } //是否反击 backAttackCardCtrl = hasCardType(CardType.ORDERCARD, OrderCardType.BACKATTACK); if (backAttackCardCtrl != null && defenseCtrl.armyState.Hp > 0) { //反击 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, "对方回合"); } //defenseCtrl = null; //attackCtrl = null; }
/// <summary> /// 攻击飞行单位协程 /// </summary> /// <returns></returns> private IEnumerator AttackSky() { //选择要攻击的地图点 if (clickMapPointCtrl == null) { //refresh(); yield return(new WaitUntil(isclickMapPointCtrlnull)); attackState(); } //屏蔽查看属性 if (clickMapPointCtrl != null) { if (clickMapPointCtrl.LandArmy != null) { OtherArmyCtrl otherArmyCtrl = clickMapPointCtrl.LandArmy.GetComponent <OtherArmyCtrl>(); if (otherArmyCtrl != null) { otherArmyCtrl.iscanShowStatePanel = false; } } if (clickMapPointCtrl.SkyArmy != null) { OtherArmyCtrl otherArmyCtrl = clickMapPointCtrl.SkyArmy.GetComponent <OtherArmyCtrl>(); if (otherArmyCtrl != null) { otherArmyCtrl.iscanShowStatePanel = false; } } } if (clickMapPointCtrl.SkyArmy != null) { //如果攻击方的是陆地单位 if (clickMapPointCtrl.SkyArmy != armyCtrl.ArmyPrefab) { //如果攻击的不是自己 defenseArmy = clickMapPointCtrl.SkyArmy.GetComponent <OtherArmyCtrl>(); } } if (defenseArmy == null) { Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "攻击目标无效"); refresh(); yield break; } //调用Armyctrl攻击 if (!armyCtrl.Attack(defenseArmy.OtherMapPintctrl, defenseArmy)) { //如果不能攻击 refresh(); //防御单位置空 defenseArmy = null; yield break; } else { //显示等待面板 Dispatch(AreoCode.UI, UIEvent.SHOW_WAIT_PANEL, "等待对方是否闪避..."); Dispatch(AreoCode.UI, UIEvent.SHOW_HIDE_PLANE, "显示遮挡平面"); } Button_Attack_Land.interactable = false; Button_Attack_Sky.interactable = false; refresh(); //防御单位置空 //defenseArmy = null; }
/// <summary> /// 处理其他人的兵种移动 /// </summary> /// <param name="mapMoveDto"></param> private void processMoveOtherArmy(MapMoveDto mapMoveDto) { //镜像对称 int totalX = 12; int totalZ = 8; int Originalx = mapMoveDto.OriginalMapPoint.X; int Originalz = mapMoveDto.OriginalMapPoint.Z; int MoveX = mapMoveDto.MoveMapPoint.X; int MoveZ = mapMoveDto.MoveMapPoint.Z; int OtherOriginalx = totalX - Originalx; int OtherOriginalz = totalZ - Originalz;//对方兵种真实位置 int OtherMoveX = totalX - MoveX; int OtherMoveZ = totalZ - MoveZ; MapPointCtrl OriginalPointCtrl = null; MapPointCtrl MovePointCtrl = null; GameObject Army = null; OtherArmyCtrl otherArmyCtrl = null; foreach (var item in MapManager.mapPointCtrls) { if (item.mapPoint.X == OtherOriginalx && item.mapPoint.Z == OtherOriginalz) { OriginalPointCtrl = item; } else if (item.mapPoint.X == OtherMoveX && item.mapPoint.Z == OtherMoveZ) { MovePointCtrl = item; } if (OriginalPointCtrl != null && MovePointCtrl != null) { break; } } //fixbug已解决 只通过坐标选择了敌方单位 foreach (var item in OtherArmyCtrlManager.OtherArmyCtrlList) { if (item.transform.position.x == OtherOriginalx && item.transform.position.z == OtherOriginalz && item.armyState.MoveType == mapMoveDto.MoveType) { Army = item.gameObject; otherArmyCtrl = Army.GetComponent <OtherArmyCtrl>(); } } if (mapMoveDto.MoveType == ArmyMoveType.LAND) { //如果是陆地单位 OriginalPointCtrl.RemoveLandArmy(); MovePointCtrl.MoveLandArmy(ref Army, otherArmyCtrl.armyState.Race, otherArmyCtrl.armyState.Name, false); otherArmyCtrl.Move(MovePointCtrl.mapPoint, MovePointCtrl); } else if (mapMoveDto.MoveType == ArmyMoveType.SKY) { OriginalPointCtrl.RemoveSkyArmy(); MovePointCtrl.MoveSkyArmy(ref Army, otherArmyCtrl.armyState.Race, otherArmyCtrl.armyState.Name, false); otherArmyCtrl.Move(MovePointCtrl.mapPoint, MovePointCtrl); } }
public bool Attack(MapPointCtrl defensemapPointCtrl, OtherArmyCtrl defenseArmy) { if (defenseArmy == null) { return(false); } bool canAttackPoint = false; //是否能攻击地图点上的兵种 int attackSpace = ArmyMoveType.NONE; //攻击陆地1 攻击飞行2 if (defenseArmy.armyState.Name == defensemapPointCtrl.LandArmyName) { attackSpace = ArmyMoveType.LAND; } else { attackSpace = ArmyMoveType.SKY; } if (canAttack) { //如果能攻击 foreach (var item in canAttckPoint) { if (item.X == defensemapPointCtrl.mapPoint.X && item.Z == defensemapPointCtrl.mapPoint.Z) { //canAttack = true; canAttackPoint = true; break; } } if (canAttackPoint && attackSpace == ArmyMoveType.LAND) { //如果攻击陆地兵种 //改变状态 //isAttack = true; //isShowAttackButton = false; canAttack = false; //TODO 播放攻击动画 //向服务器发送攻击消息 attackDto.Change(mapPoint, defensemapPointCtrl.mapPoint, armyState.MoveType, defenseArmy.armyState.MoveType); socketMsg.Change(OpCode.FIGHT, FightCode.ARMY_ATTACK_CREQ, attackDto); Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg); return(true); } else if (canAttackPoint && attackSpace == ArmyMoveType.SKY) { //如果攻击飞行兵种 //改变状态 canAttack = false; //isShowAttackButton = false; //TODO 播放攻击动画 //向服务器发送攻击消息 attackDto.Change(mapPoint, defensemapPointCtrl.mapPoint, armyState.MoveType, defenseArmy.armyState.MoveType); socketMsg.Change(OpCode.FIGHT, FightCode.ARMY_ATTACK_CREQ, attackDto); Dispatch(AreoCode.NET, NetEvent.SENDMSG, socketMsg); return(true); } } return(false); }