using asap.core; using cfg; using DG.Tweening; using UnityEngine; public class FishingStateMaxCombo : IFishingState { Vector3 scale; public FishingStateName fishingState { get { return FishingStateName.MaxCombo; } } public FishingBehaviorB fishingBehavior { get; set; } public float fishMoveSpeed { get; set; } FishingData fishingData; public void InState(FishingBehaviorB fishingBehavior, FishingData fishingData) { GContext.Publish(ERightState.MaxCombo); this.fishingData = fishingData; GContext.Publish(new VibrationData(HapticTypes.HeavyImpact)); this.fishingBehavior = fishingBehavior; scale = Vector3.one * fishingData.curFishData.SlashFxScale; if (fishingBehavior.fx_fishing_splashloop != null) { fishingBehavior.fx_fishing_splashloop.transform.localScale = scale * 1.35f; } if (fishingBehavior.fx_fishing_splashwaveloop != null) { fishingBehavior.fx_fishing_splashwaveloop.transform.localScale = scale * 1.35f; } fishMoveSpeed = 0.5f; fishingBehavior.cameraAnimator.SetTrigger("_maxcombo"); fishingBehavior.fishingRodAnimator.SetTrigger("_maxcombo"); if (fishingBehavior.Far) { StatrMoveByEscape(); } else { StatrMove(); } } //逃跑回拉 void StatrMoveByEscape() { var FishBackFarRangeParam = GContext.container.Resolve().TbFishStatsConfig.FishBackFarRangeParam; //位移距离的占比 = 参数1 + 鱼的力量 * 参数2 float distance = FishBackFarRangeParam[2] + fishingData.StrugglingPower * FishBackFarRangeParam[3]; distance = Mathf.Clamp(distance, FishBackFarRangeParam[0], FishBackFarRangeParam[1]); Vector3 endPoint = fishingBehavior.GetFish.transform.position; if (endPoint.z > fishingData.MaxLinelength) { endPoint.z = fishingData.MaxLinelength; } endPoint.z -= distance; endPoint.x = 0; fishingBehavior.GetFish.transform.DOKill(); Quaternion rotation = Quaternion.LookRotation(fishingBehavior.GetFish.transform.position - endPoint); fishingBehavior.GetFish.transform.DORotateQuaternion(rotation, fishingBehavior.GetTurnTime()); float time = fishingData.fishRodData.ComboTime; fishingBehavior.GetFish.transform.DOMove(endPoint, time).SetEase(Ease.Linear); } // 像自己做曲线运动 void StatrMove() { Vector3 controlPoint = new Vector3(0, fishingBehavior.GetFish.transform.position.y, 0); controlPoint.x = Mathf.Lerp(0, fishingBehavior.GetFish.transform.position.x, 1.0f / 3.0f); controlPoint.z = Mathf.Lerp(0, fishingBehavior.GetFish.transform.position.z, 2.0f / 3.0f); Vector3 endPoint = fishingBehavior.GetFish.transform.position; endPoint.x = 0; endPoint.z = fishingBehavior.RodBehaviour.TopLine.position.z + fishingData.fishingBehaviorConf.reelingToPullLength; fishingBehavior.GetFish.transform.DOKill(); Quaternion rotation = Quaternion.LookRotation(fishingBehavior.GetFish.transform.position - controlPoint); fishingBehavior.GetFish.transform.DORotateQuaternion(rotation, fishingBehavior.GetTurnTime()); Vector3[] path = new Vector3[] { fishingBehavior.GetFish.transform.position, controlPoint, endPoint }; var FishBackNearRangeParam = GContext.container.Resolve().TbFishStatsConfig.FishBackNearRangeParam; //位移距离的占比 = 参数1 + 鱼的力量 * 参数2 float distance = FishBackNearRangeParam[2] + fishingData.StrugglingPower * FishBackNearRangeParam[3]; distance = Mathf.Clamp(distance, FishBackNearRangeParam[0], FishBackNearRangeParam[1]); float turnTime = 0; Vector3 fishPos = fishingBehavior.GetFish.transform.position; float time = fishingData.fishRodData.ComboTime / distance; fishingBehavior.GetFish.transform.DOPath(path, time, PathType.CatmullRom)/*.SetDelay(GetTurnTime())*/ .OnUpdate( (() => { turnTime += Time.deltaTime; if (turnTime > fishingBehavior.GetTurnTime()) { Quaternion rotation = Quaternion.LookRotation(fishPos - fishingBehavior.GetFish.transform.position); fishingBehavior.GetFish.transform.rotation = rotation; } fishPos = fishingBehavior.GetFish.transform.position; })).SetEase(Ease.Linear); } public void UpdateState() { } public void OutState() { GContext.Publish(ERightState.Drawing); fishingBehavior.GetFish.transform.DOKill(); fishingBehavior.cameraAnimator.SetTrigger("_maxcomboExit"); //cameraAnimator.SetBool("_maxcombo", false); fishingBehavior.fishingRodAnimator.SetTrigger("_maxcomboExit"); if (fishingBehavior.fx_fishing_splashloop != null) { fishingBehavior.fx_fishing_splashloop.transform.localScale = scale; } if (fishingBehavior.fx_fishing_splashwaveloop != null) { fishingBehavior.fx_fishing_splashwaveloop.transform.localScale = scale; } fishMoveSpeed = 1; } }