private void removeArmy(ref MapPointCtrl Originalpointctrl, CardDto armyCard) { if (armyCard.MoveType == ArmyMoveType.LAND) { //陆地单位 Originalpointctrl.RemoveLandArmy(); } else if (armyCard.MoveType == ArmyMoveType.SKY) { Originalpointctrl.RemoveSkyArmy(); } }
/// <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); } }