IEnumerator RunBallCoroutine(GolfPathInfo pathinfo) { if (pathinfo == null || pathinfo.ListPt == null || pathinfo.ListPt.Count == 0) { yield return(null); } for (int i = 0; i < pathinfo.ListPt.Count; i++) { GolfPathPoint golfPoint = pathinfo.ListPt[i]; if (golfPoint.Status == BallRunStatus.Roll) { if (golfPoint.BallType == BallType.OutHole) { yield return(Yielders.GetWaitForSeconds(golfPoint.Interval / 2)); } else { yield return(Yielders.GetWaitForSeconds(golfPoint.Interval / 0.5f)); } } else { yield return(Yielders.GetWaitForSeconds(golfPoint.Interval / 3)); } if (!string.IsNullOrEmpty(golfPoint.EventType)) { EventCenter.DispatchEvent(golfPoint.EventType, -1, golfPoint.EventParam); } SetBallPos(golfPoint.Position); BattleM.SetBallRunInfo(golfPoint.Position, golfPoint.AType, golfPoint.Status); } StopAllCoroutines(); }
/// <summary> /// 更新推杆参数 /// </summary> /// <param name="Param"></param> public static void SetRollOperation(BattingParam Param) { GolfPathInfo pathInfo = GetPath(Param); EventCenter.DispatchEvent(EventCenterType.Battle_DrawPath, -1, pathInfo); EventCenter.DispatchEvent(EventCenterType.Battle_PathCrossHole, -1, pathInfo.CheckCrossHole()); }
/// <summary> /// 实时刷新路径 /// </summary> /// <param name="Event_Send"></param> /// <param name="Param"></param> private void RefreshGolfPath(int Event_Send, object Param) { if (Param == null) { ClearCurve(); } else { GolfPathInfo Info = Param as GolfPathInfo; DrawCurve(0.15f, Info); } }
/// <summary> /// 发球 /// </summary> private static void RoundFireBall(object Param) { if (Param == null) { return; } BattingParam param = Param as BattingParam; GolfPathInfo pathInfo = GetPath(param); EventCenter.DispatchEvent(EventCenterType.Battle_BattingFinish, -1, pathInfo); EventCenter.DispatchEvent(EventCenterType.Battle_ShowRing, -1, false); m_SelfSel.SetBallSpeed(param.BattingSpeed); m_SelfSel.SetWindSpeed(param.WindSpeed); m_SelfSel.SetCurFBSpin(param.CurFBSpin); m_SelfSel.SetCurLRSpin(param.CurLRSpin); m_SelfSel.SetCurHookAngle(param.CurHookAngle); m_SelfSel.SetCurAccuracyOffset(param.CurAccuracyOffset); m_SelfSel.SetResultPos(pathInfo.GetRuseltPos()); BattleOperateInfo v = new BattleOperateInfo(m_SelfSel); AddBattleOperate(true, g_Times, v); }
/// <summary> /// 绘制曲线 /// </summary> /// <param name="Count"></param> /// <param name="startWidth"></param> /// <param name="endWidth"></param> /// <param name="lpt"></param> private void DrawCurve(float Width, GolfPathInfo Info) { if (Info == null || Info.ListPt == null || Info.ListPt.Count == 0) { ClearCurve(); return; } List <Vector3> l = new List <Vector3>(); foreach (GolfPathPoint p in Info.ListPt) { l.Add(p.Position); } if (BattleM.BallInAra == AreaType.PuttingGreen) { Linemesh = CreateLine(l, Width, true); } else { Linemesh = CreateLine(l, Width, true); } }
private void BattingFinish(int Event_Send, object Param) { GolfPathInfo pathinfo = Param as GolfPathInfo; RunBall(pathinfo); }
public void RunBall(GolfPathInfo pathinfo) { StartCoroutine(RunBallCoroutine(pathinfo)); }