/// <summary> /// 根据飞机数据获取地图位置 /// </summary> /// <param name="planeData">飞机数据</param> /// <param name="checkOnly">是否只是检测</param> public void GetMapPosByPlaneData(PludoPlaneData planeData, bool checkOnly = true) { var planeId = planeData.DataId; int curPosId; int tarGetPosId; switch ((EnumPlaneStatus)planeData.Status) { case EnumPlaneStatus.Finish: case EnumPlaneStatus.Home: curPosId = PludoGameData.GetReadyId(planeData.ItemColor, planeId); if (planeId == ConstantData.ValueLastPlaneId) { tarGetPosId = PludoGameData.GetReadyId(planeData.ItemColor, ConstantData.IntValue); } else { tarGetPosId = PludoGameData.GetReadyId(planeData.ItemColor, ConstantData.ValueReadyPosIndex); } break; case EnumPlaneStatus.Ready: curPosId = PludoGameData.GetReadyId(planeData.ItemColor, ConstantData.ValueReadyPosIndex); tarGetPosId = _commonStartId; break; default: curPosId = planeData.LocalPosition; if (planeData.LocalPosition < ConstantData.ValueReadyMapItemColorBase) { var findItem = _commomMapDic[planeData.LocalPosition]; if (findItem.EnumMapType == EnumMapItemType.End && findItem.Color == planeData.ItemColor) { tarGetPosId = SafeArea[ConstantData.IntValue].DataId; } else { tarGetPosId = (planeData.LocalPosition + 1) % PludoGameData.MapNormalLenth; } } else { var index = SafeArea.FindIndex(item => item.DataId == curPosId); if (index > ConstantData.IntDefValue) { tarGetPosId = SafeArea[index + 1].DataId; } else { tarGetPosId = ConstantData.IntDefValue; Debug.LogError("could not find such item in safeArea,local is:" + curPosId); } } break; } Vector3 curPos = GetMapItemPos(curPosId); Vector3 defTargetPos = GetMapItemPos(tarGetPosId); planeData.SetVector(curPos, defTargetPos); }
/// <summary> /// 等待爆炸时间并移动 /// </summary> public void WaitBoomAndMove(PludoPlaneData newPlaneData, AsyncCallback moveFinishCall = null) { var movePlane = GetPlaneById(newPlaneData.DataId); if (_boomCor != null) { StopCoroutine(_boomCor); } _boomCor = StartCoroutine(WaitBoomMove(movePlane.BoomAniTime, newPlaneData, moveFinishCall)); }
/// <summary> /// 飞机合体 /// </summary> public void OnPlaneFit(PludoPlaneData newPlaneData, int betFitId, bool fitWithMove = true) { var fitPlane = GetPlaneById(newPlaneData.DataId); YxDebug.LogError("当前操作的飞机存在子飞机数量是:" + fitPlane.PlaneList.Count); var beFitPlane = GetPlaneById(betFitId); beFitPlane.ShowPlaneFit( fitWithMove?PlaneMove(fitPlane, newPlaneData):ConstantData.IntValue, fitPlane, delegate { beFitPlane.PlaneData.PlaneStateChange((int)EnumPlaneStatus.BeFit); }); }
/// <summary> /// 飞机移动(常规) /// </summary> public int OnPlaneMove(PludoPlaneData newPlaneData, AsyncCallback call = null) { var movePlane = GetPlaneById(newPlaneData.DataId); return(PlaneMove(movePlane, newPlaneData, delegate { movePlane.PlaneData.PlaneStateChange((int)EnumPlaneStatus.Load); movePlane.PlaneData.PlaneLocalPosChange(newPlaneData.MovePath.Last()); GetMapPosByPlaneData(movePlane.PlaneData, false); if (call != null) { call(null); } })); }
/// <summary> /// 飞机准备 /// </summary> /// <param name="newPlaneData"></param> public void OnPlaneReady(PludoPlaneData newPlaneData) { var readyPlane = GetPlaneById(newPlaneData.DataId); var moveList = new List <Vector3>(); newPlaneData.PlaneStateChange((int)EnumPlaneStatus.Ready); GetMapPosByPlaneData(newPlaneData, false); moveList.Add(newPlaneData.CurPos); ConstantData.PlaySoundBySex(_curPlayerInfo.SexI, ConstantData.KeyStarFly); MoveAndRotateData moveRoateData = new MoveAndRotateData() { MovePath = moveList.ToList(), FinishRotate = newPlaneData.DefTargetPos }; readyPlane.PlaneMovePathWithRotate(moveRoateData, true, delegate { readyPlane.PlaneListReset(); readyPlane.PlaneData.PlaneStateChange((int)EnumPlaneStatus.Ready); }); }
/// <summary> /// 飞机完成 /// </summary> /// <param name="newPlaneData"></param> public void OnPlaneFinish(PludoPlaneData newPlaneData) { var finishPlane = GetPlaneById(newPlaneData.DataId); var finishDic = new Dictionary <int, List <Vector3> >(); var planeList = finishPlane.PlaneList; var count = planeList.Count; var moveList = GetMovePath(newPlaneData.MovePath); Vector3 finishShowPos; if (moveList.Count > ConstantData.IntValue) { finishShowPos = moveList.Last() + PlaneFinishOffset; } else { finishShowPos = PlaneFinishOffset; } for (int i = 0; i < count; i++) { var finishList = new List <Vector3>(); finishList.Add(finishShowPos); var plane = planeList[i]; plane.PlaneData.PlaneStateChange((int)EnumPlaneStatus.Finish); GetMapPosByPlaneData(plane.PlaneData); finishList.Add(plane.PlaneData.CurPos); finishDic.Add(plane.IdCode, finishList); YxDebug.LogError(string.Format("飞机{0}_{1}最终的位置是{2}", (ItemColor)plane.Color, plane.IdCode, plane.PlaneData.CurPos)); } finishPlane.OnPlaneFinish(moveList, finishDic, delegate { for (int i = 0; i < count; i++) { var plane = planeList[i]; plane.PlaneData.PlaneStateChange((int)EnumPlaneStatus.Finish); } Facade.Instance <MusicManager>().Play(ConstantData.KeyPlaneFinish); Facade.EventCenter.DispatchEvent(LoaclRequest.FreshStartNum, ConstantData.IntDefValue); }); }
/// <summary> /// 等待爆炸并移动 /// </summary> /// <param name="boomTime">爆炸时间</param> /// <param name="newPlaneData">新飞机数据</param> /// <returns></returns> private IEnumerator WaitBoomMove(float boomTime, PludoPlaneData newPlaneData, AsyncCallback moveFinishCall) { yield return(new WaitForSeconds(boomTime)); OnPlaneMove(newPlaneData, moveFinishCall); }
private int PlaneMove(PludoPlane movePlane, PludoPlaneData newPlaneData, AsyncCallback call = null) { return(movePlane.PlaneMovePath(GetMovePath(newPlaneData.MovePath), true, call)); }