/// <summary> /// 获取飞行输入 /// </summary> /// <param name="param"></param> /// <returns></returns> private static GolfFlyInput GetFlyInput(BattingParam param) { GolfFlyInput flyInput = new GolfFlyInput(); if (param != null) { flyInput.ClubType = (uint)param.Club.Type; flyInput.ClubStrength = param.Club.Strength; flyInput.BallStrengthPercent = param.Ball.StrengthPercent; flyInput.BattingVelocity = param.BattingSpeed; flyInput.Spin = new GolfSpin(param.CurFBSpin, param.CurFBSpin, param.CurFBSpin, param.CurFBSpin, param.CurLRSpin); flyInput.HookAngle = param.CurHookAngle; flyInput.Accuracy = new GolfAccuracy(param.Club.Accuracy, param.CurAccuracyOffset); flyInput.Wind = new GolfWind(param.WindSpeed); } else { flyInput.ClubType = (uint)BattleDC.SelClub.Type; flyInput.ClubStrength = BattleDC.SelClub.Strength; flyInput.BallStrengthPercent = BattleDC.SelBall.StrengthPercent; flyInput.HookAngle = 0; flyInput.BattingVelocity = Vector3.zero; flyInput.Spin = new GolfSpin(0, 0, 0, 0, 0); flyInput.Wind = new GolfWind(Vector3.zero); flyInput.Accuracy = new GolfAccuracy(0, 0); } return(flyInput); }
/// <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> /// temp /// </summary> /// <returns></returns> public static GolfPathInfo GetPath(BattingParam param = null) { if (BallInAra == AreaType.PuttingGreen) { return(Path.CalcRollPath(GetPushInput(param), BallPos, RingPos)); } else { return(Path.CalcFlyPath(GetFlyInput(param), BallPos, RingPos)); } }
/// <summary> /// 初始化窗口 /// </summary> public void Start() { m_swingInfo = new BattingParam(); m_limitAngle = 45; if (m_backGround != null && m_ring != null && m_arrow != null) { m_backGround.gameObject.SetActive(false); m_ring.gameObject.SetActive(false); m_arrow.gameObject.SetActive(false); m_arrowGreen.gameObject.SetActive(false); m_arrowGreenMove.gameObject.SetActive(false); } if (m_GolfboxOut != null && m_GolfboxIn != null) { m_imgGolfOut = m_GolfboxOut.GetComponent <Image>(); m_imgGolfIn = m_GolfboxIn.GetComponent <Image>(); if (m_imgGolfOut != null && m_imgGolfIn != null) { m_colorGolfOut = new Color(m_imgGolfOut.color.r, m_imgGolfOut.color.g, m_imgGolfOut.color.b, 0); m_colorGolfIn = new Color(m_imgGolfIn.color.r, m_imgGolfIn.color.g, m_imgGolfIn.color.b, 0); m_imgGolfOut.color = new Color(m_colorGolfOut.r, m_colorGolfOut.g, m_colorGolfOut.b, 0); m_imgGolfIn.color = new Color(m_colorGolfIn.r, m_colorGolfIn.g, m_colorGolfIn.b, 0); } } GameObject uiCamera = GameObject.Find("UI/UICamera"); if (uiCamera != null) { this.m_uiCamera = uiCamera.GetComponent <Camera>(); } if (m_GolfboxOut != null && m_golfPos != null && m_GolfboxOut != null && m_golf != null && m_imgGolfIn != null) { m_boxPos = m_GolfboxOut.transform.position; m_golfPos = m_golf.transform.position; m_disGolfBox = Vector3.Distance(m_golf.transform.position, m_boxPos); if (BattleM.BallInAra == AreaType.PuttingGreen) { m_GolfboxOut.gameObject.SetActive(false); m_imgGolfIn.gameObject.SetActive(false); } } }
/// <summary> /// 获取滚动输入 /// </summary> /// <param name="param"></param> /// <returns></returns> private static GolfPushInput GetPushInput(BattingParam param) { GolfPushInput pushInput = new GolfPushInput(); if (param != null) { pushInput.ClubType = (uint)param.Club.Type; pushInput.ClubStrength = param.Club.Strength; pushInput.BallStrengthPercent = param.Ball.StrengthPercent; pushInput.BattingVelocity = param.BattingSpeed; } else { pushInput.ClubType = (uint)BattleDC.SelClub.Type; pushInput.ClubStrength = BattleDC.SelClub.Strength; pushInput.BallStrengthPercent = BattleDC.SelBall.StrengthPercent; pushInput.BattingVelocity = Vector3.zero; } return(pushInput); }
/// <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); }