备份CatanBuilding瘦身独立工程
This commit is contained in:
8
Assets/Scripts/GampPlay/Build.meta
Normal file
8
Assets/Scripts/GampPlay/Build.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1eabfa07b4c437c4d9e32ff3d3b5b641
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
284
Assets/Scripts/GampPlay/Build/Building.cs
Normal file
284
Assets/Scripts/GampPlay/Build/Building.cs
Normal file
@@ -0,0 +1,284 @@
|
||||
using GameCore;
|
||||
using asap.core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using System;
|
||||
using UniRx;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public enum EBuildingType
|
||||
{
|
||||
UpgradeBuilding = 0,
|
||||
Pause = 1,
|
||||
Continue = 2,
|
||||
Next = 3,
|
||||
OpenFix = 4,
|
||||
CampPhoto = 5,
|
||||
}
|
||||
public class SwitchBuildingData
|
||||
{
|
||||
}
|
||||
public class OnUpgradeBuildingData
|
||||
{
|
||||
public OnUpgradeBuildingData(EBuildingType buildingType, bool CanContinue = true)
|
||||
{
|
||||
this.type = buildingType;
|
||||
this.CanContinue = CanContinue;
|
||||
}
|
||||
public EBuildingType type;//0-UpgradeBuilding;1-暂停;2-继续;3-下一步 (-1-打开修复)
|
||||
public bool CanContinue;//是否可以继续
|
||||
public int TimelineId;
|
||||
public float StartTime;
|
||||
public float Duration;
|
||||
public float Speed = 1;
|
||||
public string NextPrefab;
|
||||
public string CurrentPrefab;
|
||||
}
|
||||
|
||||
public class OnUpgradeBuildingFix
|
||||
{
|
||||
public TaskCompletionSource<bool> ts = new TaskCompletionSource<bool>();
|
||||
}
|
||||
|
||||
public class SwitchVirtualCameraEvent
|
||||
{
|
||||
public int type;
|
||||
public bool isDrag = true;
|
||||
}
|
||||
|
||||
public class Building : MonoBehaviour
|
||||
{
|
||||
public PlayableDirector[] directors;
|
||||
public PlayableDirector fix;
|
||||
public PlayableDirector fade;
|
||||
public PlayableDirector enter;
|
||||
double _targetTime;
|
||||
PlayableDirector _currentDirector;
|
||||
private OnUpgradeBuildingData _upgradeBuildingData;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (fix == null && transform.parent != null)
|
||||
{
|
||||
fix = transform.parent.Find("Fix")?.GetComponent<PlayableDirector>();
|
||||
}
|
||||
if (directors != null && directors.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < directors.Length; i++)
|
||||
{
|
||||
var director = directors[i];
|
||||
director.initialTime = 0;
|
||||
director.Evaluate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTimelineDone(int index)
|
||||
{
|
||||
if (index >= directors.Length)
|
||||
{
|
||||
Debug.LogError($"[Building::SetTimelineDone] index {index} is out of range, directors length is {directors.Length}");
|
||||
index = directors.Length - 1;
|
||||
}
|
||||
var director = directors[index];
|
||||
director.time = director.duration;
|
||||
director.initialTime = director.time;
|
||||
}
|
||||
|
||||
public void SetTimelineAllDone()
|
||||
{
|
||||
for (int i = 0; i < directors.Length; i++)
|
||||
{
|
||||
var director = directors[i];
|
||||
director.time = director.duration;
|
||||
director.initialTime = director.time;
|
||||
director.Evaluate();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCurrentTimeLine(int index, float startTime, float duration, bool evaluate)
|
||||
{
|
||||
if (index >= directors.Length)
|
||||
{
|
||||
Debug.LogError($"[Building::SetCurrentTimeLine] index {index} is out of range, directors length is {directors.Length}");
|
||||
index = directors.Length - 1;
|
||||
}
|
||||
|
||||
var director = directors[index];
|
||||
|
||||
if (!evaluate)
|
||||
{
|
||||
director.time = 0;
|
||||
director.initialTime = 0;
|
||||
}
|
||||
|
||||
if (director.time >= startTime + duration)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
director.time = startTime;
|
||||
|
||||
director.initialTime = startTime;
|
||||
|
||||
_targetTime = startTime + duration;
|
||||
|
||||
if (_targetTime > director.duration + 0.01f)
|
||||
{
|
||||
Debug.LogError($"[Building::SetCurrentTimeLine] _targetTime {startTime + duration} is greater than director duration {director.duration}, clamping to duration.");
|
||||
_targetTime = (float)director.duration;
|
||||
}
|
||||
|
||||
if (evaluate)
|
||||
{
|
||||
director.Evaluate();
|
||||
_currentDirector = director;
|
||||
}
|
||||
}
|
||||
|
||||
public void EvaluateAllDrictors()
|
||||
{
|
||||
for (int i = 0; i < directors.Length; i++)
|
||||
{
|
||||
var director = directors[i];
|
||||
director.Evaluate();
|
||||
}
|
||||
}
|
||||
|
||||
public void Show(CampDataMM campData)
|
||||
{
|
||||
if (_currentDirector != null)
|
||||
_currentDirector.Pause();
|
||||
if (campData != null && campData.TimelineId >= 0 && campData.TimelineId < directors.Length)
|
||||
{
|
||||
_currentDirector = directors[campData.TimelineId];
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentDirector = directors[^1];
|
||||
Debug.LogError($"[Building::Show] campData is null or TimelineId {campData?.TimelineId} is out of range, directors length is {directors.Length}");
|
||||
}
|
||||
_currentDirector.gameObject.SetActive(true);
|
||||
_currentDirector.Evaluate();
|
||||
|
||||
// _currentDirector.time = campData.StepInfo.StartTime;
|
||||
// _currentDirector.initialTime = campData.StepInfo.StartTime;
|
||||
// _currentDirector.Evaluate();
|
||||
// _targetTime = MathF.Min(
|
||||
// campData.StepInfo.StartTime + campData.StepInfo.PlayTime,
|
||||
// (float)_currentDirector.duration);
|
||||
// Debug.Log($"[Building::Show] director {_currentDirector.state} {_currentDirector.name} time {_currentDirector.time} {_targetTime}");
|
||||
}
|
||||
|
||||
public void ShowFix()
|
||||
{
|
||||
if (fix != null)
|
||||
{
|
||||
fix.initialTime = 0;
|
||||
fix.Evaluate();
|
||||
fix.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("fix is null");
|
||||
}
|
||||
}
|
||||
|
||||
public void OnUpgradeBuilding(OnUpgradeBuildingData data)
|
||||
{
|
||||
switch (data.type)
|
||||
{
|
||||
case EBuildingType.UpgradeBuilding:
|
||||
|
||||
//Debug.Log($"[Building::OnUpgradeBuilding update] director {_currentDirector.state} {_currentDirector.name} time {_currentDirector.time} {_targetTime}");
|
||||
_currentDirector.Play();
|
||||
_currentDirector.playableGraph.GetRootPlayable(0).SetSpeed(data.Speed);
|
||||
_upgradeBuildingData = data;
|
||||
break;
|
||||
case EBuildingType.Pause:
|
||||
_currentDirector.Pause();
|
||||
break;
|
||||
case EBuildingType.Continue:
|
||||
_currentDirector.Resume();
|
||||
break;
|
||||
case EBuildingType.Next:
|
||||
OnNext(data.TimelineId, data.StartTime, data.Duration);
|
||||
break;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
case EBuildingType.OpenFix:
|
||||
ShowFix();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNext(int TimelineId, float startTime, float duration)
|
||||
{
|
||||
SetCurrentTimeLine(TimelineId, startTime, duration, true);
|
||||
}
|
||||
|
||||
public async void OnFix(OnUpgradeBuildingFix onUpgradeBuildingFix, Action onFixed)
|
||||
{
|
||||
if (fix)
|
||||
{
|
||||
fix.Play();
|
||||
await Awaiters.Seconds((float)fix.duration);
|
||||
if (fix)
|
||||
{
|
||||
fix.Stop();
|
||||
fix.gameObject.SetActive(false);
|
||||
}
|
||||
onFixed?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public double Fade()
|
||||
{
|
||||
if (fade == null)
|
||||
return 0;
|
||||
fade.time = 0;
|
||||
fade.initialTime = 0;
|
||||
_currentDirector = null;
|
||||
fade.Play();
|
||||
return fade.duration;
|
||||
}
|
||||
|
||||
public double Enter()
|
||||
{
|
||||
if (enter == null)
|
||||
return 0;
|
||||
enter.time = 0;
|
||||
enter.initialTime = 0;
|
||||
enter.Play();
|
||||
return enter.duration;
|
||||
}
|
||||
|
||||
//public double GetRestTime()
|
||||
//{
|
||||
//if(_currentDirector == null)
|
||||
//return 0;
|
||||
//if(_currentDirector.state != PlayState.Playing)
|
||||
//return 0;
|
||||
//return _targetTime - _currentDirector.time;
|
||||
//}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_currentDirector != null && _currentDirector.state == PlayState.Playing)
|
||||
{
|
||||
if (_targetTime - _currentDirector.time < 0.001f)
|
||||
{
|
||||
_currentDirector.Pause();
|
||||
_currentDirector.time = _targetTime;
|
||||
if (_upgradeBuildingData != null)
|
||||
{
|
||||
_upgradeBuildingData.CanContinue = true;
|
||||
_upgradeBuildingData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/Build/Building.cs.meta
Normal file
11
Assets/Scripts/GampPlay/Build/Building.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0d05d5f803bb584098ed1956b129609
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
333
Assets/Scripts/GampPlay/Build/BuildingCameraController.cs
Normal file
333
Assets/Scripts/GampPlay/Build/BuildingCameraController.cs
Normal file
@@ -0,0 +1,333 @@
|
||||
using asap.core;
|
||||
using Cinemachine;
|
||||
using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
public class BuildingCameraController : MonoBehaviour
|
||||
{
|
||||
//public Transform mainCameraTr;
|
||||
public CinemachineVirtualCamera cameraVirtual;
|
||||
|
||||
public CinemachineFreeLook[] cameraFreeLook;
|
||||
public GameObject cameraMove;
|
||||
string inputAxisXName = "Mouse X";
|
||||
|
||||
string inputAxisYName = "Mouse Y";
|
||||
|
||||
// public CinemachineVirtualCameraBase vcam;
|
||||
private int index = 0;
|
||||
bool photo;
|
||||
private CinemachineVirtualCameraBase currentCamera;
|
||||
float zoomSpeed = 0.2f;
|
||||
private Vector2[] lastTouchPositions = new Vector2[2];
|
||||
private Vector2[] currentTouchPositions = new Vector2[2];
|
||||
private float lastTouchDistance;
|
||||
|
||||
private float currentTouchDistance;
|
||||
//方向 圆心
|
||||
private Vector2 circle;
|
||||
private Vector2 touchDelta0;
|
||||
private Vector2 touchDelta1;
|
||||
private Vector2 currentDelta0;
|
||||
private Vector2 currentDelta1;
|
||||
float signedAngle0;
|
||||
float signedAngle1;
|
||||
float angle0;
|
||||
float angle1;
|
||||
public Transform lookAt;
|
||||
public Transform boundary1;
|
||||
public Transform boundary2;
|
||||
private Vector3 minVec;
|
||||
private Vector3 maxVec;
|
||||
//是否双指
|
||||
private bool isTouchTwo = false;
|
||||
//双指拖动开始阈值
|
||||
public float touchTwoThreshold = 50;
|
||||
|
||||
public CinemachineDollyCart cinemachineDollyCart;
|
||||
public CinemachineVirtualCamera cameraPhotoVirtual;
|
||||
|
||||
bool isMove = false;
|
||||
bool isTransfer = false;
|
||||
Vector3 startPos;
|
||||
IDisposable disposable;
|
||||
bool isDrag = false;
|
||||
void Start()
|
||||
{
|
||||
transform.Find("CameraMain").gameObject.SetActive(false);
|
||||
startPos = lookAt.localPosition;
|
||||
cameraMove.SetActive(false);
|
||||
minVec = new Vector3(Mathf.Min(boundary1.localPosition.x, boundary2.localPosition.x), lookAt.localPosition.y, Mathf.Min(boundary1.localPosition.z, boundary2.localPosition.z));
|
||||
maxVec = new Vector3(Mathf.Max(boundary1.localPosition.x, boundary2.localPosition.x), lookAt.localPosition.y, Mathf.Max(boundary1.localPosition.z, boundary2.localPosition.z));
|
||||
//Zoom = cameraVirtual.m_Lens.FieldOfView;
|
||||
currentCamera = cameraVirtual;
|
||||
cameraVirtual.gameObject.SetActive(true);
|
||||
for (int i = 0; i < cameraFreeLook.Length; i++)
|
||||
{
|
||||
cameraFreeLook[i].gameObject.SetActive(false);
|
||||
}
|
||||
//mainCameraTr.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
disposable = GContext.OnEvent<SwitchVirtualCameraEvent>().Subscribe(OnSwitchVirtualCamera);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
//切换虚拟相机
|
||||
void SwitchVirtualCamera(int _index)
|
||||
{
|
||||
if (index != _index)
|
||||
{
|
||||
CinemachineVirtualCameraBase nextCamera;
|
||||
if (_index != 0)
|
||||
{
|
||||
nextCamera = cameraFreeLook[_index - 1];
|
||||
nextCamera.transform.position = currentCamera.transform.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
nextCamera = cameraVirtual;
|
||||
lookAt.localPosition = startPos;
|
||||
}
|
||||
currentCamera.gameObject.SetActive(false);
|
||||
currentCamera = nextCamera;
|
||||
currentCamera.gameObject.SetActive(true);
|
||||
if (isMove && _index == 0)
|
||||
{
|
||||
cameraMove.SetActive(false);
|
||||
isMove = false;
|
||||
}
|
||||
}
|
||||
index = _index;
|
||||
}
|
||||
void OnSwitchVirtualCamera(SwitchVirtualCameraEvent eventData)
|
||||
{
|
||||
isDrag = eventData.isDrag;
|
||||
if (eventData.type > 10)
|
||||
{
|
||||
photo = true;
|
||||
if (eventData.type == 11)
|
||||
{
|
||||
SetPhotoVirtual();
|
||||
}
|
||||
else if (eventData.type == 12)
|
||||
{
|
||||
SetCinemachineDollyCart();
|
||||
}
|
||||
index = eventData.type;
|
||||
return;
|
||||
}
|
||||
if (isDrag || eventData.type == 0)
|
||||
{
|
||||
if (index > 10)
|
||||
{
|
||||
if (cameraPhotoVirtual != null)
|
||||
{
|
||||
cameraPhotoVirtual.gameObject.SetActive(false);
|
||||
}
|
||||
cinemachineDollyCart.transform.parent.gameObject.SetActive(false);
|
||||
}
|
||||
SwitchVirtualCamera(eventData.type);
|
||||
}
|
||||
}
|
||||
|
||||
void SetPhotoVirtual()
|
||||
{
|
||||
if (cameraPhotoVirtual == null)
|
||||
{
|
||||
Debug.LogError("cameraPhotoVirtual is null");
|
||||
return;
|
||||
}
|
||||
currentCamera.gameObject.SetActive(false);
|
||||
|
||||
cameraPhotoVirtual.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
void SetCinemachineDollyCart()
|
||||
{
|
||||
if (cameraPhotoVirtual != null)
|
||||
{
|
||||
cameraPhotoVirtual.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
currentCamera.gameObject.SetActive(false);
|
||||
cinemachineDollyCart.transform.parent.gameObject.SetActive(true);
|
||||
cinemachineDollyCart.m_Speed = 0;
|
||||
}
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!isDrag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (photo)
|
||||
{
|
||||
if (Input.GetMouseButton(0) || Input.touchCount == 1)
|
||||
{
|
||||
if (cinemachineDollyCart.transform.parent.gameObject.activeSelf)
|
||||
{
|
||||
cinemachineDollyCart.m_Position -= Input.GetAxis(inputAxisXName);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
if (Input.GetMouseButton(0) && index == 1)
|
||||
#else
|
||||
if (Input.touchCount==1&& index==1)
|
||||
#endif
|
||||
{
|
||||
if (!isTouchTwo)
|
||||
{
|
||||
//SwitchVirtualCamera(1);
|
||||
cameraFreeLook[index - 1].m_XAxis.m_InputAxisValue = Input.GetAxis(inputAxisXName);
|
||||
cameraFreeLook[index - 1].m_YAxis.m_InputAxisValue = Input.GetAxis(inputAxisYName);
|
||||
}
|
||||
}
|
||||
else if (Input.touchCount == 2)
|
||||
{
|
||||
if (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(1).phase == TouchPhase.Moved)
|
||||
{
|
||||
|
||||
currentTouchPositions[0] = Input.GetTouch(0).position;
|
||||
currentTouchPositions[1] = Input.GetTouch(1).position;
|
||||
if (!isTouchTwo)
|
||||
{
|
||||
isTouchTwo = true;
|
||||
lastTouchPositions[0] = currentTouchPositions[0];
|
||||
lastTouchPositions[1] = currentTouchPositions[1];
|
||||
}
|
||||
|
||||
if (Vector2.Distance(currentTouchPositions[0], lastTouchPositions[0]) + Vector2.Distance(currentTouchPositions[1], lastTouchPositions[1]) > touchTwoThreshold && index != 2)
|
||||
{
|
||||
SwitchVirtualCamera(2);
|
||||
}
|
||||
if (!isTransfer && !isMove && (Vector2.Distance(currentTouchPositions[0], lastTouchPositions[0]) < touchTwoThreshold && Vector2.Distance(currentTouchPositions[1], lastTouchPositions[1]) < touchTwoThreshold))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (index == 2)
|
||||
{
|
||||
circle = (lastTouchPositions[0] + lastTouchPositions[1]) / 2;
|
||||
touchDelta0 = lastTouchPositions[0] - circle;
|
||||
touchDelta1 = lastTouchPositions[1] - circle;
|
||||
currentDelta0 = (currentTouchPositions[0] - lastTouchPositions[0]);
|
||||
currentDelta1 = (currentTouchPositions[1] - lastTouchPositions[1]);
|
||||
signedAngle0 = Vector2.SignedAngle(touchDelta0, currentDelta0);
|
||||
signedAngle1 = Vector2.SignedAngle(touchDelta1, currentDelta1);
|
||||
angle0 = Vector2.Angle(touchDelta0, currentDelta0);
|
||||
angle1 = Vector2.Angle(touchDelta1, currentDelta1);
|
||||
if ((Vector2.Angle(currentDelta0, currentDelta1) > 30) && !isMove || isTransfer)
|
||||
{
|
||||
TransferPOrR();
|
||||
}
|
||||
else if ((!isTransfer && Vector2.Angle(currentDelta0, currentDelta1) < 20) || (isMove && (Vector2.Angle(currentDelta0, currentDelta1) < 50)))
|
||||
{
|
||||
Move();
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraFreeLook[index - 1].m_YAxis.m_InputAxisValue = 0;
|
||||
cameraFreeLook[index - 1].m_XAxis.m_InputAxisValue = 0;
|
||||
}
|
||||
|
||||
lastTouchPositions[0] = currentTouchPositions[0];
|
||||
lastTouchPositions[1] = currentTouchPositions[1];
|
||||
}
|
||||
}
|
||||
else if (index != 0)
|
||||
{
|
||||
cameraFreeLook[index - 1].m_YAxis.m_InputAxisValue = 0;
|
||||
cameraFreeLook[index - 1].m_XAxis.m_InputAxisValue = 0;
|
||||
}
|
||||
}
|
||||
else if (Input.touchCount == 0 && index != 0)
|
||||
{
|
||||
isTouchTwo = false;
|
||||
isTransfer = false;
|
||||
if (isMove)
|
||||
{
|
||||
cameraFreeLook[1].transform.position = cameraMove.transform.position;
|
||||
currentCamera.gameObject.SetActive(true);
|
||||
cameraMove.SetActive(false);
|
||||
isMove = false;
|
||||
}
|
||||
cameraFreeLook[index - 1].m_XAxis.m_InputAxisValue = 0;
|
||||
cameraFreeLook[index - 1].m_YAxis.m_InputAxisValue = 0;
|
||||
}
|
||||
}
|
||||
//旋转缩放
|
||||
void TransferPOrR()
|
||||
{
|
||||
isTransfer = true;
|
||||
if (signedAngle0 * signedAngle1 > 0 && ((angle0 > 60 && angle0 < 120) || (angle1 > 60 && angle1 < 120)))
|
||||
{
|
||||
float delta = currentDelta0.magnitude + currentDelta1.magnitude;
|
||||
if (signedAngle0 > 0)
|
||||
{
|
||||
cameraFreeLook[index - 1].m_XAxis.m_InputAxisValue = delta * zoomSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraFreeLook[index - 1].m_XAxis.m_InputAxisValue = -delta * zoomSpeed;
|
||||
}//旋转
|
||||
|
||||
}
|
||||
else if ((angle0 > 150 && angle1 > 150) || (angle0 < 30 && angle1 < 30))
|
||||
{
|
||||
currentTouchDistance = Vector2.Distance(currentTouchPositions[0], currentTouchPositions[1]);
|
||||
lastTouchDistance = Vector2.Distance(lastTouchPositions[0], lastTouchPositions[1]);//缩放
|
||||
float delta = currentTouchDistance - lastTouchDistance;
|
||||
if (delta < 0)
|
||||
{
|
||||
cameraFreeLook[index - 1].m_YAxis.m_InputAxisValue = delta * zoomSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraFreeLook[index - 1].m_YAxis.m_InputAxisValue = delta * zoomSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
//移动
|
||||
void Move()
|
||||
{
|
||||
if (!isMove)
|
||||
{
|
||||
isMove = true;
|
||||
cameraMove.transform.position = cameraFreeLook[index - 1].transform.position;
|
||||
cameraMove.SetActive(true);
|
||||
currentCamera.gameObject.SetActive(false);
|
||||
}
|
||||
//方向
|
||||
Vector2 offset;
|
||||
if (currentDelta0.magnitude > currentDelta1.magnitude)
|
||||
{
|
||||
offset = currentDelta0;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = currentDelta1;
|
||||
}
|
||||
//同方向移动
|
||||
//Vector2 offset = (currentDelta0 + currentDelta1).normalized;
|
||||
//offst在相机坐标系下的向量
|
||||
Vector3 vector = Camera.main.transform.TransformDirection(offset.x, 0, offset.y);
|
||||
vector.y = 0;
|
||||
lookAt.localPosition += vector.normalized * Time.deltaTime * 30;
|
||||
lookAt.localPosition = new Vector3(Mathf.Clamp(lookAt.localPosition.x, minVec.x, maxVec.x), lookAt.localPosition.y, Mathf.Clamp(lookAt.localPosition.z, minVec.z, maxVec.z));
|
||||
//cameraFreeLook[index - 1].m_Orbits[0].m_Radius += vector.magnitude;
|
||||
//cameraFreeLook[index - 1].m_Orbits[1].m_Radius += vector.magnitude;
|
||||
//cameraFreeLook[index - 1].m_Orbits[2].m_Radius += vector.magnitude;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3484f749a8cc4eea8c633986b81b33e8
|
||||
timeCreated: 1694414241
|
||||
31
Assets/Scripts/GampPlay/Build/CampPlayAudio.cs
Normal file
31
Assets/Scripts/GampPlay/Build/CampPlayAudio.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class CampPlayAudio : MonoBehaviour
|
||||
{
|
||||
AudioSource audioSource;
|
||||
float audioTime = 0;
|
||||
//private void Awake()
|
||||
//{
|
||||
// audioSource = GetComponent<AudioSource>();
|
||||
// if (audioSource)
|
||||
// {
|
||||
// audioTime = audioSource.clip.length;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void OnEnable()
|
||||
//{
|
||||
// if (audioSource)
|
||||
// {
|
||||
// audioSource.Play();
|
||||
// StartCoroutine(Stop());
|
||||
// }
|
||||
//}
|
||||
|
||||
//IEnumerator Stop()
|
||||
//{
|
||||
// yield return new WaitForSeconds(audioTime);
|
||||
// gameObject.SetActive(false);
|
||||
//}
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/Build/CampPlayAudio.cs.meta
Normal file
11
Assets/Scripts/GampPlay/Build/CampPlayAudio.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae44b2fc925374c45ab6b93f7260cd52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/GampPlay/ChallengeMatch.meta
Normal file
8
Assets/Scripts/GampPlay/ChallengeMatch.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9d0108e1cf8b5d4195331de07300edc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
246
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeBox.cs
Normal file
246
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeBox.cs
Normal file
@@ -0,0 +1,246 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Castle.Core.Internal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 挂在脚本,方便额外的处理
|
||||
/// </summary>
|
||||
|
||||
public enum CBoxState
|
||||
{
|
||||
Locked = 0,
|
||||
UnLocking = 1, // 解锁中
|
||||
UnLocked = 2, // 已解锁
|
||||
Attacking = 3, // 袭击中
|
||||
Broken = 4 // 破碎
|
||||
}
|
||||
|
||||
|
||||
public class ChallengeBox : MonoBehaviour
|
||||
{
|
||||
[Header("Timeline配置")]
|
||||
public PlayableDirector AppearTimeline;//出现表现timeline
|
||||
public PlayableDirector BreakTimeline;//销毁表现timeline
|
||||
|
||||
[Header("头像运动参数")]
|
||||
public float AppearJumpDelay = 4f;//播放出现表现timeline同时,延迟多久播放头像动画
|
||||
|
||||
[Header("被破坏的箱子")]
|
||||
private ChallengeBox box;
|
||||
|
||||
[Header("箱子破碎,被鳄鱼袭击特效")]
|
||||
[SerializeField]
|
||||
private ParticleSystem psBoxBroken;
|
||||
|
||||
// 断开藤曼,同时播放吗
|
||||
[Header("断开藤曼")]
|
||||
[SerializeField]
|
||||
private Animation aniKnife;
|
||||
[SerializeField]
|
||||
private ParticleSystem psKnife;
|
||||
|
||||
// 藤曼退开,可以跳跃
|
||||
[Header("藤曼退开,箱子可供站立")]
|
||||
[SerializeField]
|
||||
private Animation aniBoxOn;
|
||||
private float _speed = 1.0f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (psBoxBroken)
|
||||
{
|
||||
psBoxBroken.Stop();
|
||||
}
|
||||
|
||||
if (psKnife)
|
||||
{
|
||||
psKnife.Stop();
|
||||
}
|
||||
|
||||
if (aniBoxOn)
|
||||
{
|
||||
aniBoxOn.Stop();
|
||||
}
|
||||
|
||||
if (aniKnife)
|
||||
{
|
||||
aniKnife.Stop();
|
||||
// aniKnife.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// if (challengeKiller)
|
||||
// {
|
||||
// challengeKiller.OnIdle();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// AppearTimeline.initialTime = 0;
|
||||
// AppearTimeline.Evaluate();
|
||||
// // AppearTimeline.playOnAwake();
|
||||
// IdleTimeline.initialTime = 0;
|
||||
// IdleTimeline.Evaluate();
|
||||
// BreakTimeline.initialTime = 0;
|
||||
// BreakTimeline.Evaluate();
|
||||
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Log(object t)
|
||||
{
|
||||
// Debug.Log("");
|
||||
}
|
||||
|
||||
public float GetSpeed()
|
||||
{
|
||||
return _speed;
|
||||
}
|
||||
|
||||
public float SpeedUpSeconds(float seconds)
|
||||
{
|
||||
return _speed * seconds;
|
||||
}
|
||||
|
||||
public void UpdateTimeController(ChallengeSetAnimationEvent e)
|
||||
{
|
||||
_speed = e.speed;
|
||||
// _timeForUnlocking = e.timeForUnlocking;
|
||||
// _timeForUnlockingEnd = e.timeForUnLockingEnd;
|
||||
// _timeForAttackStart = e.timeForAttackStart;
|
||||
// _timeForAttacking1 = e.timeForAttacking_1;
|
||||
// _timeForAttacking2 = e.timeForAttacking_2;
|
||||
// _timeForAttackEnd = e.timeForAttackEnd;
|
||||
// _timeForAttackEndWait = e.timeForAttackEndWait;
|
||||
}
|
||||
public void SnapToEnd(Animation anim, string clipName = null)
|
||||
{
|
||||
if (!anim) return;
|
||||
if (clipName == null)
|
||||
{
|
||||
clipName = anim.clip?.name;
|
||||
}
|
||||
|
||||
if (clipName == null)
|
||||
return;
|
||||
|
||||
if (anim[clipName] == null)
|
||||
{
|
||||
Log($"动画片段 {clipName} 不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
// 方法1:直接设置时间并采样
|
||||
anim[clipName].time = anim[clipName].length;
|
||||
anim.Play(clipName);
|
||||
anim.Sample();
|
||||
anim.Stop(clipName);
|
||||
|
||||
}
|
||||
|
||||
public void SnapToStart(Animation anim)
|
||||
{
|
||||
if (!anim || !anim.clip ) return;
|
||||
var clipName = anim.clip.name;
|
||||
if (anim[clipName] == null)
|
||||
{
|
||||
Log($"动画片段 {clipName} 不存在");
|
||||
return;
|
||||
}
|
||||
// var speed = anim[clipName].speed;
|
||||
anim.Play(clipName);
|
||||
anim[clipName].time = 0f;
|
||||
anim.Sample();
|
||||
// anim[clipName].speed = 0f;
|
||||
anim.Stop(clipName);
|
||||
// anim[clipName].time = speed;
|
||||
|
||||
}
|
||||
//
|
||||
private async Task OnUnLocking()
|
||||
{
|
||||
Log("OnUnlocking");
|
||||
// aniKnife.gameObject.SetActive(true);
|
||||
// var knifeName = (from AnimationState state in aniKnife select state.name).FirstOrDefault();
|
||||
// aniKnife.Play(knifeName);
|
||||
// // 注意时间是自己调的,有时间最好协助回调中
|
||||
// await Awaiters.Seconds(SpeedUpSeconds(_timeForUnlocking));
|
||||
// aniBoxOn.Play();
|
||||
// await Awaiters.Seconds(SpeedUpSeconds(_timeForUnlockingEnd));
|
||||
|
||||
// aniKnife.gameObject.SetActive(true);
|
||||
AppearTimeline.initialTime = 0;
|
||||
AppearTimeline.Play();
|
||||
// AppearTimeline.playableGraph.GetRootPlayable(0).SetSpeed(2.0f);
|
||||
await Awaiters.Seconds(SpeedUpSeconds(AppearJumpDelay));
|
||||
}
|
||||
|
||||
private async Task OnAttacking()
|
||||
{
|
||||
Log("OnAttacking");
|
||||
BreakTimeline.initialTime = 0;
|
||||
BreakTimeline?.Play();
|
||||
}
|
||||
|
||||
public void OnLocked()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
|
||||
AppearTimeline.initialTime = 0;
|
||||
AppearTimeline.Evaluate();
|
||||
AppearTimeline.Stop();
|
||||
|
||||
}
|
||||
private void OnUnlocked()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
|
||||
AppearTimeline.initialTime = AppearTimeline.duration;
|
||||
AppearTimeline.Evaluate();
|
||||
AppearTimeline.Stop();
|
||||
|
||||
}
|
||||
private void OnBroken()
|
||||
{
|
||||
Log("OnBroken");
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
///////
|
||||
public async Task UpdateState(CBoxState state)
|
||||
{
|
||||
Log($"UpdateState({state})");
|
||||
switch (state)
|
||||
{
|
||||
case CBoxState.UnLocked:
|
||||
OnUnlocked();
|
||||
break;
|
||||
case CBoxState.Broken:
|
||||
OnBroken();
|
||||
break;
|
||||
case CBoxState.Locked:
|
||||
OnLocked();
|
||||
break;
|
||||
case CBoxState.UnLocking:
|
||||
await OnUnLocking();
|
||||
break;
|
||||
case CBoxState.Attacking:
|
||||
await OnAttacking();
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(state), state, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc1140f992414538bad245ce04d3fbb6
|
||||
timeCreated: 1754313414
|
||||
61
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeKiller.cs
Normal file
61
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeKiller.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using PlayFab.Internal;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 挂在到鳄鱼或者其他东西身上
|
||||
/// </summary>
|
||||
///
|
||||
public class ChallengeKiller : MonoBehaviour
|
||||
{
|
||||
|
||||
[Header("下沉上浮动画")]
|
||||
[SerializeField]
|
||||
private Animation aniOnOrOff;
|
||||
[SerializeField]
|
||||
private string startActionName;
|
||||
[SerializeField]
|
||||
private string endActionName;
|
||||
|
||||
|
||||
[Header("Eye眨眼动画")]
|
||||
[SerializeField] private Animation aniEye;
|
||||
//
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Log("Awake");
|
||||
}
|
||||
|
||||
public async Task OnAttackingStart(float actionTime = 0.3f)
|
||||
{
|
||||
if (aniOnOrOff)
|
||||
{
|
||||
aniOnOrOff.Play(startActionName);
|
||||
}
|
||||
await Awaiters.Seconds(actionTime);
|
||||
}
|
||||
|
||||
public async Task OnAttackingEnd(float actionTime = 0.3f)
|
||||
{
|
||||
if (aniOnOrOff)
|
||||
{
|
||||
aniOnOrOff.Play(endActionName);
|
||||
}
|
||||
await Awaiters.Seconds(actionTime);
|
||||
}
|
||||
public void OnIdle()
|
||||
{
|
||||
if (aniEye)
|
||||
{
|
||||
aniEye.Play();
|
||||
}
|
||||
}
|
||||
|
||||
private void Log(object t)
|
||||
{
|
||||
Debug.Log($"Killer -> {t}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c85ccfc62ebe40bfac5102be7962f23b
|
||||
timeCreated: 1754313533
|
||||
103
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchScene.cs
Normal file
103
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchScene.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UniRx;
|
||||
|
||||
|
||||
// 不要删,下个可直接拿来用
|
||||
public class ChallengeMatchPlayEvent
|
||||
{
|
||||
public int step;//当前步骤减一
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
public class ChallengeMatchPlayGMEvent
|
||||
{
|
||||
public int step;//当前步骤减一
|
||||
}
|
||||
|
||||
#endif
|
||||
public class ChallengeMatchScene : MonoBehaviour
|
||||
{
|
||||
public PlayableDirector playableDirector;
|
||||
double _targetTime;
|
||||
bool _isPlaying;
|
||||
protected CompositeDisposable disposables = new CompositeDisposable();
|
||||
private void Start()
|
||||
{
|
||||
playableDirector.played += OnTimelinePlayed;
|
||||
playableDirector.paused += OnTimelinePaused;
|
||||
playableDirector.stopped += OnTimelineStopped;
|
||||
}
|
||||
void OnEnable()
|
||||
{
|
||||
_isPlaying = false;
|
||||
GContext.OnEvent<ChallengeMatchPlayEvent>().Subscribe(e => { OnPlay(e.step); }).AddTo(disposables);
|
||||
#if UNITY_EDITOR
|
||||
GContext.OnEvent<ChallengeMatchPlayGMEvent>().Subscribe(e => { OnGMPlay(e.step); }).AddTo(disposables);
|
||||
#endif
|
||||
|
||||
|
||||
// FishingChallengeCenter FCC = GContext.container.Resolve<FishingChallengeCenter>();
|
||||
var fishingChallengeManager = GContext.container.Resolve<FishingChallengeManager>();
|
||||
int step = fishingChallengeManager.fishingChallengeData.step - 1;
|
||||
if (step < 0)
|
||||
{
|
||||
step = 0;
|
||||
}
|
||||
playableDirector.initialTime = step * 1.5f;
|
||||
playableDirector.Evaluate();
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
void OnGMPlay(int step)
|
||||
{
|
||||
step = step - 1;
|
||||
if (step < 0)
|
||||
{
|
||||
step = 0;
|
||||
}
|
||||
playableDirector.Stop();
|
||||
playableDirector.initialTime = step * 1.5f;
|
||||
playableDirector.Evaluate();
|
||||
}
|
||||
#endif
|
||||
void OnPlay(int step)
|
||||
{
|
||||
playableDirector.Play();
|
||||
_targetTime = step * 1.5f;
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_isPlaying)
|
||||
{
|
||||
if (playableDirector.time >= _targetTime)
|
||||
{
|
||||
playableDirector.Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
void OnTimelinePlayed(PlayableDirector director)
|
||||
{
|
||||
_isPlaying = true;
|
||||
}
|
||||
|
||||
void OnTimelinePaused(PlayableDirector director)
|
||||
{
|
||||
_isPlaying = false;
|
||||
}
|
||||
|
||||
void OnTimelineStopped(PlayableDirector director)
|
||||
{
|
||||
_isPlaying = false;
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
disposables?.Dispose();
|
||||
disposables = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11854fd50c96b0a43b84db5b0473aea7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
247
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchScene1.cs
Normal file
247
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchScene1.cs
Normal file
@@ -0,0 +1,247 @@
|
||||
using System.Threading.Tasks;
|
||||
using asap.core;
|
||||
using Cinemachine;
|
||||
using UniRx;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChallengeCleanStageEvent
|
||||
{
|
||||
public int stage;
|
||||
public readonly TaskCompletionSource<bool> Tcs = new ();
|
||||
}
|
||||
|
||||
public class ChallengeBrokeStepEvent
|
||||
{
|
||||
public int step;
|
||||
public float dealyTime;
|
||||
public readonly TaskCompletionSource<bool> Tcs = new();
|
||||
}
|
||||
|
||||
public class ChallengeInitStepEvent
|
||||
{
|
||||
public int step;
|
||||
}
|
||||
|
||||
public class ChallengeSetAnimationEvent
|
||||
{
|
||||
public float speed;
|
||||
public float timeForUnlocking;
|
||||
public float timeForUnLockingEnd;
|
||||
public float timeForAttacking_1;
|
||||
public float timeForAttacking_2;
|
||||
public float timeForAttackStart;
|
||||
public float timeForAttackEnd;
|
||||
public float timeForAttackEndWait;
|
||||
}
|
||||
|
||||
|
||||
public class ChallengeMatchScene1 : MonoBehaviour
|
||||
{
|
||||
|
||||
// private Transform _challengeStatic;
|
||||
// private Transform _challengeDynamic;
|
||||
private Transform _camera;
|
||||
// 想法是以后绑定一个 大奖 + 台子区域的点 到 当前的场景Node,或者直接坐在 场景Prefab 中,看看是否可实现
|
||||
// private Transform _rewardNode;
|
||||
// 管卡容器
|
||||
[SerializeField] private ChallengeBox[] boxNodeContainer;
|
||||
|
||||
|
||||
[Header("设计宽高以及分辨率")]
|
||||
|
||||
|
||||
|
||||
[SerializeField] private float designMinWidth = 1080f;
|
||||
[SerializeField] private float designMinHeight = 2160f;
|
||||
[SerializeField] private float designMaxWidth = 1080f;
|
||||
[SerializeField] private float designMaxHeight = 1920f;
|
||||
[SerializeField] private float designOrthoSize = 5f;
|
||||
|
||||
//
|
||||
private int _lastWidth;
|
||||
private int _lastHeight;
|
||||
|
||||
|
||||
// 修改平行和投影视图
|
||||
private CinemachineVirtualCamera _vCam;
|
||||
// 数据管理
|
||||
private FishingChallengeManager _fishingChallengeManager;
|
||||
//
|
||||
private CompositeDisposable _disposables = new();
|
||||
|
||||
// 当前 的Step
|
||||
private int _curStep;
|
||||
// private int _curScore;
|
||||
|
||||
public float CalcOrthographicSize()
|
||||
{
|
||||
// if (_camera == null) return;
|
||||
// 计算设计宽高比和当前宽高比
|
||||
float designMinAspect = designMinWidth/designMinHeight;
|
||||
float designMaxAspect = designMaxWidth/designMaxHeight;
|
||||
float currentAspect = Screen.width/(float)Screen.height ;
|
||||
|
||||
currentAspect = Mathf.Clamp(currentAspect, designMinAspect, designMaxAspect);
|
||||
var size = designOrthoSize * designMaxAspect/currentAspect;
|
||||
|
||||
Log($"CalcOrthographicSize ->{size}");
|
||||
return size;
|
||||
}
|
||||
|
||||
private void ApplyCameraScale()
|
||||
{
|
||||
if (Screen.width == _lastWidth && Screen.height == _lastHeight) return;
|
||||
_vCam.m_Lens.OrthographicSize = CalcOrthographicSize();
|
||||
_lastWidth = Screen.width;
|
||||
_lastHeight = Screen.height;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// Log("Awake -> ");
|
||||
// _challengeStatic = transform.Find("challenge_static");
|
||||
// _challengeDynamic = transform.Find("challenge_dynamic");
|
||||
_camera = transform.Find("CameraRoot/Camera");
|
||||
// _rewardNode = transform.Find("RewardNode");
|
||||
|
||||
_vCam = _camera.GetComponent<CinemachineVirtualCamera>();
|
||||
// _vCam.m_Lens.Orthographic = true;
|
||||
// _vCam.m_Lens.OrthographicSize = CalcOrthographicSize(); // 设置所需大小
|
||||
_fishingChallengeManager = GContext.container.Resolve<FishingChallengeManager>();
|
||||
// 当前场景的阶段
|
||||
_curStep = _fishingChallengeManager.fishingChallengeData.step;
|
||||
// _curScore = _fishingChallengeManager.fishingChallengeData.Score;
|
||||
OnAddEvents();
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
_curStep = (_curStep + 1) % (_fishingChallengeManager.GetFullStep() + 1);
|
||||
InitCurStep();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.V))
|
||||
{
|
||||
var e = new ChallengeCleanStageEvent
|
||||
{
|
||||
stage = 1,
|
||||
};
|
||||
OnUpdateStage(e);
|
||||
}
|
||||
ApplyCameraScale();
|
||||
}
|
||||
private void OnGMInitStep(ChallengeInitStepEvent evt)
|
||||
{
|
||||
_curStep = evt.step;
|
||||
InitCurStep();
|
||||
}
|
||||
#endif
|
||||
void OnChallengeTimeEvent(ChallengeSetAnimationEvent e)
|
||||
{
|
||||
foreach (var box in boxNodeContainer)
|
||||
{
|
||||
box.UpdateTimeController(e);
|
||||
}
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
Log("Start");
|
||||
// _vCam.Priority = 0; // 设置低优先级使其他相机接管
|
||||
// #if UNITY_EDITOR
|
||||
// EditorApplication.QueuePlayerLoopUpdate();
|
||||
// #endif
|
||||
OnSceneStart();
|
||||
}
|
||||
//
|
||||
private void OnAddEvents()
|
||||
{
|
||||
GContext.OnEvent<ChallengeCleanStageEvent>().Subscribe(OnUpdateStage).AddTo(_disposables);
|
||||
GContext.OnEvent<ChallengeBrokeStepEvent>().Subscribe(OnBrokeStep).AddTo(_disposables);
|
||||
#if UNITY_EDITOR
|
||||
GContext.OnEvent<ChallengeInitStepEvent>().Subscribe(OnGMInitStep).AddTo(_disposables);
|
||||
#endif
|
||||
GContext.OnEvent<ChallengeSetAnimationEvent>().Subscribe(OnChallengeTimeEvent).AddTo(_disposables);
|
||||
|
||||
}
|
||||
private void OnSceneStart()
|
||||
{
|
||||
InitCurStep();
|
||||
}
|
||||
private void InitCurStep()
|
||||
{
|
||||
Log($"InitCurStep -> _curStep = {_curStep}");
|
||||
var curIndex = _curStep - 1;
|
||||
var maxNum = boxNodeContainer.Length;
|
||||
for (var i = curIndex + 1; i < maxNum; ++i)
|
||||
{
|
||||
_ = boxNodeContainer[i].UpdateState(CBoxState.Locked);
|
||||
}
|
||||
if (curIndex < 0 || curIndex > boxNodeContainer.Length)
|
||||
return;
|
||||
|
||||
for (var i = 0; i <= curIndex; ++i)
|
||||
{
|
||||
_ = boxNodeContainer[i].UpdateState(CBoxState.Broken);
|
||||
}
|
||||
_ = boxNodeContainer[curIndex].UpdateState(CBoxState.UnLocked);
|
||||
}
|
||||
private async void OnUpdateStage(ChallengeCleanStageEvent upStepEvent)
|
||||
{
|
||||
// Log("UpdateCurStep()");
|
||||
var stageIndex = upStepEvent.stage - 1;
|
||||
if (stageIndex >= 0)
|
||||
{
|
||||
await boxNodeContainer[stageIndex].UpdateState(CBoxState.UnLocking);
|
||||
// await Awaiters.Seconds(0.5f);
|
||||
}
|
||||
upStepEvent.Tcs.SetResult(true);
|
||||
}
|
||||
|
||||
private async void OnBrokeStep(ChallengeBrokeStepEvent brokeEvent)
|
||||
{
|
||||
var step = brokeEvent.step - 1;
|
||||
if (step >= 0 && step < boxNodeContainer.Length)
|
||||
{
|
||||
await Awaiters.Seconds(brokeEvent.dealyTime);
|
||||
await boxNodeContainer[step].UpdateState(CBoxState.Attacking);
|
||||
}
|
||||
brokeEvent.Tcs.SetResult(true);
|
||||
}
|
||||
//
|
||||
private void OnEnable()
|
||||
{
|
||||
Log("OnEnable");
|
||||
_vCam.m_Lens.Orthographic = true;
|
||||
_vCam.m_Lens.OrthographicSize = CalcOrthographicSize();; // 设置所需大小
|
||||
|
||||
|
||||
_lastWidth = Screen.width;
|
||||
_lastHeight = Screen.height;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_vCam)
|
||||
{
|
||||
_vCam.m_Lens.Orthographic = false;
|
||||
if (Camera.main != null)
|
||||
{
|
||||
var brain = Camera.main.GetComponent<CinemachineBrain>();
|
||||
brain?.ManualUpdate();
|
||||
}
|
||||
}
|
||||
_disposables?.Dispose();
|
||||
_disposables = null;
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
|
||||
}
|
||||
private void Log(object t)
|
||||
{
|
||||
Debug.Log($"<color=#00ff00> ChallengeMatchScene -> {t} </color>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3abf7b0d82faf4847bff62703ca1bb82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
555
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchSceneUI.cs
Normal file
555
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchSceneUI.cs
Normal file
@@ -0,0 +1,555 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
using UnityEngine.UI;
|
||||
using game;
|
||||
using System.Threading.Tasks;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using TMPro;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
|
||||
public class ChallengeShowPlayerEvent
|
||||
{
|
||||
public int oldStep;
|
||||
}
|
||||
public class ChallengePlayAniEvent
|
||||
{
|
||||
public int oldStep;
|
||||
public int newStep;
|
||||
public TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
|
||||
}
|
||||
public class ChallengeFailEvent
|
||||
{
|
||||
public int oldStep;
|
||||
public TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
|
||||
}
|
||||
|
||||
// 定义显示Tips
|
||||
//
|
||||
public class ChallengeLevelTipsEvent
|
||||
{
|
||||
public bool IsGm;
|
||||
public int oldScore;
|
||||
public int newScore;
|
||||
public TaskCompletionSource<bool> tcs = new();
|
||||
}
|
||||
|
||||
public class ShowResidueNumEvent
|
||||
{
|
||||
public int num;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 比赛场景中显示头像奖励等的UI,挂载与比赛场景上
|
||||
public class ChallengeMatchSceneUI : MonoBehaviour
|
||||
{
|
||||
//
|
||||
private Transform icon_reward;
|
||||
private Transform text_title;
|
||||
private Transform _textNumCash;
|
||||
|
||||
|
||||
// 地点
|
||||
public ChallengeMatchSceneUIRegion[] uiRegion;
|
||||
|
||||
public GameObject[] tipPlaceHolder;
|
||||
|
||||
public GameObject eventChallengeHead;
|
||||
|
||||
private EventChallengeLevelTips _levelTipController;
|
||||
|
||||
private FishingChallengeManager _fishingChallengeManager;
|
||||
|
||||
private List<EventChallengeHead> _headList = new();
|
||||
|
||||
private EventChallengeHead _myHead;
|
||||
|
||||
private int count;
|
||||
|
||||
private CompositeDisposable _disposables = new();
|
||||
|
||||
|
||||
// 本人起跳间隔
|
||||
[Header("本人起跳到其他人开始起跳")]
|
||||
public float jumpIntervalMy = 0.1f;
|
||||
//起跳间隔
|
||||
[Header("其他人起跳开始间隔")]
|
||||
public float jumpInterval = 0.1f;
|
||||
// 最后一个起跳到淘汰时间
|
||||
[Header("最后一人起跳到开始落水")]
|
||||
public float jumpToEliminateTime = 0.6f;
|
||||
// 落水到平台下沉时间
|
||||
// [Header("开始落水到沉船")]
|
||||
// public float eliminateToPlatformTime = 0.5f;
|
||||
//int maxCount = 3;
|
||||
[Header("每个人落水间隔")] public float eliminateInterval = 0.01f;
|
||||
|
||||
[Header("跳水动画时长")] public float jumpDuration = 0.6f;
|
||||
|
||||
[Header("淘汰落水时长")] public float jumpDead = 0.2f;
|
||||
|
||||
[Header("箱子破坏前延时")] public float BreakDuration = 0.1f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_fishingChallengeManager = GContext.container.Resolve<FishingChallengeManager>();
|
||||
GetComponent<Canvas>().worldCamera = Camera.main;
|
||||
_levelTipController = transform.Find("EventChallengeLevelTips").GetComponent<EventChallengeLevelTips>();
|
||||
// _levelTipController.SetSpeed(speed);
|
||||
// _levelTipController.UpdateControllerTime(uptime1, wait2, wait3);
|
||||
|
||||
// var evt = new ChallengeSetAnimationEvent()
|
||||
// {
|
||||
// speed = speed,
|
||||
// timeForUnlocking = _timeForUnlocking,
|
||||
// timeForUnLockingEnd = _timeForUnlockingEnd,
|
||||
// timeForAttacking_1 = _timeForAttacking_1,
|
||||
// timeForAttacking_2 = _timeForAttacking_2,
|
||||
// timeForAttackStart = _timeForAttackStart,
|
||||
// timeForAttackEnd = _timeForAttackEnd,
|
||||
// timeForAttackEndWait = _timeForAttackEndEnd,
|
||||
// };
|
||||
// GContext.Publish(evt);
|
||||
|
||||
|
||||
icon_reward = transform.Find("taizi_reward/icon_reward/icon_reward");
|
||||
text_title = transform.Find("taizi_reward/total_reward/text_title");
|
||||
_textNumCash = transform.Find("taizi_reward/total_reward/text_num_cash");
|
||||
|
||||
|
||||
|
||||
GContext.OnEvent<ChallengeShowPlayerEvent>().Subscribe(ShowPlayer).AddTo(_disposables);
|
||||
GContext.OnEvent<ChallengePlayAniEvent>().Subscribe(PlayAni).AddTo(_disposables);
|
||||
GContext.OnEvent<ChallengeFailEvent>().Subscribe(OnFail).AddTo(_disposables);
|
||||
GContext.OnEvent<ChallengeLevelTipsEvent>().Subscribe(OnShowLevelTips).AddTo(_disposables);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
var listItemData = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(_fishingChallengeManager.eventChallengeMain.WinnerReward);
|
||||
var totalCount = listItemData.Sum(itemData => itemData.count);
|
||||
_textNumCash.GetComponent<TMP_Text>().text = "x" + ConvertTools.GetNumberString(totalCount);
|
||||
InitLevelTip(_fishingChallengeManager.fishingChallengeData.ProcessedScore);
|
||||
}
|
||||
|
||||
public void InitLevelTip(int score )
|
||||
{
|
||||
var step = _fishingChallengeManager.GetStepByScore(score,true);
|
||||
if (step > tipPlaceHolder.Length - 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_levelTipController.transform.localPosition = tipPlaceHolder[step].transform.localPosition;
|
||||
_levelTipController.gameObject.SetActive(true);
|
||||
_levelTipController.Init(score);
|
||||
}
|
||||
private void ShowPlayer(ChallengeShowPlayerEvent challengeShowPlayerEvent)
|
||||
{
|
||||
var oldStep = challengeShowPlayerEvent.oldStep;
|
||||
var robots = GContext.container.Resolve<cfg.Tables>().TbRobot.DataMap;
|
||||
var uiService = GContext.container.Resolve<IUIService>();
|
||||
var randomPos = uiRegion[oldStep];
|
||||
var posTran = randomPos.posTran;
|
||||
var myself = randomPos.myself;
|
||||
|
||||
if (_headList.Count > 0)
|
||||
{
|
||||
_headList.ForEach(x => Destroy(x.gameObject));
|
||||
_headList.Clear();
|
||||
Destroy(_myHead.gameObject);
|
||||
}
|
||||
var residual = posTran.Count;
|
||||
for (int i = 0; i < residual; i++)
|
||||
{
|
||||
GameObject go = Instantiate(eventChallengeHead.gameObject, posTran[i]);
|
||||
go.transform.localScale = Vector3.one;
|
||||
go.transform.localPosition = Vector3.zero;
|
||||
var head = go.GetComponent<EventChallengeHead>();
|
||||
if (robots.TryGetValue(_fishingChallengeManager.fishingChallengeData.robotAccountList[i], out cfg.Robot robot))
|
||||
{
|
||||
uiService.SetHeadImage(head.icon_head, robot.Avatar);
|
||||
}
|
||||
_headList.Add(head);
|
||||
}
|
||||
|
||||
_myHead = Instantiate(eventChallengeHead.gameObject, myself).GetComponent<EventChallengeHead>();
|
||||
_myHead.transform.localScale = Vector3.one;
|
||||
_myHead.transform.localPosition = Vector3.zero;
|
||||
_myHead.bg_head_myself.SetActive(true);
|
||||
uiService.SetHeadImage(_myHead.icon_head, GContext.container.Resolve<IUserService>().AvatarUrl);
|
||||
count = _headList.Count;
|
||||
}
|
||||
|
||||
////打乱headList顺序
|
||||
// void Shuffle(int curCount)
|
||||
// {
|
||||
// var newHeadList = new List<EventChallengeHead>();
|
||||
// var robotAccountList = new List<int>();
|
||||
// int index = 0;
|
||||
// for (int i = 0; i < curCount; i++)
|
||||
// {
|
||||
// newHeadList.Insert(index, _headList[i]);
|
||||
// robotAccountList.Insert(index, _fishingChallengeManager.fishingChallengeData.robotAccountList[i]);
|
||||
// index = UnityEngine.Random.Range(0, newHeadList.Count + 1);
|
||||
// }
|
||||
// _headList = newHeadList;
|
||||
// _fishingChallengeManager.fishingChallengeData.robotAccountList = robotAccountList;
|
||||
// }
|
||||
#if UNITY_EDITOR
|
||||
bool isShow;
|
||||
string oldStepStr, newStepStr;
|
||||
private string _scoreStr; // 添加到渔获的价值
|
||||
private int _level;
|
||||
string oldScoreStr, newScoreStr;
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.K))
|
||||
{
|
||||
isShow = !isShow;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
_level = (_level + 1) % 7;
|
||||
// _tipController.transform.localPosition = tipPlaceHolder[_level].transform.localPosition;
|
||||
LocationLevelTips(_level);
|
||||
}
|
||||
|
||||
}
|
||||
private async void OnGUI()
|
||||
{
|
||||
|
||||
GUILayout.Label($"当前段位: {_fishingChallengeManager.eventChallengeMain.ID}");
|
||||
|
||||
if (!isShow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Set the button width and height
|
||||
float buttonWidth = 300; // Replace with your desired width
|
||||
float buttonHeight = 70; // Replace with your desired height
|
||||
int fontSize = 40; // Replace with your desired font size
|
||||
|
||||
// Set the font size for text fields, buttons, and labels
|
||||
GUI.skin.textField.fontSize = fontSize;
|
||||
GUI.skin.button.fontSize = fontSize;
|
||||
GUI.skin.label.fontSize = fontSize;
|
||||
// 触发ChallengeShowPlayAniEvent 事件并能输入oldStep和newStep
|
||||
GUILayout.Label("oldStep:");
|
||||
oldStepStr = GUILayout.TextField(oldStepStr, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight));
|
||||
int.TryParse(oldStepStr, out int oldStep);
|
||||
if (GUILayout.Button("Fail"))
|
||||
{
|
||||
GContext.Publish(new ChallengeMatchPlayGMEvent() { step = oldStep });
|
||||
ShowPlayer(new ChallengeShowPlayerEvent { oldStep = oldStep });
|
||||
await Awaiters.Seconds(0.5f);
|
||||
ChallengeFailEvent challengeFailEvent = new ChallengeFailEvent();
|
||||
challengeFailEvent.oldStep = oldStep;
|
||||
OnFail(challengeFailEvent);
|
||||
}
|
||||
GUILayout.Label("newStep:");
|
||||
newStepStr = GUILayout.TextField(newStepStr, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight));
|
||||
int.TryParse(newStepStr, out int newStep);
|
||||
if (GUILayout.Button("PlayAni", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
|
||||
{
|
||||
GContext.Publish(new ChallengeMatchPlayGMEvent() { step = oldStep });
|
||||
ShowPlayer(new ChallengeShowPlayerEvent { oldStep = oldStep });
|
||||
await Awaiters.Seconds(0.5f);
|
||||
var challengePlayAniEvent = new ChallengePlayAniEvent();
|
||||
challengePlayAniEvent.oldStep = oldStep;
|
||||
challengePlayAniEvent.newStep = newStep;
|
||||
PlayAni(challengePlayAniEvent);
|
||||
}
|
||||
|
||||
GUILayout.Label("QualityScore:");
|
||||
_scoreStr = GUILayout.TextField(_scoreStr,GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight));
|
||||
int.TryParse(_scoreStr, out var score);
|
||||
_fishingChallengeManager.SetQualityScore(score);
|
||||
|
||||
|
||||
GUILayout.Label("oldScore:");
|
||||
oldScoreStr = GUILayout.TextField(oldScoreStr, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight));
|
||||
int.TryParse(oldScoreStr, out var oldScore);
|
||||
//
|
||||
GUILayout.Label("newScore:");
|
||||
newScoreStr = GUILayout.TextField(newScoreStr, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight));
|
||||
int.TryParse(newScoreStr, out var newScore);
|
||||
//
|
||||
if (GUILayout.Button("RunNewPlay", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
|
||||
{
|
||||
// GContext.Publish(new ChallengeMatchPlayGMEvent() { step = oldStep });
|
||||
var nStep = _fishingChallengeManager.GetStepByScore(oldScore,true);
|
||||
var evt = new ChallengeInitStepEvent()
|
||||
{
|
||||
step = nStep
|
||||
};
|
||||
GContext.Publish(evt);
|
||||
await Awaiters.NextFrame;
|
||||
ShowPlayer(new ChallengeShowPlayerEvent { oldStep = nStep });
|
||||
await Awaiters.Seconds(0.5f);
|
||||
// 全部重置
|
||||
|
||||
var tipsEvent = new ChallengeLevelTipsEvent()
|
||||
{
|
||||
IsGm = true,
|
||||
oldScore = oldScore,
|
||||
newScore = newScore,
|
||||
};
|
||||
//OnShowLevelTips(tipsEvent);
|
||||
GContext.Publish(tipsEvent);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
private async void PlayAni(ChallengePlayAniEvent challengePlayAniEvent)
|
||||
{
|
||||
var oldStep = challengePlayAniEvent.oldStep;
|
||||
var newStep = challengePlayAniEvent.newStep;
|
||||
ChallengeMatchSceneUIRegion randomPos;
|
||||
List<Transform> posTran;
|
||||
Transform myself;
|
||||
|
||||
/// 更新剩余人数
|
||||
ShowResidueNumEvent showResidueNumEvent = new ShowResidueNumEvent();
|
||||
var eliminateNumber = _fishingChallengeManager.fishingChallengeData.eliminateNumber;
|
||||
var newEliminate = _fishingChallengeManager.CalcResidualNumber(oldStep);
|
||||
showResidueNumEvent.num = newEliminate;
|
||||
GContext.Publish(showResidueNumEvent);
|
||||
//
|
||||
|
||||
float speed = 1;
|
||||
if (newStep > oldStep + 1)
|
||||
{
|
||||
speed = 0.7f;
|
||||
}
|
||||
|
||||
//var uiRegionNum = uiRegion.Length;
|
||||
//从oldStep到newStep
|
||||
var brokeStepEvent = new ChallengeBrokeStepEvent
|
||||
{
|
||||
step = oldStep,
|
||||
dealyTime = BreakDuration,
|
||||
};
|
||||
for (int i = oldStep; i < newStep; i++)
|
||||
{
|
||||
var regionIdx = Math.Min(uiRegion.Length - 1, i + 1);
|
||||
randomPos = uiRegion[regionIdx];
|
||||
posTran = randomPos.posTran;
|
||||
myself = randomPos.myself;
|
||||
int residual = posTran.Count;
|
||||
// for (int j = 0; j < residual; j++)
|
||||
// {
|
||||
// _headList[j].rectTransform.SetParent(posTran[j]);
|
||||
// }
|
||||
// for (int j = residual; j < count; j++)
|
||||
// {
|
||||
// _headList[j].rectTransform.SetParent(posTran[residual - 1]);
|
||||
// }
|
||||
_myHead.rectTransform.SetParent(myself);
|
||||
_myHead.rectTransform.localScale = Vector3.one;
|
||||
_myHead.rectTransform.DOLocalMove(Vector3.zero,jumpDuration);
|
||||
_myHead.headAni.Play("fx_anim_eventchallengehead_jump_success_01");
|
||||
// 头狼起调
|
||||
var myJumpAudioName = uiRegion[i].myJumpAudioName;
|
||||
if (!string.IsNullOrEmpty(myJumpAudioName))
|
||||
{
|
||||
GContext.Publish(new EventUISound(myJumpAudioName));
|
||||
}
|
||||
await Awaiters.Seconds(jumpIntervalMy * speed);
|
||||
// 跟随起跳
|
||||
var followerJumpAudioName = uiRegion[i].followerJumpAudioName;
|
||||
if (!string.IsNullOrEmpty(myJumpAudioName))
|
||||
{
|
||||
GContext.Publish(new EventUISound(followerJumpAudioName));
|
||||
}
|
||||
for (int j = 0; j < residual; j++)
|
||||
{
|
||||
await Awaiters.Seconds(jumpInterval * speed);
|
||||
_headList[j].rectTransform.SetParent(posTran[j]);
|
||||
_headList[j].rectTransform.DOLocalMove(Vector3.zero, jumpDuration).SetEase(Ease.OutCubic);
|
||||
_headList[j].rectTransform.DOScale(Vector3.one, jumpDuration).SetEase(Ease.OutCubic);
|
||||
_headList[j].headAni.Play("fx_anim_eventchallengehead_jump_success_01");
|
||||
}
|
||||
var posTranRect = uiRegion[i].posTranRect;
|
||||
//淘汰动画
|
||||
await Awaiters.Seconds(jumpToEliminateTime * speed);
|
||||
// 播放动画声音
|
||||
var audioName = uiRegion[i].fallAudioName;
|
||||
if (!string.IsNullOrEmpty(audioName)){
|
||||
GContext.Publish(new EventUISound(audioName));
|
||||
}
|
||||
|
||||
//
|
||||
int tranCount = posTranRect.Count;
|
||||
RectTransform rectPos = posTranRect[0];
|
||||
float width = 0, height = 0;
|
||||
|
||||
if (residual >= count)
|
||||
{
|
||||
GContext.Publish(brokeStepEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = residual; j < count; j++)
|
||||
{
|
||||
if (tranCount > j - residual)
|
||||
{
|
||||
rectPos = posTranRect[j - residual];
|
||||
width = rectPos.rect.width / 2;
|
||||
height = rectPos.rect.height / 2;
|
||||
}
|
||||
|
||||
Vector3 vector3 = new Vector3(UnityEngine.Random.Range(-width, width),
|
||||
UnityEngine.Random.Range(-height, height), 0);
|
||||
await Awaiters.Seconds(eliminateInterval * speed);
|
||||
_headList[j].rectTransform.SetParent(rectPos);
|
||||
_headList[j].rectTransform.DOScale(Vector3.one, jumpDead).SetEase(Ease.Linear);
|
||||
_headList[j].rectTransform.DOLocalMove(vector3, jumpDead).SetEase(Ease.Linear);
|
||||
_headList[j].headAni.Play("fx_anim_eventchallengehead_jump_defeat_01");
|
||||
if (j == residual)
|
||||
{
|
||||
// 播放破坏动画
|
||||
GContext.Publish(brokeStepEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//从i到i+1平台,起点0不动
|
||||
if (i > 0)
|
||||
{
|
||||
// await Awaiters.Seconds(eliminateToPlatformTime * speed );
|
||||
GContext.Publish(new ChallengeMatchPlayEvent() { step = i });
|
||||
}
|
||||
|
||||
count = residual;
|
||||
newEliminate -= eliminateNumber[i];
|
||||
showResidueNumEvent.num = newEliminate;
|
||||
GContext.Publish(showResidueNumEvent);
|
||||
|
||||
// if (i < eliminateNumber.Count - 2)
|
||||
// {
|
||||
// _fishingChallengeManager.AddStageReward(i);
|
||||
// }
|
||||
|
||||
// 直接写添加奖品
|
||||
// var itemDataList = playerItemData.GetItemDataByDropId(eventChallengeMain.StageReward[newStep], fishingChallengeData.mapId);
|
||||
// playerItemData.AddItem(itemDataList);
|
||||
await Awaiters.Seconds(1f * speed);
|
||||
await brokeStepEvent.Tcs.Task; //
|
||||
}
|
||||
challengePlayAniEvent.tcs.SetResult(true);
|
||||
}
|
||||
private async void OnFail(ChallengeFailEvent challengeFailEvent)
|
||||
{
|
||||
int oldStep = challengeFailEvent.oldStep;
|
||||
var rectPos = uiRegion[oldStep].myselfRect;
|
||||
//淘汰动画
|
||||
float width = rectPos.rect.width / 2;
|
||||
float height = rectPos.rect.height / 2;
|
||||
Vector3 vector3 = new Vector3(UnityEngine.Random.Range(-width, width), UnityEngine.Random.Range(-height, height), 0);
|
||||
_myHead.rectTransform.SetParent(rectPos);
|
||||
_myHead.rectTransform.localScale = Vector3.one;
|
||||
_myHead.rectTransform.DOLocalMove(vector3, 0.2f).SetEase(Ease.Linear);
|
||||
_myHead.headAni.Play("fx_anim_eventchallengehead_jump_defeat_01");
|
||||
await Awaiters.Seconds(1f);
|
||||
challengeFailEvent.tcs.SetResult(true);
|
||||
}
|
||||
|
||||
// 注意多组的情况,根据分数算,可能要跳好多次
|
||||
private async void OnShowLevelTips(ChallengeLevelTipsEvent tipsEvent)
|
||||
{
|
||||
Log("OnShowLevelTips");
|
||||
var oldScore = tipsEvent.oldScore;
|
||||
var newScore = tipsEvent.newScore;
|
||||
var isGm = tipsEvent.IsGm;
|
||||
|
||||
if (oldScore == newScore)
|
||||
{
|
||||
InitLevelTip(oldScore);
|
||||
tipsEvent.tcs.SetResult(true);
|
||||
return;
|
||||
}
|
||||
var step = _fishingChallengeManager.GetStepByScore(oldScore,true);
|
||||
var maxScore = _fishingChallengeManager.GetMaxScoreByStep(step);
|
||||
if (_levelTipController && step >= 0 && step < tipPlaceHolder.Length )
|
||||
{
|
||||
LocationLevelTips(step);
|
||||
var curScore = await _levelTipController.ShowTips(oldScore,newScore);
|
||||
// 播放显示动画
|
||||
if (maxScore == curScore)
|
||||
{
|
||||
await _levelTipController.PlayInVisibleAni();
|
||||
await ReceiveStageReward(step);
|
||||
await JumpStage(step, curScore, newScore,isGm);
|
||||
}
|
||||
}
|
||||
tipsEvent.tcs.SetResult(true);
|
||||
}
|
||||
|
||||
private void LocationLevelTips(int step)
|
||||
{
|
||||
_levelTipController.transform.localPosition = tipPlaceHolder[step].transform.localPosition;
|
||||
_levelTipController.SetCurStep(step);
|
||||
_levelTipController.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
// 看看需要加什么动画类的东西么
|
||||
public async Task ReceiveStageReward(int step)
|
||||
{
|
||||
Log($"ReceiveStageReward {step}");
|
||||
_fishingChallengeManager.AddStageReward(step);
|
||||
}
|
||||
|
||||
private static async Task JumpStage(int step, int curScore, int newScore,bool isGm)
|
||||
{
|
||||
Log("JumpStage");
|
||||
// 清理下一个台子
|
||||
var cleanEvent = new ChallengeCleanStageEvent
|
||||
{
|
||||
stage = step + 1,
|
||||
};
|
||||
GContext.Publish(cleanEvent);
|
||||
await cleanEvent.Tcs.Task;
|
||||
|
||||
// 播放跳跃动画
|
||||
var cspe = new ChallengePlayAniEvent() { oldStep = step, newStep = step + 1 };
|
||||
GContext.Publish(cspe);
|
||||
await cspe.tcs.Task;
|
||||
|
||||
// // 播放破坏动画
|
||||
// var brokeStepEvent = new ChallengeBrokeStepEvent { step = step };
|
||||
// GContext.Publish(brokeStepEvent);
|
||||
// await brokeStepEvent.Tcs.Task;
|
||||
|
||||
// -- 进入下一个循环
|
||||
// if (curScore != newScore || newScore == maxScore)
|
||||
// {
|
||||
var nextStageEvent = new ChallengeLevelTipsEvent
|
||||
{
|
||||
oldScore = curScore,
|
||||
newScore = newScore,
|
||||
IsGm = isGm,
|
||||
};
|
||||
GContext.Publish(nextStageEvent);
|
||||
await nextStageEvent.tcs.Task;
|
||||
// }
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
_disposables?.Dispose();
|
||||
_disposables = null;
|
||||
}
|
||||
|
||||
private static void Log(object message)
|
||||
{
|
||||
Debug.Log($"<color=orange>ChallengeMatchSceneUI => {message} </color>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e73184c4395c5304fb7096669602544c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class ChallengeMatchSceneUIRegion : MonoBehaviour
|
||||
{
|
||||
public List<Transform> posTran;
|
||||
public List<RectTransform> posTranRect;
|
||||
public Transform myself;
|
||||
public RectTransform myselfRect;
|
||||
|
||||
public string myJumpAudioName;
|
||||
public string followerJumpAudioName;
|
||||
public string fallAudioName;
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
//private void Awake()
|
||||
//{
|
||||
|
||||
//}
|
||||
void Init()
|
||||
{
|
||||
myself = transform.Find("myself");
|
||||
var re = transform.Find("myself (1)");
|
||||
if (re)
|
||||
{
|
||||
myselfRect = re.GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
int count = transform.childCount;
|
||||
Transform pos;
|
||||
Transform posRect;
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
pos = transform.Find(i.ToString());
|
||||
posRect = transform.Find(i.ToString() + " (1)");
|
||||
if (posRect != null)
|
||||
{
|
||||
posTranRect.Add(posRect.GetComponent<RectTransform>());
|
||||
}
|
||||
if (pos != null)
|
||||
{
|
||||
posTran.Add(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 629538e6064fbbc4880911bdbcfa81c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/GampPlay/FishSkill.meta
Normal file
8
Assets/Scripts/GampPlay/FishSkill.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f24beaef4208866469d234ac9a51fc65
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
141
Assets/Scripts/GampPlay/FishSkill/CorruptSpSkillData.cs
Normal file
141
Assets/Scripts/GampPlay/FishSkill/CorruptSpSkillData.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using cfg;
|
||||
using UnityEngine;
|
||||
|
||||
public class CorruptSpSkillData : IFishSpSkillData
|
||||
{
|
||||
public FishSkill fishSkill { get; set; }
|
||||
public SpKillType Type { get; set; } = SpKillType.Corrupt;
|
||||
public FishSpSkillLabel spSkillLabel { get; set; }
|
||||
public Corrupt spSkill { get; set; }
|
||||
|
||||
public int StopCount { get; set; }
|
||||
public bool InProgress { get; set; }
|
||||
public bool End { get; set; }
|
||||
|
||||
public void StartSkill(FishSpSkillLabel fishSpSkill)
|
||||
{
|
||||
Type = SpKillType.Corrupt;
|
||||
|
||||
spSkillLabel = fishSpSkill;
|
||||
spSkill = fishSpSkill as Corrupt;
|
||||
End = false;
|
||||
Debug.Log("StartSkill");
|
||||
}
|
||||
|
||||
public void RefreshSkill(FishSpSkillLabel fishSpSkill)
|
||||
{
|
||||
spSkillLabel = fishSpSkill;
|
||||
spSkill = fishSpSkill as Corrupt;
|
||||
StopCount++;
|
||||
InProgress = false;
|
||||
End = false;
|
||||
Debug.Log("RefreshSkill");
|
||||
}
|
||||
|
||||
public void EndSkill()
|
||||
{
|
||||
End = true;
|
||||
Debug.Log("EndSkill");
|
||||
}
|
||||
|
||||
public string AudioScreen()
|
||||
{
|
||||
return spSkill.AudioScreen;
|
||||
}
|
||||
|
||||
public string AudioRewardFish()
|
||||
{
|
||||
return spSkill.AudioRewardFish;
|
||||
}
|
||||
|
||||
#region UI
|
||||
public string FxScreen()
|
||||
{
|
||||
return spSkill.FxScreen;
|
||||
}
|
||||
|
||||
public string FxBar()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public string FxProgressInc()
|
||||
{
|
||||
return spSkill.FxProgressInc;
|
||||
}
|
||||
|
||||
public string FxFishIcon()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Jump
|
||||
|
||||
public string FxFishJump()
|
||||
{
|
||||
return spSkill.FxFishJump;
|
||||
}
|
||||
|
||||
public string FxWater()
|
||||
{
|
||||
if (spSkill.FxWater == "None")
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return spSkill.FxWater;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Struggle
|
||||
|
||||
public string FxFishSkillAppend()
|
||||
{
|
||||
if (spSkill.FxFishSkillAppend == "None")
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return spSkill.FxFishSkillAppend;
|
||||
}
|
||||
/// <summary>
|
||||
/// 鱼起跳的时候,立刻在Root处挂上一个特效
|
||||
/// </summary>
|
||||
public string FxFishJumpWater()
|
||||
{
|
||||
return spSkill.FxFishJumpWater;
|
||||
}
|
||||
/// <summary>
|
||||
/// 鱼起跳的时候,立刻在Root处挂上一个特效
|
||||
/// </summary>
|
||||
public string FxFishStruggle()
|
||||
{
|
||||
return spSkill.FxFishStruggle;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public BarTarget GetBarTarget()
|
||||
{
|
||||
BarTarget barTarget = new BarTarget();
|
||||
barTarget.CorruptSpeed = spSkill.CorruptSpeed;
|
||||
barTarget.ClearSpeed = spSkill.ClearSpeed;
|
||||
barTarget.CorruptMaxPercent = spSkill.CorruptMaxPercent;
|
||||
barTarget.CorruptBarIncPercent = spSkill.CorruptBarIncPercent;
|
||||
barTarget.CorruptBarDecPercent = spSkill.CorruptBarDecPercent;
|
||||
barTarget.fx_target_bar_bg = spSkill.FxBarBottom;
|
||||
barTarget.fx_target_bar = spSkill.FxBar; ;
|
||||
barTarget.fx_target_bar_highlight = spSkill.FxProgressInc;
|
||||
barTarget.bar_target = spSkill.BarBg;
|
||||
barTarget.highlight = spSkill.EdgeBg;
|
||||
barTarget.fxScreenWarning = spSkill.FxScreenWarning;
|
||||
return barTarget;
|
||||
}
|
||||
|
||||
public string FxWaterSplash()
|
||||
{
|
||||
return spSkill.FxWaterSplash;
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/GampPlay/FishSkill/CorruptSpSkillData.cs.meta
Normal file
11
Assets/Scripts/GampPlay/FishSkill/CorruptSpSkillData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f303a29ae9e54dd47bc3551d211297be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
119
Assets/Scripts/GampPlay/FishSkill/ElectricShockSpSkillData.cs
Normal file
119
Assets/Scripts/GampPlay/FishSkill/ElectricShockSpSkillData.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using cfg;
|
||||
using UnityEngine;
|
||||
|
||||
public class ElectricShockSpSkillData : IFishSpSkillData
|
||||
{
|
||||
public FishSkill fishSkill { get; set; }
|
||||
public SpKillType Type { get; set; } = SpKillType.ElectricShock;
|
||||
public FishSpSkillLabel spSkillLabel { get; set; }
|
||||
public ElectricShock spSkill { get; set; }
|
||||
|
||||
public int StopCount { get; set; }
|
||||
public bool InProgress { get; set; }
|
||||
public bool End { get; set; }
|
||||
public void StartSkill(FishSpSkillLabel fishSpSkill)
|
||||
{
|
||||
Type = SpKillType.ElectricShock;
|
||||
spSkillLabel = fishSpSkill;
|
||||
spSkill = fishSpSkill as ElectricShock;
|
||||
End = false;
|
||||
Debug.Log("StartSkill");
|
||||
}
|
||||
|
||||
public void RefreshSkill(FishSpSkillLabel fishSpSkill)
|
||||
{
|
||||
spSkillLabel = fishSpSkill;
|
||||
spSkill = fishSpSkill as ElectricShock;
|
||||
StopCount++;
|
||||
InProgress = false;
|
||||
End = false;
|
||||
}
|
||||
|
||||
public void EndSkill()
|
||||
{
|
||||
End = true;
|
||||
}
|
||||
|
||||
public string AudioScreen()
|
||||
{
|
||||
return spSkill.AudioScreen;
|
||||
}
|
||||
|
||||
public string AudioRewardFish()
|
||||
{
|
||||
return spSkill.AudioRewardFish;
|
||||
}
|
||||
|
||||
#region UI
|
||||
public string FxScreen()
|
||||
{
|
||||
return spSkill.FxScreen;
|
||||
}
|
||||
|
||||
public string FxBar()
|
||||
{
|
||||
return spSkill.FxBar;
|
||||
}
|
||||
|
||||
public string FxProgressInc()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public string FxProgressDec()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public string FxFishIcon()
|
||||
{
|
||||
return spSkill.FxFishIcon;
|
||||
}
|
||||
|
||||
public BarTarget GetBarTarget()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Jump
|
||||
|
||||
public string FxFishJump()
|
||||
{
|
||||
return spSkill.FxFish;
|
||||
}
|
||||
public string FxWater()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Struggle
|
||||
|
||||
public string FxFishSkillAppend()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
/// <summary>
|
||||
/// 鱼起跳的时候,立刻在Root处挂上一个特效
|
||||
/// </summary>
|
||||
public string FxFishJumpWater()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
/// <summary>
|
||||
/// 鱼起跳的时候,立刻在Root处挂上一个特效
|
||||
/// </summary>
|
||||
public string FxFishStruggle()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
public string FxWaterSplash()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bb8d4c830656124fb7842f746ce4be6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
103
Assets/Scripts/GampPlay/FishSkill/IFishSpSkillData.cs
Normal file
103
Assets/Scripts/GampPlay/FishSkill/IFishSpSkillData.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using cfg;
|
||||
public enum SpKillType
|
||||
{
|
||||
Corrupt,
|
||||
ElectricShock,
|
||||
}
|
||||
|
||||
public class BarTarget
|
||||
{
|
||||
public float CorruptSpeed;
|
||||
public float ClearSpeed;
|
||||
public float CorruptMaxPercent;
|
||||
public float CorruptBarIncPercent;
|
||||
public float CorruptBarDecPercent;
|
||||
public string fx_target_bar_bg;
|
||||
public string fx_target_bar;
|
||||
public string fx_target_bar_highlight;
|
||||
public string bar_target;
|
||||
public string highlight;
|
||||
public string fxScreenWarning;
|
||||
}
|
||||
|
||||
|
||||
public interface IFishSpSkillData
|
||||
{
|
||||
public FishSkill fishSkill { get; set; }
|
||||
public FishSpSkillLabel spSkillLabel { get; set; }
|
||||
|
||||
public SpKillType Type { set; get; }
|
||||
|
||||
public int StopCount { set; get; }
|
||||
public bool InProgress { set; get; }
|
||||
public bool End { set; get; }
|
||||
public void StartSkill(FishSpSkillLabel fishSpSkill);
|
||||
|
||||
public void RefreshSkill(FishSpSkillLabel fishSpSkill);
|
||||
|
||||
public void EndSkill();
|
||||
|
||||
/// <summary>
|
||||
/// 跳跃时鱼身上动画
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string FxFishJump();
|
||||
|
||||
/// <summary>
|
||||
/// 鱼起跳的时候,立刻在Root处挂上一个特效
|
||||
/// </summary>
|
||||
public string FxFishJumpWater();
|
||||
/// <summary>
|
||||
/// 鱼起跳的时候,立刻在Root处挂上一个特效
|
||||
/// </summary>
|
||||
public string FxFishStruggle();
|
||||
/// <summary>
|
||||
/// 鱼在释放技能的时候,在Head处的特效
|
||||
/// </summary>
|
||||
public string FxFishSkillAppend();
|
||||
/// <summary>
|
||||
/// 替换跳跃入水出水动画
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string FxWater();
|
||||
public string FxWaterSplash();
|
||||
|
||||
/// <summary>
|
||||
/// 与释放技能时的全屏特效
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
public string FxScreen();
|
||||
/// <summary>
|
||||
/// 与释放技能时的进度条特效
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string FxBar();
|
||||
/// <summary>
|
||||
/// 鱼头像特效
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string FxFishIcon();
|
||||
/// <summary>
|
||||
/// 释放技能时进度条指针特效
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string FxProgressInc();
|
||||
|
||||
/// <summary>
|
||||
/// 鱼释放技能时音效
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string AudioScreen();
|
||||
/// <summary>
|
||||
/// 结算界面音效
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string AudioRewardFish();
|
||||
|
||||
/// <summary>
|
||||
/// 进度条特效相关
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public BarTarget GetBarTarget();
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/FishSkill/IFishSpSkillData.cs.meta
Normal file
11
Assets/Scripts/GampPlay/FishSkill/IFishSpSkillData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 146facaec174ddf4ca4272271cf15d16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/GampPlay/Fishing.meta
Normal file
8
Assets/Scripts/GampPlay/Fishing.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ca235a4d755e9d428823e2b04114a47
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
306
Assets/Scripts/GampPlay/Fishing/CollectingData.cs
Normal file
306
Assets/Scripts/GampPlay/Fishing/CollectingData.cs
Normal file
@@ -0,0 +1,306 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
public class DropAfterDrop
|
||||
{
|
||||
public string Mode;
|
||||
public string Bone;
|
||||
public string Fx;
|
||||
public DropAfterDrop(string mode, string bone, string fx)
|
||||
{
|
||||
Mode = mode;
|
||||
Bone = bone;
|
||||
Fx = fx;
|
||||
}
|
||||
}
|
||||
public class PlayNewItemFxEvent
|
||||
{
|
||||
public string fxName;
|
||||
public string audioName;
|
||||
public bool IsDarkness;
|
||||
public float PerformanceDelay;
|
||||
//==0=>start ==1=>stopFX ==2=>stopAudio or all
|
||||
public int type;
|
||||
}
|
||||
public class CollectingData
|
||||
{
|
||||
ETDropAfterDrop etDropAfterDrop;
|
||||
ETChangeMaterial eTChangeMaterial;
|
||||
ETNewItem etNewItem;
|
||||
ETKeepsake eTKeepsake;
|
||||
ETDropByFish eTDropByFish;
|
||||
|
||||
private MapFishList mapFishList = null;
|
||||
int addCollecting = 0;
|
||||
int extraCashDrop = 0;
|
||||
public FishingData fishingData;
|
||||
//获取额外掉落id
|
||||
int GetExtraDropID()
|
||||
{
|
||||
if (!fishingData.IsEventGameFish())
|
||||
{
|
||||
if (etDropAfterDrop != null)
|
||||
{
|
||||
//根据鱼的品质获取掉落id
|
||||
int Quality = fishingData.fishItem.Quality - 1;
|
||||
if (Quality >= etDropAfterDrop.ExtraDropList.Count)
|
||||
{
|
||||
Quality = etDropAfterDrop.ExtraDropList.Count - 1;
|
||||
}
|
||||
extraCashDrop = etDropAfterDrop.ExtraCashDropList[Quality];
|
||||
return etDropAfterDrop.ExtraDropList[Quality];
|
||||
}
|
||||
else if (eTChangeMaterial != null)
|
||||
{
|
||||
extraCashDrop = eTChangeMaterial.ExtraCashDropList;
|
||||
return eTChangeMaterial.ExtraDropList;
|
||||
}
|
||||
else if (mapFishList != null)
|
||||
{
|
||||
//根据鱼的编号获取掉落id
|
||||
int index = mapFishList.FishIDList.IndexOf(fishingData.fishItem.RedirectID);
|
||||
if (index != -1)
|
||||
{
|
||||
return mapFishList.DropIDList[index];
|
||||
}
|
||||
}
|
||||
else if (eTKeepsake != null)
|
||||
{
|
||||
if (fishingData.NewIndex >= eTKeepsake.FishExtraDropList.Count)
|
||||
{
|
||||
Debug.LogError($"Keepsake FishExtraDropList == {eTKeepsake.FishExtraDropList.Count} Not Index {fishingData.NewIndex}");
|
||||
return eTKeepsake.FishExtraDropList[0];
|
||||
}
|
||||
return eTKeepsake.FishExtraDropList[fishingData.NewIndex];
|
||||
}
|
||||
else if (etNewItem != null)
|
||||
{
|
||||
if (fishingData.NewIndex >= etNewItem.ExtraDropList.Count)
|
||||
{
|
||||
Debug.LogError($"NewItem ExtraDropList == {etNewItem.ExtraDropList.Count} Not Index {fishingData.NewIndex}");
|
||||
|
||||
return etNewItem.ExtraDropList[0];
|
||||
}
|
||||
return etNewItem.ExtraDropList[fishingData.NewIndex];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// 最后钓上来的鱼是否有装饰
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DropAfterDrop OnChangeFishData()
|
||||
{
|
||||
var collectingTargetInit = GContext.container.Resolve<FishingEventData>().collectingTargetInit;
|
||||
if (collectingTargetInit == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DropAfterDrop afterDrop = null;
|
||||
if (etDropAfterDrop != null)
|
||||
{
|
||||
afterDrop = new DropAfterDrop(etDropAfterDrop.Mode, etDropAfterDrop.Bone, etDropAfterDrop.Fx);
|
||||
}
|
||||
else if (eTDropByFish != null)
|
||||
{
|
||||
afterDrop = new DropAfterDrop(eTDropByFish.Mode, eTDropByFish.Bone, eTDropByFish.Fx);
|
||||
}
|
||||
//有相关装饰活动,并且有代币掉落
|
||||
return addCollecting > 0 ? afterDrop : null;
|
||||
}
|
||||
public ETChangeMaterial MaterialChange()
|
||||
{
|
||||
return addCollecting > 0 ? eTChangeMaterial : null;
|
||||
}
|
||||
|
||||
public float StatsChange(int index)
|
||||
{
|
||||
if (addCollecting == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (eTChangeMaterial != null)
|
||||
{
|
||||
int Quality = fishingData.curFishData.Quality - 1;
|
||||
if (Quality >= eTChangeMaterial.StatsChange.Count)
|
||||
{
|
||||
Quality = eTChangeMaterial.StatsChange.Count - 1;
|
||||
}
|
||||
|
||||
List<float> statsChange = eTChangeMaterial.StatsChange[Quality];
|
||||
if (index < statsChange.Count)
|
||||
{
|
||||
return statsChange[index];
|
||||
}
|
||||
}
|
||||
if (etDropAfterDrop != null && index < etDropAfterDrop.StatsChange.Count)
|
||||
{
|
||||
return etDropAfterDrop.StatsChange[index];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
public ETNewItem ETNewItemFx()
|
||||
{
|
||||
return etNewItem;
|
||||
}
|
||||
/// <summary>
|
||||
/// 掉落活动代币数量
|
||||
/// </summary>
|
||||
public void ExtraDrop()
|
||||
{
|
||||
addCollecting = 0;
|
||||
extraCashDrop = 0;
|
||||
//鱼的品质或者编号
|
||||
int dropID = GetExtraDropID();
|
||||
if (dropID != 0)
|
||||
{
|
||||
List<ItemData> itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(dropID);
|
||||
if (itemData is { Count: > 0 })
|
||||
{
|
||||
addCollecting = itemData[0].count;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
eTDropByFish = null;
|
||||
etDropAfterDrop = null;
|
||||
etNewItem = null;
|
||||
eTKeepsake = null;
|
||||
eTChangeMaterial = null;
|
||||
|
||||
mapFishList = null;
|
||||
addCollecting = 0;
|
||||
}
|
||||
public void GetFishByWeight()
|
||||
{
|
||||
var collectingTargetInit = GContext.container.Resolve<FishingEventData>().collectingTargetInit;
|
||||
if (collectingTargetInit != null)
|
||||
{
|
||||
FishBuffTimeData fishBuffTimeData = GContext.container.Resolve<BuffDataCenter>().GetBuffData<CollectionTargetWeight>();
|
||||
float BasicProb = collectingTargetInit.BasicProb;
|
||||
CollectionTargetWeight collectionTargetWeight = null;
|
||||
if (fishBuffTimeData != null)
|
||||
{
|
||||
FishBuff fishBuff = GContext.container.Resolve<Tables>().TbFishBuff.GetOrDefault(fishBuffTimeData.buffID);
|
||||
collectionTargetWeight = fishBuff.BuffParam as CollectionTargetWeight;
|
||||
BasicProb = collectionTargetWeight.NewTargetFishProb;
|
||||
}
|
||||
if (Random.Range(0, 1f) <= BasicProb + 0.0001f)
|
||||
{
|
||||
EventTargetExtraDrop eventTargetExtraDrop = GContext.container.Resolve<FishingEventData>().GetEventTargetExtraDrop();
|
||||
if (eventTargetExtraDrop != null)
|
||||
{
|
||||
if (eventTargetExtraDrop is ETDropByFish)
|
||||
{
|
||||
var eTDropByFishCur = (ETDropByFish)eventTargetExtraDrop;
|
||||
List<MapFishList> _mapFishList = eTDropByFishCur.ExtraDropList;
|
||||
for (int i = 0; i < _mapFishList.Count; i++)
|
||||
{
|
||||
if (_mapFishList[i].MapID == fishingData.MapId)
|
||||
{
|
||||
eTDropByFish = eTDropByFishCur;
|
||||
mapFishList = _mapFishList[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (eventTargetExtraDrop is ETDropAfterDrop)
|
||||
{
|
||||
etDropAfterDrop = (ETDropAfterDrop)eventTargetExtraDrop;
|
||||
}
|
||||
else if (eventTargetExtraDrop is ETChangeMaterial)
|
||||
{
|
||||
eTChangeMaterial = (ETChangeMaterial)eventTargetExtraDrop;
|
||||
}
|
||||
else if (eventTargetExtraDrop is ETNewItem)
|
||||
{
|
||||
fishingData.NewIndex = 0;
|
||||
etNewItem = (ETNewItem)eventTargetExtraDrop;
|
||||
fishingData.NewItemID = etNewItem.NewItemID[fishingData.NewIndex];
|
||||
fishingData.fishItem = GContext.container.Resolve<Tables>().GetItemData(fishingData.NewItemID);
|
||||
return;
|
||||
}
|
||||
else if (eventTargetExtraDrop is ETKeepsake)
|
||||
{
|
||||
eTKeepsake = (ETKeepsake)eventTargetExtraDrop;
|
||||
var newItemIDList = new List<int>(eTKeepsake.FishIDList);
|
||||
var newItemWeight = new List<float>(eTKeepsake.FishWeightList);
|
||||
//===================信物相关===================
|
||||
int curHour = ZZTimeHelper.UtcNow().UtcNowOffset().Hour;
|
||||
if (curHour >= 16)
|
||||
{
|
||||
curHour = 16;
|
||||
}
|
||||
else if (curHour >= 8)
|
||||
{
|
||||
curHour = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
curHour = 0;
|
||||
}
|
||||
int fishCount = GContext.container.Resolve<PlayerShopData>().GetShopPackBuyCount("CTFishID0" + curHour);
|
||||
|
||||
//每日信物权重
|
||||
var keepsakeWeight = eTKeepsake.KeepsakeWeight;
|
||||
if (fishCount < keepsakeWeight.Count)
|
||||
{
|
||||
newItemWeight[0] = keepsakeWeight[fishCount];
|
||||
}
|
||||
//buff重置鱼和信物权重
|
||||
if (collectionTargetWeight != null)
|
||||
{
|
||||
newItemWeight = new List<float>(collectionTargetWeight.NewWeightList);
|
||||
}
|
||||
//===================信物相关===================
|
||||
NewItemIDListFun(newItemIDList, newItemWeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NewItemIDListFun(List<int> newItemIDList, List<float> newItemWeight)
|
||||
{
|
||||
fishingData.NewIndex = 0;
|
||||
fishingData.NewItemID = newItemIDList[0];
|
||||
float allWeight = newItemWeight.Sum();
|
||||
//特殊物品概率特殊调整 Todo
|
||||
float randomWeight = Random.Range(0.001f, allWeight);
|
||||
float sum = 0;
|
||||
for (int i = 0; i < newItemIDList.Count; i++)
|
||||
{
|
||||
sum += newItemWeight[i];
|
||||
if (randomWeight < sum)
|
||||
{
|
||||
fishingData.NewIndex = i;
|
||||
fishingData.NewItemID = newItemIDList[fishingData.NewIndex];
|
||||
fishingData.fishItem = GContext.container.Resolve<Tables>().GetItemData(fishingData.NewItemID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 额外掉落代币数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetAddCollecting()
|
||||
{
|
||||
return addCollecting;
|
||||
}
|
||||
|
||||
public float ExtraCashDrop()
|
||||
{
|
||||
if (addCollecting > 0 && extraCashDrop > 0)
|
||||
{
|
||||
DropPackageList dropPackageList = GContext.container.Resolve<Tables>().TbDrop[extraCashDrop].DropList;
|
||||
return dropPackageList.DropCountList[0];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/Fishing/CollectingData.cs.meta
Normal file
11
Assets/Scripts/GampPlay/Fishing/CollectingData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ae443f88645a784ea153394be9c2c69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
222
Assets/Scripts/GampPlay/Fishing/Fish.cs
Normal file
222
Assets/Scripts/GampPlay/Fishing/Fish.cs
Normal file
@@ -0,0 +1,222 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using GameCore;
|
||||
using System.Collections;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
public struct FishRotateEvent
|
||||
{
|
||||
public float rotate;
|
||||
public int state;// 0:停止自转, 1:开始自转, 2:旋转,3:固定角度, 4:隐藏, 5:显示
|
||||
public int rodType;
|
||||
public FishRotateEvent(float rotate, int state, int rodType)
|
||||
{
|
||||
this.rotate = rotate;
|
||||
this.state = state;
|
||||
this.rodType = rodType;
|
||||
}
|
||||
}
|
||||
public class Fish : MonoBehaviour
|
||||
{
|
||||
//鱼嘴位置
|
||||
public Transform mouthPos;
|
||||
public Transform Head;
|
||||
public Transform LeftEye;
|
||||
public Transform RightEye;
|
||||
public Transform Fin;
|
||||
public Transform Tail;
|
||||
public Transform Neck;
|
||||
public Transform Root;
|
||||
public Animator animator;
|
||||
//public FishingFlyingFish fishingFlyingFish;
|
||||
BoxCollider boxCollider;
|
||||
bool isCollider = false;
|
||||
[HideInInspector]
|
||||
public GameObject modeGo;
|
||||
//旋转速度
|
||||
public int rotateSpeed = 10;
|
||||
System.IDisposable disposable;
|
||||
float _fishAnimSpeed;
|
||||
bool Pulling01;
|
||||
public float FishAnimSpeed
|
||||
{
|
||||
set
|
||||
{
|
||||
_fishAnimSpeed = value;
|
||||
animator.speed = _fishAnimSpeed;
|
||||
}
|
||||
get { return _fishAnimSpeed; }
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
|
||||
boxCollider = GetComponent<BoxCollider>();
|
||||
if (boxCollider)
|
||||
{
|
||||
boxCollider.enabled = isCollider;
|
||||
}
|
||||
}
|
||||
public Transform Find(string name)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "Fin":
|
||||
return Fin;
|
||||
case "Tail":
|
||||
return Tail;
|
||||
case "Neck":
|
||||
return Neck;
|
||||
case "Head":
|
||||
return Head;
|
||||
case "LeftEye":
|
||||
return LeftEye;
|
||||
case "RightEye":
|
||||
return RightEye;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
Pulling01 = false;
|
||||
transform.DOKill();
|
||||
disposable = GContext.OnEvent<FishRotateEvent>().Subscribe(OnFishingRotate);
|
||||
GameEventMgr.Instance.AddListener(GameEvents.EventFishingPlay, PlayerClick);
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
disposable.Dispose();
|
||||
disposable = null;
|
||||
GameEventMgr.Instance.RemoveListener(GameEvents.EventFishingPlay, PlayerClick);
|
||||
}
|
||||
public void EnableCollider()
|
||||
{
|
||||
isCollider = true;
|
||||
if (boxCollider)
|
||||
{
|
||||
boxCollider.enabled = true;
|
||||
}
|
||||
}
|
||||
public float GetColliderSize(float size)
|
||||
{
|
||||
if (boxCollider)
|
||||
{
|
||||
boxCollider.isTrigger = true;
|
||||
boxCollider.size *= size;
|
||||
return boxCollider.size.magnitude / 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private void PlayerClick()
|
||||
{
|
||||
if (animator != null)
|
||||
{
|
||||
var clicp = animator.GetCurrentAnimatorClipInfo(0);
|
||||
if (clicp[0].clip.name == "Idle01")
|
||||
{
|
||||
StartCoroutine(PlayClickSound());
|
||||
animator.SetTrigger("Click01");
|
||||
}
|
||||
}
|
||||
}
|
||||
public void PlayBite()
|
||||
{
|
||||
animator.SetTrigger("Bite01");
|
||||
}
|
||||
public void PlayJump()
|
||||
{
|
||||
animator.SetTrigger("Jump01");
|
||||
}
|
||||
public void SetTrigger(string triggerName)
|
||||
{
|
||||
animator.SetBool("Swim01", false);
|
||||
animator.speed = 1;
|
||||
animator.SetTrigger(triggerName);
|
||||
}
|
||||
public void PlaySwim01()
|
||||
{
|
||||
animator.speed = _fishAnimSpeed;
|
||||
if (!Pulling01)
|
||||
{
|
||||
animator.SetTrigger("Swim01");
|
||||
}
|
||||
}
|
||||
public void SetSkillInt(int inValue)
|
||||
{
|
||||
animator.SetInteger("SkillIndex", inValue);
|
||||
}
|
||||
public void SetSkillType(int inValue)
|
||||
{
|
||||
animator.SetInteger("SkillType", inValue);
|
||||
}
|
||||
IEnumerator PlayClickSound()
|
||||
{
|
||||
FishingData fishingData = GContext.container.Resolve<FishingData>();
|
||||
yield return new WaitForSeconds(fishingData.curFishData.DelaySplashClick);
|
||||
var audios = fishingData.curFishData.AudioSplashClick;
|
||||
if (audios.Count > 0)
|
||||
{
|
||||
string pullingOutSound = audios[Random.Range(0, audios.Count)];
|
||||
|
||||
GContext.Publish(new EventFishingSound(pullingOutSound));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(fishingData.curFishData.FxWaterSplash))
|
||||
GContext.Publish(new PlayerRaindropEvent() { FxWaterSplash = fishingData.curFishData.FxWaterSplash });
|
||||
}
|
||||
public void Pulling()
|
||||
{
|
||||
if (animator != null)
|
||||
{
|
||||
animator.SetBool("Swim01", false);
|
||||
Pulling01 = true;
|
||||
animator.SetTrigger("Pulling01");
|
||||
}
|
||||
}
|
||||
void OnFishingRotate(FishRotateEvent fishRotateEvent)
|
||||
{
|
||||
OnFishingRotate(fishRotateEvent.rotate, fishRotateEvent.state, fishRotateEvent.rodType);
|
||||
}
|
||||
private void OnFishingRotate(float rotate, int state, int rodType)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
//停止自转
|
||||
transform.DOKill();
|
||||
break;
|
||||
case 1:
|
||||
DOLocalRotate(rodType);
|
||||
break;
|
||||
case 2:
|
||||
transform.Rotate(Vector3.forward * rotate);
|
||||
break;
|
||||
case 3:
|
||||
transform.DOKill();
|
||||
transform.localEulerAngles = Vector3.back * rotate;
|
||||
break;
|
||||
case 4:
|
||||
animator.gameObject.SetActive(false);
|
||||
break;
|
||||
case 5:
|
||||
animator.gameObject.SetActive(true);
|
||||
animator.Play("Idle01");
|
||||
DOLocalRotate(rodType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DOLocalRotate(int rodType)
|
||||
{
|
||||
transform.DOKill();
|
||||
//开始自转
|
||||
Vector3 vector3 = Vector3.back * 360;
|
||||
if (rodType == 2)
|
||||
{
|
||||
vector3 = Vector3.forward * 360;
|
||||
}
|
||||
transform.DOLocalRotate(vector3, rotateSpeed, RotateMode.LocalAxisAdd).SetEase(Ease.Linear).SetLoops(-1);
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/Fishing/Fish.cs.meta
Normal file
11
Assets/Scripts/GampPlay/Fishing/Fish.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69a1181c1a285784699a8abf736f7aa0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
250
Assets/Scripts/GampPlay/Fishing/FishingSkinTool.cs
Normal file
250
Assets/Scripts/GampPlay/Fishing/FishingSkinTool.cs
Normal file
@@ -0,0 +1,250 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
public enum RodSkinType
|
||||
{
|
||||
skin = 0,
|
||||
glove = 1,
|
||||
//accessories = 2
|
||||
}
|
||||
public struct ChangeSkinEvent
|
||||
{
|
||||
public ChangeSkinEvent(RodSkinType Type)
|
||||
{
|
||||
this.Type = Type;
|
||||
}
|
||||
public RodSkinType Type;
|
||||
}
|
||||
public struct SelectSkinEvent
|
||||
{
|
||||
public SelectSkinEvent(int ID)
|
||||
{
|
||||
this.ID = ID;
|
||||
}
|
||||
public int ID;
|
||||
}
|
||||
public struct SelectGloveEvent
|
||||
{
|
||||
public SelectGloveEvent(int ID)
|
||||
{
|
||||
this.ID = ID;
|
||||
}
|
||||
public int ID;
|
||||
}
|
||||
public struct SelectAccessoriesEvent
|
||||
{
|
||||
public SelectAccessoriesEvent(int ID)
|
||||
{
|
||||
this.ID = ID;
|
||||
}
|
||||
public int ID;
|
||||
}
|
||||
public class FishingSkinTool : MonoBehaviour
|
||||
{
|
||||
Tables _tables;
|
||||
public GameObject _bait;
|
||||
GameObject baitAB;
|
||||
//相机初始化
|
||||
public Animator _cameraAnimator;
|
||||
public GameObject _fishingRodHandle;
|
||||
public Vector2 _lineResolution; // 钓鱼线的分辨率
|
||||
Animator rodHandleAni;
|
||||
Vector3 _targetPos;
|
||||
Animator fishingRodAnimator;
|
||||
Rod RodBehaviour;
|
||||
GameObject rodPrefab;
|
||||
HandController HandController;
|
||||
GameObject handAB;
|
||||
CompositeDisposable disposables = new CompositeDisposable();
|
||||
PlayerData playerData;
|
||||
PlayerFishData playerFishData;
|
||||
float FishingScale = 1;
|
||||
string _rodSkinPath;
|
||||
string _glovePath;
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
playerData = GContext.container.Resolve<PlayerData>();
|
||||
playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
GContext.OnEvent<SelectGloveEvent>().Subscribe(OnSelectGloveEvent).AddTo(disposables);
|
||||
GContext.OnEvent<SelectSkinEvent>().Subscribe(OnSelectSkinEvent).AddTo(disposables);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
LoadHand();
|
||||
LoadFishRod();
|
||||
LoadBait();
|
||||
}
|
||||
void LoadHand()
|
||||
{
|
||||
GloveData gloveData = GContext.container.Resolve<PlayerFishData>().GetGloveData;
|
||||
InitRodHandAsync(gloveData);
|
||||
}
|
||||
|
||||
void OnSelectGloveEvent(SelectGloveEvent e)
|
||||
{
|
||||
var gloveData = _tables.TbGloveData[e.ID];
|
||||
InitRodHandAsync(gloveData);
|
||||
}
|
||||
public async void InitRodHandAsync(GloveData gloveData)
|
||||
{
|
||||
if (gloveData == null)
|
||||
{
|
||||
Debug.LogError("gloveData is null");
|
||||
return;
|
||||
}
|
||||
string path = gloveData.Fbx;
|
||||
if (_glovePath == path)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_glovePath = path;
|
||||
if (handAB != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(handAB);
|
||||
}
|
||||
var hand = await Addressables.InstantiateAsync(path, transform).Task;
|
||||
if (hand != null)
|
||||
{
|
||||
if (path != gloveData.Fbx)
|
||||
{
|
||||
Addressables.ReleaseInstance(hand);
|
||||
return;
|
||||
}
|
||||
handAB = hand;
|
||||
HandController = handAB.GetComponent<HandController>();
|
||||
if (RodBehaviour != null)
|
||||
{
|
||||
HandController.SetHandTargets(RodBehaviour.RightHandTargets, RodBehaviour.LeftHandTargets, RodBehaviour.BodyTargets);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async void LoadBait()
|
||||
{
|
||||
baitAB = await Addressables.InstantiateAsync("BaitRoot", _bait.transform).Task;
|
||||
baitAB.transform.localPosition = Vector3.zero;
|
||||
baitAB.transform.localRotation = Quaternion.identity;
|
||||
baitAB.transform.localScale = Vector3.one;
|
||||
}
|
||||
void LoadFishRod()
|
||||
{
|
||||
int equipRodID = playerData.equipRodID;
|
||||
var fishRodData = _tables.TbRodData[equipRodID];
|
||||
InitFishRodAsync(fishRodData);
|
||||
}
|
||||
public void InitFishRodAsync(RodData fishRodData)
|
||||
{
|
||||
int skindID = playerFishData.GetRodSkin(fishRodData.ID);
|
||||
if (skindID > 0)
|
||||
{
|
||||
var fishRodSkinData = _tables.TbRodSkinData.GetOrDefault(skindID);
|
||||
if (fishRodSkinData != null)
|
||||
{
|
||||
FishingScale = fishRodSkinData.FishingScale;
|
||||
LoadFishRodAsync(fishRodSkinData.Fbx);
|
||||
}
|
||||
}
|
||||
}
|
||||
void OnSelectSkinEvent(SelectSkinEvent e)
|
||||
{
|
||||
int skindID = e.ID;
|
||||
if (skindID > 0)
|
||||
{
|
||||
var fishRodSkinData = _tables.TbRodSkinData.GetOrDefault(skindID);
|
||||
if (fishRodSkinData != null)
|
||||
{
|
||||
FishingScale = fishRodSkinData.FishingScale;
|
||||
LoadFishRodAsync(fishRodSkinData.Fbx);
|
||||
}
|
||||
}
|
||||
}
|
||||
async void LoadFishRodAsync(string path)
|
||||
{
|
||||
if (_rodSkinPath == path)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_rodSkinPath = path;
|
||||
var goPrefab = await Addressables.LoadAssetAsync<GameObject>(path).Task;
|
||||
_bait.transform.SetParent(transform);
|
||||
if (goPrefab != null)
|
||||
{
|
||||
if (rodPrefab)
|
||||
{
|
||||
Addressables.Release(rodPrefab);
|
||||
}
|
||||
rodPrefab = goPrefab;
|
||||
var go = Instantiate(goPrefab, transform.Find("FishingRodHandle"));
|
||||
go.transform.localPosition = Vector3.zero;
|
||||
go.transform.localScale = Vector3.one * FishingScale;
|
||||
if (RodBehaviour != null)
|
||||
{
|
||||
DestroyImmediate(RodBehaviour.gameObject);
|
||||
}
|
||||
|
||||
RodBehaviour = go.GetComponent<Rod>();
|
||||
fishingRodAnimator = RodBehaviour.rod.GetComponent<Animator>();
|
||||
//Set HandIK Target
|
||||
if (HandController != null)
|
||||
{
|
||||
HandController.SetHandTargets(RodBehaviour.RightHandTargets, RodBehaviour.LeftHandTargets, RodBehaviour.BodyTargets);
|
||||
}
|
||||
|
||||
if (RodBehaviour.cCDIK != null)
|
||||
{
|
||||
RodBehaviour.cCDIK.enabled = false;
|
||||
}
|
||||
_bait.transform.SetParent(RodBehaviour.Bait);
|
||||
_bait.transform.localPosition = Vector3.zero; //-Vector3.up * 0.1f;
|
||||
_bait.transform.localRotation = Quaternion.Euler(Vector3.forward * 90);
|
||||
}
|
||||
}
|
||||
private void LateUpdate()
|
||||
{
|
||||
DrawFishingLine();
|
||||
}
|
||||
private void DrawFishingLine()
|
||||
{
|
||||
if (RodBehaviour == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 计算钓鱼线上的点
|
||||
Vector3[] linePoints;
|
||||
int addCount = RodBehaviour.LineList.Count + 4;
|
||||
linePoints = new Vector3[addCount];
|
||||
linePoints[0] = RodBehaviour.LineHole.position;
|
||||
linePoints[1] = RodBehaviour.EndLine.position;
|
||||
|
||||
for (int i = 0; i < RodBehaviour.LineList.Count; i++)
|
||||
{
|
||||
linePoints[i + 2] = RodBehaviour.LineList[i].position;
|
||||
|
||||
}
|
||||
linePoints[addCount - 2] = RodBehaviour.TopLine.position;
|
||||
linePoints[addCount - 1] = _bait.transform.position;
|
||||
// 绘制钓鱼线
|
||||
RodBehaviour.fishingLineRenderer.positionCount = addCount;
|
||||
RodBehaviour.fishingLineRenderer.SetPositions(linePoints);
|
||||
}
|
||||
private float CalculateSegmetLenght(float distance, Vector2 lineResolution)
|
||||
{
|
||||
float x = Mathf.InverseLerp(1, 50, distance);
|
||||
float value = Mathf.Lerp(lineResolution.x, lineResolution.y, x);
|
||||
|
||||
return value;
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
disposables?.Dispose();
|
||||
disposables = null;
|
||||
|
||||
Addressables.Release(rodPrefab);
|
||||
Addressables.ReleaseInstance(baitAB);
|
||||
Addressables.ReleaseInstance(handAB);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/Fishing/FishingSkinTool.cs.meta
Normal file
11
Assets/Scripts/GampPlay/Fishing/FishingSkinTool.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a655abc298aa9dd45ad5da6cedb3ed5d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
150
Assets/Scripts/GampPlay/Fishing/HandController.cs
Normal file
150
Assets/Scripts/GampPlay/Fishing/HandController.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using RootMotion.FinalIK;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum EHandState
|
||||
{
|
||||
None,
|
||||
Idle,
|
||||
Hold,
|
||||
Fishing,
|
||||
Catch,
|
||||
Release,
|
||||
End
|
||||
}
|
||||
|
||||
public class HandController : MonoBehaviour
|
||||
{
|
||||
// private Animator anim_hand;
|
||||
//[HideInInspector]
|
||||
//public Animator anim_rightElbowDirection;
|
||||
|
||||
HandPoser poser_l;
|
||||
HandPoser poser_r;
|
||||
|
||||
private FullBodyBipedIK _bodyIK;
|
||||
|
||||
private Transform
|
||||
_leftElbowDireciton,
|
||||
_rightElbowDireciton,
|
||||
_rightHandTargets,
|
||||
_leftHandTargets,
|
||||
Shoulder;
|
||||
|
||||
private bool _isRightHandFollowTarget;
|
||||
private bool _isLeftHandFollowTarget;
|
||||
MMTService mmtService;
|
||||
|
||||
public EHandState EHandState { get; private set; }
|
||||
#region State Method
|
||||
bool isInit;
|
||||
public void ChangeHandState(EHandState state)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnStateEnter(EHandState state)
|
||||
{
|
||||
|
||||
}
|
||||
public void OnStateExit()
|
||||
{
|
||||
|
||||
}
|
||||
public void SetActive(bool value)
|
||||
{
|
||||
if (mmtService == null)
|
||||
{
|
||||
mmtService = GContext.container.Resolve<MMTService>();
|
||||
}
|
||||
if (mmtService.CanShowHand)
|
||||
{
|
||||
gameObject.SetActive(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Component Method
|
||||
void Awake()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
private void Init()
|
||||
{
|
||||
if (isInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isInit = true;
|
||||
Shoulder = transform.Find("HandComponent/Shoulder");
|
||||
// anim_hand = transform.Find("Hand").GetComponent<Animator>();
|
||||
_rightElbowDireciton = transform.Find("HandComponent/Elbow/RightElbowDirection");
|
||||
_leftElbowDireciton = transform.Find("HandComponent/Elbow/LeftElbowDirection");
|
||||
//anim_rightElbowDirection = transform.Find("RightElbowDirection").GetComponent<Animator>();
|
||||
_bodyIK = GetComponentInChildren<FullBodyBipedIK>();
|
||||
var posers = GetComponentsInChildren<HandPoser>();
|
||||
if (posers.Length == 2)
|
||||
{
|
||||
poser_l = posers[0];
|
||||
poser_r = posers[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("HandPoser not found: " + posers.Length);
|
||||
}
|
||||
_bodyIK.solver.rightArmChain.bendConstraint.bendGoal = _rightElbowDireciton;
|
||||
_bodyIK.solver.leftArmChain.bendConstraint.bendGoal = _leftElbowDireciton;
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
SetShoulderRota(Vector3.zero);
|
||||
}
|
||||
public void SetHandTargets(Transform rightHand, Transform LeftHand, Transform body)
|
||||
{
|
||||
Init();
|
||||
_leftHandTargets = LeftHand;
|
||||
_rightHandTargets = rightHand;
|
||||
|
||||
_bodyIK.solver.leftHandEffector.target = _leftHandTargets;
|
||||
_bodyIK.solver.rightHandEffector.target = _rightHandTargets;
|
||||
|
||||
//_bodyIK.solver.bodyEffector.target = body;
|
||||
if (poser_l != null)
|
||||
{
|
||||
poser_l.poseRoot = _leftHandTargets;
|
||||
}
|
||||
if (poser_r != null)
|
||||
{
|
||||
poser_r.poseRoot = _rightHandTargets;
|
||||
}
|
||||
|
||||
SetAllHandIkTarget(1f);
|
||||
|
||||
}
|
||||
|
||||
private void SetAllHandIkTarget(float weight)
|
||||
{
|
||||
SetHandIKWeight(_bodyIK.solver.leftHandEffector, weight);
|
||||
SetHandIKWeight(_bodyIK.solver.rightHandEffector, weight);
|
||||
}
|
||||
|
||||
private void SetHandIKWeight(IKEffector effector, float weight)
|
||||
{
|
||||
effector.positionWeight = weight;
|
||||
effector.rotationWeight = weight;
|
||||
}
|
||||
public void SetShoulderRota(Vector3 vector)
|
||||
{
|
||||
Quaternion quaternion = Quaternion.Euler(vector);
|
||||
Shoulder.localRotation = quaternion;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/Fishing/HandController.cs.meta
Normal file
11
Assets/Scripts/GampPlay/Fishing/HandController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0b11f7381675ee4ca0229d57b014134
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
97
Assets/Scripts/GampPlay/Fishing/HandPosController.cs
Normal file
97
Assets/Scripts/GampPlay/Fishing/HandPosController.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using asap.core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
|
||||
public enum ERightState
|
||||
{
|
||||
Idle,
|
||||
Throwing,
|
||||
Waiting,
|
||||
Piercing,
|
||||
Drawing,
|
||||
Pulling,
|
||||
Preparing,
|
||||
Noviceguide,
|
||||
MaxCombo,
|
||||
Shock,
|
||||
PiercingSp,
|
||||
}
|
||||
[Serializable]
|
||||
public class RightState
|
||||
{
|
||||
public ERightState state;
|
||||
public float time;
|
||||
public Vector3 pos;
|
||||
}
|
||||
|
||||
public class HandPosController : MonoBehaviour
|
||||
{
|
||||
[Header("专为钓场钓鱼使用,其他场景不再初始化")]
|
||||
public List<RightState> RightStateDic;
|
||||
public ERightState curERightState;
|
||||
Coroutine coroutine;
|
||||
IDisposable disposable;
|
||||
bool isInFishingAct = false;
|
||||
private void Awake()
|
||||
{
|
||||
IAct act = GContext.container.ResolveAct("ShooterFishAct");
|
||||
isInFishingAct = act == null;
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
if (isInFishingAct)
|
||||
{
|
||||
disposable = GContext.OnEvent<ERightState>().Subscribe(SetRightStateDic);
|
||||
SetRightStateDic(ERightState.Preparing);
|
||||
}
|
||||
}
|
||||
public void SetRightStateDic(ERightState state)
|
||||
{
|
||||
RightState rightState = null;
|
||||
foreach (var item in RightStateDic)
|
||||
{
|
||||
if (item.state == state)
|
||||
{
|
||||
rightState = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rightState != null)
|
||||
{
|
||||
if (coroutine != null)
|
||||
{
|
||||
StopCoroutine(coroutine);
|
||||
}
|
||||
coroutine = StartCoroutine(SetRightHandTarget(rightState));
|
||||
}
|
||||
}
|
||||
IEnumerator SetRightHandTarget(RightState rightState)
|
||||
{
|
||||
curERightState = rightState.state;
|
||||
Vector3 pos = rightState.pos;
|
||||
Vector3 starPos = transform.localPosition;
|
||||
float time = rightState.time;
|
||||
float timer = 0;
|
||||
if (time > 0.01)
|
||||
{
|
||||
while (timer < time)
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
transform.localPosition = Vector3.Lerp(starPos, pos, timer / time);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localPosition = pos;
|
||||
}
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/Fishing/HandPosController.cs.meta
Normal file
11
Assets/Scripts/GampPlay/Fishing/HandPosController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df32d4aa770f98d439ee9b5784c253f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Assets/Scripts/GampPlay/Fishing/HandPosShootController.cs
Normal file
93
Assets/Scripts/GampPlay/Fishing/HandPosShootController.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using asap.core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
|
||||
public enum EShootState
|
||||
{
|
||||
Appear,
|
||||
Idle,
|
||||
Aim,
|
||||
Back,
|
||||
Shoot,
|
||||
Capture,
|
||||
Escape,
|
||||
}
|
||||
[Serializable]
|
||||
public class ShootState
|
||||
{
|
||||
public EShootState state;
|
||||
public float time;
|
||||
public Vector3 pos;
|
||||
}
|
||||
public class HandPosShootController : MonoBehaviour
|
||||
{
|
||||
[Header("专为射场射鱼使用,其他场景不再初始化")]
|
||||
|
||||
public List<ShootState> ShootStateDic;
|
||||
public EShootState curEShootState;
|
||||
Coroutine coroutine;
|
||||
IDisposable disposable;
|
||||
bool isInShooterFishAct = false;
|
||||
private void Awake()
|
||||
{
|
||||
IAct act = GContext.container.ResolveAct("ShooterFishAct");
|
||||
isInShooterFishAct = act != null;
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
if (isInShooterFishAct)
|
||||
{
|
||||
disposable = GContext.OnEvent<EShootState>().Subscribe(SetShootStateDic);
|
||||
SetShootStateDic(EShootState.Appear);
|
||||
}
|
||||
}
|
||||
public void SetShootStateDic(EShootState state)
|
||||
{
|
||||
ShootState ShootState = null;
|
||||
foreach (var item in ShootStateDic)
|
||||
{
|
||||
if (item.state == state)
|
||||
{
|
||||
ShootState = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ShootState != null)
|
||||
{
|
||||
if (coroutine != null)
|
||||
{
|
||||
StopCoroutine(coroutine);
|
||||
}
|
||||
coroutine = StartCoroutine(SetRightHandTarget(ShootState));
|
||||
}
|
||||
}
|
||||
IEnumerator SetRightHandTarget(ShootState ShootState)
|
||||
{
|
||||
curEShootState = ShootState.state;
|
||||
Vector3 pos = ShootState.pos;
|
||||
Vector3 starPos = transform.localPosition;
|
||||
float time = ShootState.time;
|
||||
float timer = 0;
|
||||
if (time > 0.01)
|
||||
{
|
||||
while (timer < time)
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
transform.localPosition = Vector3.Lerp(starPos, pos, timer / time);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localPosition = pos;
|
||||
}
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5460e27361bef643b2d3d9a357d7eef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/Scripts/GampPlay/Fishing/Rod.cs
Normal file
24
Assets/Scripts/GampPlay/Fishing/Rod.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using RootMotion.FinalIK;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class Rod : MonoBehaviour
|
||||
{
|
||||
public GameObject rod;
|
||||
|
||||
public Transform Bait; // 鱼饵的位置
|
||||
public Transform TopLine; // 钓鱼竿的顶部位置
|
||||
public Transform EndLine;
|
||||
public Transform Rod_Joint;
|
||||
public List<Transform> LineList;
|
||||
public Transform LineHole;
|
||||
|
||||
public LineRenderer fishingLineRenderer;
|
||||
public CCDIK cCDIK;
|
||||
|
||||
public Transform LeftHandTargets;
|
||||
public Transform RightHandTargets;
|
||||
public Transform BodyTargets;
|
||||
public TMP_Text lineLength;
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/Fishing/Rod.cs.meta
Normal file
11
Assets/Scripts/GampPlay/Fishing/Rod.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1999f4b34d23d5942b9966f39f71c715
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/GampPlay/FishingB.meta
Normal file
8
Assets/Scripts/GampPlay/FishingB.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6027f80f1f1fdd8439e6d56b4d23862e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
118
Assets/Scripts/GampPlay/FishingB/FishCome.cs
Normal file
118
Assets/Scripts/GampPlay/FishingB/FishCome.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using DG.Tweening;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.Splines;
|
||||
|
||||
public class FishCome : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
public SplineAnimate ssplineAnimate;
|
||||
public Transform FishAnimationRoot;
|
||||
GameObject splinesRoot;
|
||||
FishComeSplines fishComeSplines;
|
||||
float posY;
|
||||
private void Awake()
|
||||
{
|
||||
ssplineAnimate.enabled = false;
|
||||
}
|
||||
public async void LoadSplines(string splinesRootName)
|
||||
{
|
||||
splinesRoot = await Addressables.InstantiateAsync(splinesRootName, transform.parent).Task;
|
||||
splinesRoot.transform.localPosition = Vector3.up * posY;
|
||||
fishComeSplines = splinesRoot.GetComponent<FishComeSplines>();
|
||||
}
|
||||
public void SetPosY(float y)
|
||||
{
|
||||
posY = y;
|
||||
var pos = transform.position;
|
||||
transform.position = new Vector3(pos.x, y, pos.z);
|
||||
splinesRoot.transform.position = new Vector3(0, y, 0);
|
||||
}
|
||||
public void FishComeMove(float speed)
|
||||
{
|
||||
if (fishComeSplines != null)
|
||||
{
|
||||
SplineContainer[] splineContainers = fishComeSplines.splineContainers;
|
||||
if (splineContainers == null || splineContainers.Length < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ssplineAnimate.MaxSpeed = speed;
|
||||
ssplineAnimate.Container = splineContainers[Random.Range(0, splineContainers.Length)];
|
||||
ssplineAnimate.enabled = true;
|
||||
ssplineAnimate.Restart(true);
|
||||
ssplineAnimate.Play();
|
||||
}
|
||||
}
|
||||
public float UIEatMove(float speed, SplineContainer splineContainer)
|
||||
{
|
||||
ssplineAnimate.MaxSpeed = speed;
|
||||
//SplineContainer splineContainer = UIEatSplines[Random.Range(0, UIEatSplines.Length)];
|
||||
ssplineAnimate.Container = splineContainer;
|
||||
ssplineAnimate.enabled = true;
|
||||
ssplineAnimate.Restart(false);
|
||||
ssplineAnimate.Play();
|
||||
return splineContainer.CalculateLength() / speed;
|
||||
}
|
||||
public async Task FishEatMove(float speed)
|
||||
{
|
||||
if (fishComeSplines == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SplineContainer[] UIEatSplines = fishComeSplines.UIEatSplines;
|
||||
if (UIEatSplines == null || UIEatSplines.Length < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SplineContainer splineContainer;
|
||||
if (ssplineAnimate.IsPlaying)
|
||||
{
|
||||
FishComeStop();
|
||||
Vector3 position = transform.position;
|
||||
splineContainer = UIEatSplines[0];
|
||||
Spline spline = splineContainer[0];
|
||||
Vector3 initialPosition = spline[0].Position;
|
||||
float distance = Vector3.Distance(initialPosition, position);
|
||||
SplineContainer splineContainer1;
|
||||
Spline spline1;
|
||||
Vector3 initialPosition1;
|
||||
float distance1;
|
||||
for (int i = 1; i < UIEatSplines.Length; i++)
|
||||
{
|
||||
splineContainer1 = UIEatSplines[i];
|
||||
spline1 = splineContainer1[0];
|
||||
initialPosition1 = spline1[0].Position;
|
||||
distance1 = Vector3.Distance(initialPosition1, position);
|
||||
if (distance1 < distance)
|
||||
{
|
||||
distance = distance1;
|
||||
splineContainer = splineContainer1;
|
||||
initialPosition = initialPosition1;
|
||||
}
|
||||
}
|
||||
initialPosition += fishComeSplines.transform.position;
|
||||
Quaternion rotation11 = Quaternion.LookRotation(transform.position - initialPosition);
|
||||
float time11 = distance / speed;
|
||||
transform.DORotateQuaternion(rotation11, 0.1f);
|
||||
transform.DOLocalMove(initialPosition, time11);
|
||||
await new WaitForSeconds(time11);
|
||||
}
|
||||
else
|
||||
{
|
||||
splineContainer = UIEatSplines[Random.Range(0, UIEatSplines.Length)];
|
||||
}
|
||||
float time = UIEatMove(speed, splineContainer);
|
||||
if (time > 4)
|
||||
{
|
||||
time = 4;
|
||||
}
|
||||
await new WaitForSeconds(time);
|
||||
}
|
||||
public void FishComeStop()
|
||||
{
|
||||
animator.Play("Idle01");
|
||||
ssplineAnimate.enabled = false;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/FishingB/FishCome.cs.meta
Normal file
11
Assets/Scripts/GampPlay/FishingB/FishCome.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e29717c77c91dc48a5f7012bf71dfda
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Scripts/GampPlay/FishingB/FishComeSplines.cs
Normal file
10
Assets/Scripts/GampPlay/FishingB/FishComeSplines.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Splines;
|
||||
|
||||
public class FishComeSplines : MonoBehaviour
|
||||
{
|
||||
public SplineContainer[] splineContainers;
|
||||
public SplineContainer[] UIEatSplines;
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/FishingB/FishComeSplines.cs.meta
Normal file
11
Assets/Scripts/GampPlay/FishingB/FishComeSplines.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a510cf4a44c38444da147bfb7fa9224a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
2601
Assets/Scripts/GampPlay/FishingB/FishingBehaviorB.cs
Normal file
2601
Assets/Scripts/GampPlay/FishingB/FishingBehaviorB.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Assets/Scripts/GampPlay/FishingB/FishingBehaviorB.cs.meta
Normal file
11
Assets/Scripts/GampPlay/FishingB/FishingBehaviorB.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a90fe48536dafa41809db36323d5571
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
104
Assets/Scripts/GampPlay/FishingB/FishingBehavior_EternalDeath.cs
Normal file
104
Assets/Scripts/GampPlay/FishingB/FishingBehavior_EternalDeath.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
public partial class FishingBehaviorB : MonoBehaviour
|
||||
{
|
||||
void OnStartEternalDeath()
|
||||
{
|
||||
SetFfishWeight();
|
||||
fishingData.IsCatchingFish = true;
|
||||
|
||||
if (fx_fishing_splashwaveloop != null)
|
||||
{
|
||||
fx_fishing_splashwaveloop.SetActive(false);
|
||||
}
|
||||
if (fx_fishing_splashloop != null)
|
||||
{
|
||||
fx_fishing_splashloop.SetActive(false);
|
||||
}
|
||||
fishAnimator.speed = 1;
|
||||
|
||||
fishAnimator.SetBool("_drawing01", false);
|
||||
fishAnimator.SetBool("_drawing02", false);
|
||||
fishAnimator.SetBool("_drawing", false);
|
||||
fishAnimator.SetBool("_idle", false);
|
||||
SetPulling();
|
||||
GContext.Publish(ERightState.PiercingSp);
|
||||
_targetPos = new Vector3(0, -3, fishingBehaviorConf.piercingFishmMoveZ);
|
||||
_fish.transform.position = _targetPos;
|
||||
_fish.transform.DOKill();
|
||||
//CloseIK(true);
|
||||
_fish.transform.localRotation = Quaternion.identity;
|
||||
|
||||
_cameraAnimator.SetBool("_claim", false);
|
||||
GContext.Publish(new PlayNewItemFxEvent() { type = 1 });
|
||||
if (FishBehaviour != null)
|
||||
{
|
||||
FishBehaviour.FishAnimSpeed = 1;
|
||||
//ReelingScale 鱼缩放
|
||||
Vector3 localScale = FishBehaviour.transform.localScale * fishingData.curFishData.PullingScale;
|
||||
FishBehaviour.transform.DOScale(localScale, fishingBehaviorConf.jumpScaleTime).OnUpdate
|
||||
(
|
||||
() =>
|
||||
{
|
||||
if (FishBehaviour.mouthPos != null)
|
||||
{
|
||||
Vector3 vector3 = Vector3.zero;
|
||||
vector3 = -FishBehaviour.animator.transform.InverseTransformPoint(FishBehaviour.mouthPos.position);
|
||||
vector3.z = -vector3.z;
|
||||
FishBehaviour.animator.transform.localPosition = vector3;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (!string.IsNullOrEmpty(fishingData.curFishData.FxWaterDrop))
|
||||
{
|
||||
FxWaterDrop(fishingData.curFishData.FxWaterDrop);
|
||||
}
|
||||
|
||||
MaterialChange();
|
||||
}
|
||||
|
||||
|
||||
if (fishingData.IsEventGameFish())
|
||||
{
|
||||
StartCoroutine(HideLine());
|
||||
FishBehaviour.Pulling();
|
||||
}
|
||||
StartCoroutine(DeathTimeScale());
|
||||
StartCoroutine(ControlFishOutWater());
|
||||
StartCoroutine(ChangeSpline());
|
||||
StartCoroutine(PlayPullingSound());
|
||||
if (fx_fishing_splashloop != null)
|
||||
{
|
||||
fx_fishing_splashloop.SetActive(false);
|
||||
}
|
||||
LoadEffect("fx_fishing_splashpull");
|
||||
|
||||
rodHandleAni.SetTrigger("_piercingSp");
|
||||
_cameraAnimator.SetTrigger("_piercingSp");
|
||||
fishingRodAnimator.SetTrigger("_piercingSp");
|
||||
fishAnimator.SetTrigger("_pullingSp");
|
||||
FishingPanel_Advanced.Instance?.ShowRankInfo();
|
||||
if (!string.IsNullOrEmpty(fishingData.curFishData.FxWaterSplash))
|
||||
GContext.Publish(new PlayerRaindropEvent() { FxWaterSplash = fishingData.curFishData.FxWaterSplash });
|
||||
GContext.Publish(new VibrationData(21));
|
||||
}
|
||||
IEnumerator DeathTimeScale()
|
||||
{
|
||||
yield return new WaitForSeconds(fishingBehaviorConf.timeStartScale);
|
||||
DOTween.To(() => 0.01f, x => Time.timeScale = x, 1,
|
||||
fishingBehaviorConf.timeEndScale - fishingBehaviorConf.timeStartScale)
|
||||
.SetEase(fishingBehaviorConf.piercingSpTimeScaleCurve);
|
||||
yield return new WaitForSeconds(fishingBehaviorConf.timeEndScale);
|
||||
Time.timeScale = 1f;
|
||||
}
|
||||
|
||||
IEnumerator ChangeSpline()
|
||||
{
|
||||
yield return new WaitForSeconds(fishingBehaviorConf.fishingRodDisappearsPullingSp);
|
||||
SetEffectActive("fx_fishing_splashloopreeling", false);
|
||||
ChangelineStartPos();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e3880afbe071694baae3e17b5891acf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
640
Assets/Scripts/GampPlay/FishingB/FishingBehavior_Move.cs
Normal file
640
Assets/Scripts/GampPlay/FishingB/FishingBehavior_Move.cs
Normal file
@@ -0,0 +1,640 @@
|
||||
using asap.core;
|
||||
using System;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
using cfg;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.AddressableAssets;
|
||||
public partial class FishingBehaviorB : MonoBehaviour
|
||||
{
|
||||
|
||||
#region 进出水面
|
||||
float OldFishPos = -3f;
|
||||
float jumpoutMaxCD = 0.2f;
|
||||
float jumpoutCD = 0f;
|
||||
public void JumpWater()
|
||||
{
|
||||
if (jumpoutCD > jumpoutMaxCD)
|
||||
{
|
||||
jumpoutCD = 0;
|
||||
float newFishPos = GetFishPos().y;
|
||||
if ((newFishPos - _waterHeight) * (OldFishPos - _waterHeight) < 0)
|
||||
{
|
||||
//进出水面
|
||||
if (newFishPos > _waterHeight - 0.00001f)
|
||||
{
|
||||
Vector3 vector = _fish.transform.position;
|
||||
vector.y = _waterHeight;
|
||||
if (fx_fishing_water != null)
|
||||
{
|
||||
fx_fishing_water.transform.position = vector;
|
||||
fx_fishing_water.gameObject.SetActive(false);
|
||||
fx_fishing_water.gameObject.SetActive(true);
|
||||
}
|
||||
else if (fx_fishing_jumpout != null)
|
||||
{
|
||||
fx_fishing_jumpout.transform.position = vector;
|
||||
fx_fishing_jumpout.gameObject.SetActive(false);
|
||||
fx_fishing_jumpout.gameObject.SetActive(true);
|
||||
}
|
||||
//播音效
|
||||
GContext.Publish(new EventFishingSound(SoundType.audio_fishing_jumpout));
|
||||
}
|
||||
else if (newFishPos < _waterHeight + 0.00001f)
|
||||
{
|
||||
Vector3 vector = _fish.transform.position;
|
||||
vector.y = _waterHeight;
|
||||
//进水面
|
||||
if (fx_fishing_water != null)
|
||||
{
|
||||
fx_fishing_water.transform.position = vector;
|
||||
fx_fishing_water.gameObject.SetActive(false);
|
||||
fx_fishing_water.gameObject.SetActive(true);
|
||||
}
|
||||
else if (fx_fishing_jumpinto != null)
|
||||
{
|
||||
fx_fishing_jumpinto.transform.position = vector;
|
||||
fx_fishing_jumpinto.gameObject.SetActive(false);
|
||||
fx_fishing_jumpinto.gameObject.SetActive(true);
|
||||
}
|
||||
//播音效
|
||||
GContext.Publish(new EventFishingSound(SoundType.audio_fishing_jumpinto));
|
||||
|
||||
}
|
||||
}
|
||||
OldFishPos = newFishPos;
|
||||
}
|
||||
jumpoutCD += Time.deltaTime;
|
||||
}
|
||||
#endregion 进出水面
|
||||
|
||||
//跳跃相关
|
||||
bool isJumping = false;
|
||||
float JumpDistance = 1;
|
||||
GameObject fx_fishing_water;
|
||||
//GameObject fxWaterSplash;
|
||||
GameObject fxHeadFishSkill;
|
||||
GameObject fxFishJumpWaterSkill;
|
||||
GameObject fxFishStruggleSkill;
|
||||
GameObject fxAppendFishSkill;
|
||||
public async void PlayFxFishSkill(IFishSpSkillData fishSpSkillData)
|
||||
{
|
||||
string fxFish = "";
|
||||
string fxFishJumpWater = "";
|
||||
string fxFishStruggle = "";
|
||||
switch (fishSpSkillData.fishSkill.PerformanceType)
|
||||
{
|
||||
case FishPerformanceType.Jump:
|
||||
//技能表现
|
||||
fxFish = fishSpSkillData.FxFishJump();
|
||||
fxFishJumpWater = fishSpSkillData.FxFishJumpWater();
|
||||
break;
|
||||
//case FishPerformanceType.Dash:
|
||||
// break;
|
||||
case FishPerformanceType.Struggle:
|
||||
fxFishStruggle = fishSpSkillData.FxFishStruggle();
|
||||
break;
|
||||
}
|
||||
string rootFx = fishSpSkillData.FxFishSkillAppend();
|
||||
string fxWater = fishSpSkillData.FxWater();
|
||||
//string fxWaterSplashName = fishSpSkillData.FxWaterSplash();
|
||||
if (!string.IsNullOrEmpty(fxWater) && fx_fishing_water == null)
|
||||
{
|
||||
fx_fishing_water = await Addressables.InstantiateAsync(fxWater, transform, true).Task;
|
||||
fx_fishing_water?.SetActive(false);
|
||||
}
|
||||
//if (!string.IsNullOrEmpty(fxWaterSplashName) && fxWaterSplash == null)
|
||||
//{
|
||||
// fxWaterSplash = await Addressables.InstantiateAsync(fxWater, transform).Task;
|
||||
// fxWaterSplash?.SetActive(true);
|
||||
//}
|
||||
if (!string.IsNullOrEmpty(fxFishJumpWater) && fxFishJumpWaterSkill == null)
|
||||
{
|
||||
fxFishJumpWaterSkill = await Addressables.InstantiateAsync(fxFishJumpWater, transform).Task;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(fxFishStruggle) && fxFishStruggleSkill == null && FishBehaviour != null)
|
||||
{
|
||||
fxFishStruggleSkill = await Addressables.InstantiateAsync(fxFishStruggle, FishBehaviour.transform).Task;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(fxFish) && fxHeadFishSkill == null && FishBehaviour != null && FishBehaviour.Head != null)
|
||||
{
|
||||
fxHeadFishSkill = await Addressables.InstantiateAsync(fxFish, FishBehaviour.Head).Task;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(rootFx) && fxAppendFishSkill == null && FishBehaviour != null && FishBehaviour.Root != null)
|
||||
{
|
||||
fxAppendFishSkill = await Addressables.InstantiateAsync(rootFx, FishBehaviour.Head).Task;
|
||||
}
|
||||
fxHeadFishSkill?.SetActive(false);
|
||||
fxHeadFishSkill?.SetActive(true);
|
||||
fxAppendFishSkill?.SetActive(false);
|
||||
fxAppendFishSkill?.SetActive(true);
|
||||
fxFishStruggleSkill?.SetActive(false);
|
||||
fxFishStruggleSkill?.SetActive(true);
|
||||
fxFishJumpWaterSkill?.SetActive(true);
|
||||
}
|
||||
|
||||
public void StopFxFishSkill()
|
||||
{
|
||||
fxHeadFishSkill?.SetActive(false);
|
||||
}
|
||||
public void SkillRelease()
|
||||
{
|
||||
if (fxHeadFishSkill != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(fxHeadFishSkill);
|
||||
fxHeadFishSkill = null;
|
||||
}
|
||||
|
||||
if (fxAppendFishSkill != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(fxAppendFishSkill);
|
||||
fxAppendFishSkill = null;
|
||||
}
|
||||
if (fx_fishing_water != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(fx_fishing_water);
|
||||
fx_fishing_water = null;
|
||||
}
|
||||
if (fxFishStruggleSkill != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(fxFishStruggleSkill);
|
||||
fxFishStruggleSkill = null;
|
||||
}
|
||||
if (fxFishJumpWaterSkill != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(fxFishJumpWaterSkill);
|
||||
fxFishJumpWaterSkill = null;
|
||||
}
|
||||
//if (fxWaterSplash != null)
|
||||
//{
|
||||
// Addressables.ReleaseInstance(fxWaterSplash);
|
||||
// fxWaterSplash = null;
|
||||
//}
|
||||
}
|
||||
public async void PlayJump()
|
||||
{
|
||||
FishData curFishData = fishingData.curFishData;
|
||||
isJumping = true;
|
||||
fishAnimator.SetTrigger($"_jumping0{fishingData.FishJump.AnimatorState}");
|
||||
fishAnimator.SetTrigger("_jumping");
|
||||
fishAnimator.SetTrigger($"_drawing0{curFishData.ShowAnimation}");
|
||||
if (FishBehaviour != null)
|
||||
{
|
||||
FishBehaviour.SetSkillInt(fishingData.FishJump.SkillIndex);
|
||||
FishBehaviour.SetTrigger("Skill");
|
||||
}
|
||||
FishJump fishJump = fishingData.FishJump;
|
||||
if (fishJump != null)
|
||||
{
|
||||
_ = StartCoroutine(PlayerJumpOutDelay(fishJump.FxJumpOutDelay, fishJump.JumpDistance));
|
||||
_ = StartCoroutine(PlayerJumpIntoDelay(fishJump.FxJumpIntoDelay));
|
||||
float jumpEndTime = fishJump.JumpEndTime;
|
||||
await Awaiters.Seconds(jumpEndTime);
|
||||
}
|
||||
isJumping = false;
|
||||
JumpDistance = 1;
|
||||
if (fxFishJumpWaterSkill != null)
|
||||
{
|
||||
fxFishJumpWaterSkill.SetActive(true);
|
||||
}
|
||||
//if (fxWaterSplash != null)
|
||||
//{
|
||||
// fxWaterSplash.transform.localScale = Vector3.one * fishingData.curFishData.SlashFxScale;
|
||||
// fxWaterSplash.SetActive(true);
|
||||
//}
|
||||
//else
|
||||
if (fx_fishing_splashloop != null)
|
||||
{
|
||||
fx_fishing_splashloop.transform.localScale = Vector3.one * fishingData.curFishData.SlashFxScale;
|
||||
fx_fishing_splashloop.SetActive(true);
|
||||
}
|
||||
if (fx_fishing_splashwaveloop != null)
|
||||
{
|
||||
fx_fishing_splashwaveloop.transform.localScale = Vector3.one * fishingData.curFishData.SlashFxScale;
|
||||
fx_fishing_splashwaveloop.SetActive(true);
|
||||
}
|
||||
}
|
||||
IEnumerator PlayerJumpOutDelay(float fxJumpOutDelay, float jumpDistance)
|
||||
{
|
||||
//if (fxWaterSplash != null)
|
||||
//{
|
||||
// fxWaterSplash.transform.DOScale(Vector3.zero, fxJumpOutDelay).SetEase(Ease.Linear);
|
||||
//}
|
||||
if (fx_fishing_splashloop != null)
|
||||
{
|
||||
fx_fishing_splashloop.transform.DOScale(Vector3.zero, fxJumpOutDelay).SetEase(Ease.Linear);
|
||||
}
|
||||
if (fx_fishing_splashwaveloop != null)
|
||||
{
|
||||
fx_fishing_splashwaveloop.transform.DOScale(Vector3.zero, fxJumpOutDelay).SetEase(Ease.Linear);
|
||||
}
|
||||
yield return new WaitForSeconds(fxJumpOutDelay);
|
||||
GContext.Publish(new EventFishingSound(SoundType.HPEvent));
|
||||
CloseBaitDoTween();
|
||||
JumpDistance = jumpDistance;
|
||||
//if (fx_fishing_splashpull != null)
|
||||
//{
|
||||
// Vector3 vector = _fish.transform.position;
|
||||
// vector.y = _waterHeight;
|
||||
// fx_fishing_splashpull.transform.position = vector;
|
||||
// fx_fishing_splashpull.SetActive(false);
|
||||
// fx_fishing_splashpull.SetActive(true);
|
||||
//}
|
||||
//if (fx_fishing_water != null)
|
||||
//{
|
||||
// fx_fishing_water.SetActive(false);
|
||||
//}
|
||||
if (fx_fishing_splashloop != null)
|
||||
{
|
||||
fx_fishing_splashloop.SetActive(false);
|
||||
}
|
||||
if (fx_fishing_splashwaveloop != null)
|
||||
{
|
||||
fx_fishing_splashwaveloop.SetActive(false);
|
||||
}
|
||||
|
||||
if (fxFishJumpWaterSkill != null)
|
||||
{
|
||||
fxFishJumpWaterSkill.SetActive(false);
|
||||
}
|
||||
}
|
||||
IEnumerator PlayerJumpIntoDelay(float fxJumpIntoDelay)
|
||||
{
|
||||
yield return new WaitForSeconds(fxJumpIntoDelay);
|
||||
GContext.Publish(new EventFishingSound(SoundType.HPEvent));
|
||||
CloseBaitDoTween();
|
||||
JumpDistance = 1;
|
||||
|
||||
//if (fx_fishing_splashpull != null)
|
||||
//{
|
||||
// Vector3 vector = _fish.transform.position;
|
||||
// vector.y = _waterHeight;
|
||||
// fx_fishing_splashpull.transform.position = vector;
|
||||
// fx_fishing_splashpull.SetActive(false);
|
||||
// fx_fishing_splashpull.SetActive(true);
|
||||
//}
|
||||
}
|
||||
public void StartSplashloopScale()
|
||||
{
|
||||
Vector3 localScale = Vector3.one * fishingData.curFishData.SlashFxScale * 1.5f;
|
||||
if (fx_fishing_splashloop != null)
|
||||
{
|
||||
fx_fishing_splashloop.transform.DOKill();
|
||||
fx_fishing_splashloop.transform.localScale = localScale;
|
||||
}
|
||||
if (fx_fishing_splashwaveloop != null)
|
||||
{
|
||||
fx_fishing_splashwaveloop.transform.DOKill();
|
||||
fx_fishing_splashwaveloop.transform.localScale = localScale;
|
||||
}
|
||||
}
|
||||
public void EndSplashloopScale()
|
||||
{
|
||||
Vector3 localScale = Vector3.one * fishingData.curFishData.SlashFxScale;
|
||||
if (fx_fishing_splashloop != null)
|
||||
{
|
||||
fx_fishing_splashwaveloop.transform.DOKill();
|
||||
fx_fishing_splashloop.transform.DOScale(localScale, 1).SetEase(Ease.Linear);
|
||||
}
|
||||
if (fx_fishing_splashwaveloop != null)
|
||||
{
|
||||
fx_fishing_splashwaveloop.transform.DOKill();
|
||||
fx_fishing_splashwaveloop.transform.DOScale(localScale, 1).SetEase(Ease.Linear);
|
||||
}
|
||||
}
|
||||
//====跳跃相关
|
||||
//=====================鱼移动算法挪位置
|
||||
private float timer = 1f;
|
||||
float dashTime = 0f;
|
||||
|
||||
private float moveTimer = 0f;
|
||||
private Vector3 _strugglePoint;
|
||||
|
||||
private Vector3 _startPos;
|
||||
private Vector3 _curStartPos;
|
||||
Tweener baitDoTween;
|
||||
//X轴偏移
|
||||
float _nearDistance = 1;
|
||||
float _farDistance = 1;
|
||||
float distance = 1;
|
||||
float fishSpeed = 1;
|
||||
public bool Far => _fish.transform.position.z >= _farDistance;
|
||||
void SetBaitStartPos()
|
||||
{
|
||||
_nearDistance = _fishSwimAreaZNear;
|
||||
_nearDistance = Mathf.Clamp(_nearDistance, _fishSwimAreaZNear, _fishSwimAreaZFar);
|
||||
_farDistance = _fishSwimAreaZFar;
|
||||
_farDistance = Mathf.Clamp(_farDistance, _fishSwimAreaZNear, _fishSwimAreaZFar);
|
||||
_startPos = _fish.transform.position;
|
||||
_curStartPos = _startPos;
|
||||
|
||||
float z = Random.Range(_nearDistance, _farDistance);
|
||||
_strugglePoint = GeneratePoint(z, 0) / 2;
|
||||
timer = 10;
|
||||
}
|
||||
public async void OnFail(float z, float speed)
|
||||
{
|
||||
EscapeFish(z);
|
||||
var targetPos = Vector3.Lerp(_curStartPos, _strugglePoint, fishSpeed / distance);
|
||||
_fish.transform.DOMove(targetPos, 1);
|
||||
await Awaiters.Seconds(1);
|
||||
GetFish.gameObject.SetActive(false);
|
||||
if (fx_fishing_splashloop != null)
|
||||
{
|
||||
fx_fishing_splashloop.SetActive(false);
|
||||
}
|
||||
if (fx_fishing_splashwaveloop != null)
|
||||
{
|
||||
fx_fishing_splashwaveloop.SetActive(false);
|
||||
}
|
||||
}
|
||||
//往安全区域外移动
|
||||
public void EscapeFish(float z)
|
||||
{
|
||||
moveTimer = 0;
|
||||
_strugglePoint.z = z;
|
||||
_strugglePoint.x = 0;
|
||||
_curStartPos = _fish.transform.position;
|
||||
distance = Vector3.Distance(_curStartPos, _strugglePoint);
|
||||
FishTurn();
|
||||
}
|
||||
void SimulateFishEscape(float fishSpeed)
|
||||
{
|
||||
moveTimer += Time.deltaTime * fishSpeed;
|
||||
|
||||
if (moveTimer / distance < 1)
|
||||
{
|
||||
_fish.transform.position = Vector3.Lerp(_curStartPos, _strugglePoint, moveTimer / distance);
|
||||
Debug.Log("moveTimer / distance:" + _strugglePoint);
|
||||
}
|
||||
}
|
||||
//停止正常的移动,贝塞尔DoTween
|
||||
public void CloseBaitDoTween()
|
||||
{
|
||||
if (baitDoTween != null)
|
||||
{
|
||||
baitDoTween.Kill();
|
||||
baitDoTween = null;
|
||||
timer = 10;
|
||||
}
|
||||
}
|
||||
public void DashStayTime()
|
||||
{
|
||||
SetFishDash();
|
||||
dashTime = fishingData.DashStayTime + 1;
|
||||
timer = 10;
|
||||
}
|
||||
void SetFishDash()
|
||||
{
|
||||
fishingData.DashStay = GetFishDash();
|
||||
if (FishBehaviour != null && fishingData.DashStay != null)
|
||||
{
|
||||
FishBehaviour.SetSkillInt(fishingData.DashStay.SkillIndex);
|
||||
}
|
||||
}
|
||||
public void SetStruggle()
|
||||
{
|
||||
if (FishBehaviour != null && fishingData.FishStruggle != null)
|
||||
{
|
||||
FishBehaviour.SetSkillInt(fishingData.FishStruggle.SkillIndex);
|
||||
FishBehaviour.SetTrigger("Skill");
|
||||
}
|
||||
}
|
||||
public void StartMoveFish()
|
||||
{
|
||||
timer = 10;
|
||||
}
|
||||
//能随时修改速度的移动轨迹
|
||||
void SimulateFish(float fishSpeed, float nearDistance, float farDistance)
|
||||
{
|
||||
this.fishSpeed = fishSpeed;
|
||||
if (NotMove)
|
||||
{
|
||||
CloseBaitDoTween();
|
||||
return;
|
||||
}
|
||||
_nearDistance = nearDistance * (_fishSwimAreaZFar - _fishSwimAreaZNear) + _fishSwimAreaZNear;
|
||||
_nearDistance = Mathf.Clamp(_nearDistance, _fishSwimAreaZNear, _fishSwimAreaZFar);
|
||||
_farDistance = farDistance * (_fishSwimAreaZFar - _fishSwimAreaZNear) + _fishSwimAreaZFar;
|
||||
_farDistance = Mathf.Clamp(_farDistance, _fishSwimAreaZNear, _fishSwimAreaZFar);
|
||||
timer += Time.deltaTime;
|
||||
moveTimer += Time.deltaTime * fishSpeed;
|
||||
|
||||
if (timer > Random.Range(5f, 10f) || Vector3.Distance(_fish.transform.position, _strugglePoint) < 1)
|
||||
{
|
||||
CloseBaitDoTween();
|
||||
float escapeDistanceMag = GContext.container.Resolve<PlayerData>().GrtEscapeDistanceMag();
|
||||
if (fishingData.DashStay != null)
|
||||
{
|
||||
if (!DashMove())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isDashMove = false;
|
||||
float z = Random.Range(_nearDistance, _farDistance);
|
||||
if (fishingData.MaxZEscape > 0.001f)
|
||||
{
|
||||
z = fishingData.MaxZEscape * escapeDistanceMag;
|
||||
}
|
||||
_strugglePoint = GeneratePoint(z, _fish.transform.position.x);
|
||||
}
|
||||
timer = 0;
|
||||
moveTimer = 0;
|
||||
_strugglePoint.y = GetFishUnderwaterOffset();
|
||||
if (fishingData.MaxYEscape > 0.001f)
|
||||
{
|
||||
_strugglePoint.y = fishingData.MaxYEscape * escapeDistanceMag;
|
||||
}
|
||||
if (fishingData.MaxZEscape > 0.001f)
|
||||
{
|
||||
_strugglePoint.z = fishingData.MaxZEscape * escapeDistanceMag;
|
||||
if (_strugglePoint.z < _fishSwimAreaZFar)
|
||||
{
|
||||
_strugglePoint.z = _fishSwimAreaZFar;
|
||||
}
|
||||
if (fishingData.DashStayTime <= 0 &&
|
||||
!isJumping &&
|
||||
_fish.transform.position.z < _strugglePoint.z - 5)
|
||||
{
|
||||
_strugglePoint.x = 0;
|
||||
}
|
||||
}
|
||||
_curStartPos = _fish.transform.position;
|
||||
_curStartPos.y = GetFishUnderwaterOffset();
|
||||
distance = Vector3.Distance(_curStartPos, _strugglePoint);
|
||||
//开始转向
|
||||
FishTurn();
|
||||
|
||||
Vector3 offset = _strugglePoint - _curStartPos;
|
||||
Vector3 mid = (_strugglePoint + _curStartPos) / 2;
|
||||
float x;
|
||||
if (Math.Abs(offset.x) > Math.Abs(offset.z))
|
||||
{
|
||||
x = offset.x * Random.Range(0, 0.25f);
|
||||
mid.z += offset.x * Random.Range(-0.25f, 0.25f);
|
||||
}
|
||||
else
|
||||
{
|
||||
//z轴比较长
|
||||
x = offset.z * Random.Range(0, 0.25f);
|
||||
mid.z += offset.z * Random.Range(-0.25f, 0.25f);
|
||||
}
|
||||
if (mid.x * x > 0)
|
||||
{
|
||||
mid.x -= x;
|
||||
}
|
||||
else
|
||||
{
|
||||
mid.x += x;
|
||||
}
|
||||
float turnTime = 0;
|
||||
Vector3 fishPos = _fish.transform.position;
|
||||
Vector3[] path = new Vector3[] { _curStartPos, mid, _strugglePoint };// GetBezierCurvePoints(_curStartPos, mid, _strugglePoint, 10);
|
||||
baitDoTween = _fish.transform.DOPath(path, fishSpeed, PathType.CatmullRom).SetSpeedBased(true)
|
||||
.OnUpdate((() =>
|
||||
{
|
||||
if (turnTime > GetTurnTime() + 0.2)
|
||||
{
|
||||
Quaternion rotation = Quaternion.LookRotation(fishPos - _fish.transform.position);
|
||||
_fish.transform.rotation = rotation;
|
||||
}
|
||||
else if (turnTime > GetTurnTime())
|
||||
{
|
||||
Quaternion rotation = Quaternion.LookRotation(fishPos - _fish.transform.position);
|
||||
_fish.transform.rotation = Quaternion.Lerp(_fish.transform.rotation, rotation, (turnTime - GetTurnTime()) * 5);
|
||||
}
|
||||
fishPos = _fish.transform.position;
|
||||
turnTime += Time.deltaTime;
|
||||
}));
|
||||
if (fishingData.DashStayTime > 0.001f)
|
||||
{
|
||||
baitDoTween.SetEase(Ease.OutCubic);
|
||||
}
|
||||
else
|
||||
{
|
||||
baitDoTween.SetEase(Ease.Linear);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void FishTurn()
|
||||
{
|
||||
FishingPanel_Advanced.Instance?.SetFishIconDir(_fish.transform.position.x > _strugglePoint.x);
|
||||
|
||||
Quaternion rotation = Quaternion.LookRotation(_fish.transform.position - _strugglePoint);
|
||||
_fish.transform.DORotateQuaternion(rotation, GetTurnTime())/*.SetEase(Ease.InOutSine);*/;
|
||||
}
|
||||
Vector3 GeneratePoint(float z, float curX)
|
||||
{
|
||||
float x1 = (_fishSwimAreaXNear - _fishSwimAreaXFar) / (_fishSwimAreaZNear - _fishSwimAreaZFar) * (z - _fishSwimAreaZFar) + _fishSwimAreaXFar;
|
||||
//float x = Random.Range(_fishSwimAreaXNear, x1);
|
||||
float min = curX - (x1 * XAxisMaxProportion * 2);
|
||||
float max = curX + (x1 * XAxisMaxProportion * 2);
|
||||
if (min < -x1)
|
||||
{
|
||||
min = -x1;
|
||||
}
|
||||
if (max > x1)
|
||||
{
|
||||
max = x1;
|
||||
}
|
||||
float x = Random.Range(min, max);
|
||||
return new Vector3(x, 0, z);
|
||||
}
|
||||
bool isDashMove;
|
||||
bool DashMove()
|
||||
{
|
||||
fx_fishing_splashloopreeling.SetActive(false);
|
||||
if (!isDashMove)
|
||||
{
|
||||
isDashMove = true;
|
||||
StartSplashloopScale();
|
||||
FishBehaviour.SetTrigger("Skill");
|
||||
}
|
||||
dashTime += Time.deltaTime;
|
||||
if (dashTime < fishingData.DashStayTime)
|
||||
{
|
||||
fishingData.SetFishSkillPerformSpeed(dashTime / fishingData.DashStayTime);
|
||||
return false;
|
||||
}
|
||||
isDashMove = false;
|
||||
EndSplashloopScale();
|
||||
if (fishingData.DashStayTime < 0)
|
||||
{
|
||||
fishingData.DashStay = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFishDash();
|
||||
}
|
||||
if (FishBehaviour)
|
||||
{
|
||||
FishBehaviour.PlaySwim01();
|
||||
}
|
||||
fishingData.FishSkillPerformSpeed = 1 / fishingData.FishSkillIncPerform;
|
||||
DOTween.To(() => fishingData.FishSkillPerformSpeed,
|
||||
x => fishingData.FishSkillPerformSpeed = x, 1, Random.Range(5f, 10f)).SetId("FishSkillPerformSpeed");
|
||||
fishingData.FishSkillPerformBack = 1;
|
||||
dashTime = 0;
|
||||
_strugglePoint = DashPoint(_fish.transform.position.x);
|
||||
GContext.Publish(new EventFishingSound(SoundType.audio_fishing_dash));
|
||||
fx_fishing_splashloopreeling.SetActive(true);
|
||||
return true;
|
||||
}
|
||||
FishDash GetFishDash()
|
||||
{
|
||||
List<int> animationTypeList = fishingData.curFishData.AnimationTypeList;
|
||||
if (animationTypeList.Count <= 1)
|
||||
{
|
||||
return _tables.TbFishDash.GetOrDefault(animationTypeList[0]);
|
||||
}
|
||||
List<FishDash> fishDashes = new List<FishDash>();
|
||||
int weight = 0;
|
||||
foreach (var item in animationTypeList)
|
||||
{
|
||||
FishDash fishDash = _tables.TbFishDash.GetOrDefault(item);
|
||||
if (fishDash != null)
|
||||
{
|
||||
fishDashes.Add(fishDash);
|
||||
weight += fishDash.Weight;
|
||||
}
|
||||
}
|
||||
if (fishDashes.Count == 1)
|
||||
{
|
||||
return fishDashes[0];
|
||||
}
|
||||
int random = Random.Range(0, weight);
|
||||
foreach (var item in fishDashes)
|
||||
{
|
||||
random -= item.Weight;
|
||||
if (random <= 0)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
Debug.LogError("Not FishDash FishDataID =" + fishingData.curFishData.ID);
|
||||
return null;
|
||||
}
|
||||
|
||||
Vector3 DashPoint(float curX)
|
||||
{
|
||||
float z = Random.Range(_nearDistance, _farDistance);
|
||||
float x1 = (_fishSwimAreaXNear - _fishSwimAreaXFar) / (_nearDistance - _farDistance) * (z - _farDistance) + _fishSwimAreaXFar;
|
||||
float point = Mathf.Abs(curX) + x1;
|
||||
float nextPointNear = point * fishingData.NextPointNearDistance;
|
||||
float nextPointFar = point * fishingData.NextPointFarDistance;
|
||||
point = Random.Range(nextPointNear, nextPointFar);
|
||||
float x = curX + point;
|
||||
if (curX > 0)
|
||||
{
|
||||
x = curX - point;
|
||||
}
|
||||
return new Vector3(x, 0, z);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82d230667422ded42864e06eb74e4319
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
258
Assets/Scripts/GampPlay/FishingB/FishingData.cs
Normal file
258
Assets/Scripts/GampPlay/FishingB/FishingData.cs
Normal file
@@ -0,0 +1,258 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
public class FishingData
|
||||
{
|
||||
public FishingBehaviorConf fishingBehaviorConf { private set; get; }
|
||||
cfg.Tables _tables;
|
||||
// 是否正在遛鱼
|
||||
public bool IsDrawing;
|
||||
// 是否正在抓鱼
|
||||
public bool IsCatchingFish;
|
||||
|
||||
// 是否抓到鱼了
|
||||
public bool IsCaughtFish;
|
||||
|
||||
// 是否弹出奖励界面
|
||||
public bool IsShowRewardPanel;
|
||||
//public bool AutomaticFishing;
|
||||
|
||||
public MapData curMapData;
|
||||
public int MapId;
|
||||
public FishData curFishData;
|
||||
public FixedFishList fixedFishList;
|
||||
public FishData swimFishData;
|
||||
public int RodId;
|
||||
public RodData fishRodData;
|
||||
public Item fishItem;
|
||||
//吃鱼相关
|
||||
public Item swimItem;
|
||||
//吃鱼序列
|
||||
public List<FishData> fishEatDataList;
|
||||
public float fishWeight { get; set; }
|
||||
public float random { get; set; }
|
||||
public int CardLevel { get; set; }
|
||||
public float EventFishDamageMag { get; set; }
|
||||
public float CardDamageMag { get; set; }
|
||||
|
||||
public float WeightIncEvent { get; set; }
|
||||
public float StrugglingPower { get; set; }//鱼的力量
|
||||
public float FishingRetryPowerReduction { get; set; } = 1;
|
||||
public float FishingRetryEscapeReduction { get; set; } = 1;
|
||||
public float FishingRetryHPReduction { get; set; } = 1;
|
||||
public float Speed { get; set; }//鱼的速度
|
||||
|
||||
public float Vigilance { get; set; }//鱼的警惕性
|
||||
public float MaxLinelength;
|
||||
public float MaxZEscape;
|
||||
public float MaxYEscape;
|
||||
public float DashStayTime;
|
||||
public FishDash DashStay;
|
||||
public FishStruggle FishStruggle;
|
||||
public FishJump FishJump;
|
||||
public float NextPointNearDistance;
|
||||
public float NextPointFarDistance;
|
||||
//等鱼上钩
|
||||
public float EnhancedWaitingTime;
|
||||
public float ExtraUnderwaterOffset;
|
||||
public bool isWeather = false;
|
||||
|
||||
public int NewItemID = 0;
|
||||
public int NewIndex = 0;
|
||||
//public float ClickFishFlapping = 1f;
|
||||
//public float BottleOpenDelay = 1.95f;
|
||||
//public float FishFlapping = 3.05f;
|
||||
//钓鱼结果
|
||||
public FishingResult fishingResult = FishingResult.Success;
|
||||
public float FishSpeed; //鱼的速度对移动速度的影响
|
||||
public List<float> StrengthToScale { get; set; }
|
||||
public float FishVigilanceToTime { get; set; }
|
||||
public float RodVigilanceToTime { get; set; }
|
||||
//目标奖励活动相关
|
||||
public Vector3 image_extra_pos { set; get; }
|
||||
public int addCollecting { set; get; }
|
||||
//目标奖励活动相关
|
||||
public Transform mainCamera;
|
||||
public Quaternion startEuler;
|
||||
|
||||
|
||||
public float startTimer;
|
||||
public float endTimer;
|
||||
|
||||
//ui吃鱼的血量比
|
||||
public float UIEatHpPercent = -1;
|
||||
|
||||
//目标奖励活动Buff相关
|
||||
public bool isMapBuff = false;
|
||||
public bool isAddTargetBuff;
|
||||
public bool isAddPiggyBank;
|
||||
public bool isAddBarginPack;
|
||||
public SupplyDropCtrl supplyDropCtrl;
|
||||
public bool IsHideRod => supplyDropCtrl != null || isAddTargetBuff || isAddPiggyBank || isAddBarginPack;
|
||||
public bool isAwaitTargetBuff;
|
||||
public bool isShowTargetPanel;
|
||||
public int jerking_count = 0;
|
||||
public int stickle_state = 0;
|
||||
|
||||
public float FishAnimSpeed = 1;
|
||||
public bool IsFree = false;
|
||||
public bool IsDuel = false;
|
||||
public bool IsRetry = false;
|
||||
public int retry_ways = 0;
|
||||
//特殊技能结算音效
|
||||
public string AudioRewardFish;
|
||||
public DateTime LastCastingTime;
|
||||
public int rodType;
|
||||
public async System.Threading.Tasks.Task Init()
|
||||
{
|
||||
fishingBehaviorConf = (FishingBehaviorConf)(await Addressables.LoadAssetAsync<object>("FishingBehaviorConf").Task);
|
||||
_tables = GContext.container.Resolve<cfg.Tables>();
|
||||
}
|
||||
public void SetRodData(RodData fishRodData)
|
||||
{
|
||||
this.fishRodData = fishRodData;
|
||||
RodId = fishRodData.ID;
|
||||
}
|
||||
public void ChangeFishData(FishData curFishData)
|
||||
{
|
||||
this.curFishData = curFishData;
|
||||
}
|
||||
|
||||
public float HoldThreshold()
|
||||
{
|
||||
if (fishRodData != null)
|
||||
{
|
||||
return fishRodData.HoldThreshold;
|
||||
}
|
||||
if (fishRodData != null)
|
||||
{
|
||||
return fishRodData.HoldThreshold;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public bool IsNewItemFish()
|
||||
{
|
||||
//return NewItemID == fishItem.ID;
|
||||
return fishItem.Quality > 5;
|
||||
}
|
||||
public bool IsEventGameFish()
|
||||
{
|
||||
return fishItem.SubType == 11 || fishItem.SubType == 12;
|
||||
}
|
||||
public bool IsGeneralFish()
|
||||
{
|
||||
return fishItem.SubType == 1;
|
||||
}
|
||||
public bool IsKeepsakeFish()
|
||||
{
|
||||
return fishItem.SubType == 4;
|
||||
}
|
||||
public bool IsPiggyBankFish()
|
||||
{
|
||||
return fishItem.SubType == 22;
|
||||
}
|
||||
public bool IsBarginPackFish()
|
||||
{
|
||||
return fishItem.SubType == 21;
|
||||
}
|
||||
public bool IsPackItemFish()
|
||||
{
|
||||
return fishItem.SubType == 21 || fishItem.SubType == 22;
|
||||
}
|
||||
public List<float> SwimmingAreaX()
|
||||
{
|
||||
return curMapData.SwimmingAreaX;
|
||||
}
|
||||
public List<float> SwimmingAreaZ()
|
||||
{
|
||||
return curMapData.SwimmingAreaZ;
|
||||
}
|
||||
public float CameraMaxAngle()
|
||||
{
|
||||
return curMapData.CameraMaxAngle;
|
||||
}
|
||||
public float FishMaxAngle()
|
||||
{
|
||||
return curMapData.FishMaxAngle;
|
||||
}
|
||||
|
||||
public bool IsEact()
|
||||
{
|
||||
return fishEatDataList.Count > 0;
|
||||
}
|
||||
|
||||
//相机相关 SetCamera
|
||||
public void SetCamera(Transform camera)
|
||||
{
|
||||
mainCamera = camera;
|
||||
camera.localEulerAngles = new Vector3(0, 0, 0);
|
||||
startEuler = camera.localRotation;
|
||||
}
|
||||
|
||||
public float GetFishingTimer()
|
||||
{
|
||||
return endTimer - startTimer;
|
||||
}
|
||||
public void StopAuto()
|
||||
{
|
||||
GContext.Publish(new StopAutoEvent() { IsDrawing = IsDrawing });
|
||||
}
|
||||
|
||||
public void InitEatHp()
|
||||
{
|
||||
UIEatHpPercent = -1;
|
||||
var fixedFishList = _tables.TbFixedFishList.GetOrDefault(GContext.container.Resolve<PlayerFishData>().GetAnglingCount() + 1);
|
||||
if (fixedFishList != null && fixedFishList.EatFishType != 0)
|
||||
{
|
||||
if (fixedFishList.EatFishType == 1)
|
||||
{
|
||||
UIEatHpPercent = fixedFishList.UIEatHpPercent;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var EatFishData = _tables.TbFishEatFish.GetOrDefault(swimFishData.EatFishID);
|
||||
UIEatHpPercent = UnityEngine.Random.Range(0, 1f);
|
||||
if (EatFishData != null && EatFishData.EatWeight > 0)
|
||||
{
|
||||
int weight = EatFishData.UIEatWeight + EatFishData.EatWeight;
|
||||
int w = UnityEngine.Random.Range(0, weight);
|
||||
if (w < EatFishData.UIEatWeight)
|
||||
{
|
||||
UIEatHpPercent = UnityEngine.Random.Range(EatFishData.UIEatHpPercent[0], EatFishData.UIEatHpPercent[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
UIEatHpPercent = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float FishSkillIncPerform;
|
||||
public float FishSkillDecPerform;
|
||||
public float FishSkillPerformSpeed;//鱼技能表现张力系数
|
||||
public float FishSkillPerformBack;//鱼技能表现张力系数
|
||||
public void SetFishSkillPerformSpeed(float p)
|
||||
{
|
||||
FishSkillPerformSpeed = FishSkillIncPerform + (1 - FishSkillIncPerform) * p;
|
||||
FishSkillPerformBack = FishSkillDecPerform + (1 - FishSkillDecPerform) * p;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
FishingRetryPowerReduction = 1;
|
||||
FishingRetryEscapeReduction = 1;
|
||||
FishingRetryHPReduction = 1;
|
||||
fishItem = null;
|
||||
NewItemID = 0;
|
||||
fixedFishList = null;
|
||||
IsRetry = false;
|
||||
AudioRewardFish = null;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/FishingB/FishingData.cs.meta
Normal file
11
Assets/Scripts/GampPlay/FishingB/FishingData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee10b0b1e3933224db89304597960212
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
117
Assets/Scripts/GampPlay/FishingB/FishingStateMaxCombo.cs
Normal file
117
Assets/Scripts/GampPlay/FishingB/FishingStateMaxCombo.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using MoreMountains.NiceVibrations;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
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<Tables>().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<Tables>().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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3c4c1bf8e96e1541a364094ccb375de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/Scripts/GampPlay/FishingB/FishingStateMove.cs
Normal file
24
Assets/Scripts/GampPlay/FishingB/FishingStateMove.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FishingStateMove : IFishingState
|
||||
{
|
||||
public FishingStateName fishingState => FishingStateName.Move;
|
||||
|
||||
public FishingBehaviorB fishingBehavior { get; set; }
|
||||
float speed = 1;
|
||||
public float fishMoveSpeed { get => speed; set => speed = value; }
|
||||
|
||||
public void InState(FishingBehaviorB fishingBehavior, FishingData fishingData)
|
||||
{
|
||||
}
|
||||
|
||||
public void OutState()
|
||||
{
|
||||
}
|
||||
|
||||
public void UpdateState()
|
||||
{
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/FishingB/FishingStateMove.cs.meta
Normal file
11
Assets/Scripts/GampPlay/FishingB/FishingStateMove.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d3cb293c1fb29744a590ab96b9cd632
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
2802
Assets/Scripts/GampPlay/FishingB/FishingUpdateSys.cs
Normal file
2802
Assets/Scripts/GampPlay/FishingB/FishingUpdateSys.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Assets/Scripts/GampPlay/FishingB/FishingUpdateSys.cs.meta
Normal file
11
Assets/Scripts/GampPlay/FishingB/FishingUpdateSys.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce84c0eb9d20a454f8c6f702ecfc4747
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/GampPlay/FishingB/FlyingFish.meta
Normal file
8
Assets/Scripts/GampPlay/FishingB/FlyingFish.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 809e6ea11db3c994a8dac9eb2df60dd6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class FishingFlyingFish : MonoBehaviour
|
||||
{
|
||||
protected FishingBehaviorB fishingBehavior;
|
||||
protected FishingData fishingData;
|
||||
public abstract void StartFlying(FishingBehaviorB fishingBehavior, FishingData fishingData);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2e37ed40f6b14946b7154452c493fba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,137 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using UnityEngine;
|
||||
|
||||
public class FishingFlyingWhale : FishingFlyingFish
|
||||
{
|
||||
public float enterDelayTime = 1f;
|
||||
public float rodInactiveDelay = 1.1f;
|
||||
public float rodAppearDelay = 2.83f;
|
||||
public float drawingDelay = 3f;//结束
|
||||
public float fishSpSwimmingToMapTime = 1f;
|
||||
public float spExitDelay = 4;
|
||||
public float spDamageProtectionTime = 0.2f;
|
||||
public Vector3 fishSpEatPoint = new Vector3(0, -3, 35);
|
||||
public Vector3 fishToMouthPos = new Vector3(-1.5f, 0, -0.1f);
|
||||
public Vector3 fishToMouthRot = new Vector3(0, 86, 0);
|
||||
public override void StartFlying(FishingBehaviorB fishingBehavior, FishingData fishingData)
|
||||
{
|
||||
this.fishingBehavior = fishingBehavior;
|
||||
this.fishingData = fishingData;
|
||||
FishMove();
|
||||
}
|
||||
|
||||
async void FishMove()
|
||||
{
|
||||
//转弯
|
||||
var _fish = fishingBehavior.GetFish;
|
||||
var _strugglePoint = fishSpEatPoint;
|
||||
//_strugglePoint.y = _fish.transform.position.y;
|
||||
Quaternion rotation = Quaternion.LookRotation(_fish.transform.position - _strugglePoint);
|
||||
_fish.transform.DORotateQuaternion(rotation, 0.1f);
|
||||
_fish.transform.DOMove(_strugglePoint, enterDelayTime);
|
||||
await Awaiters.Seconds(enterDelayTime);
|
||||
fishingBehavior.CameraToFish = false;
|
||||
fishingData.mainCamera.DOLocalRotateQuaternion(Quaternion.identity, 0.5f);
|
||||
fishingBehavior.FishBehaviour.transform.parent = fishingBehavior.FishComeAnimationRoot.transform;
|
||||
fishingBehavior.FishBehaviour.transform.localPosition = fishToMouthPos;
|
||||
fishingBehavior.FishBehaviour.transform.localEulerAngles = fishToMouthRot;
|
||||
FishingPanel_Advanced.Instance?.ShowState(3);
|
||||
EatFishAction();
|
||||
RodMove();
|
||||
//开始timeScale缩放
|
||||
AniEatTimeScale();
|
||||
DarknessTimeDelay();
|
||||
AniExitTime();
|
||||
await Awaiters.Seconds(drawingDelay);
|
||||
fishingBehavior.DestroySwimFish();
|
||||
fishingBehavior.RodDrawing();
|
||||
fishingBehavior.SetDrawingForce(1);
|
||||
GContext.Publish(new LoadFishListEvent() { isShow = true });
|
||||
fishingBehavior.CameraToFish = true;
|
||||
FishSwimming();
|
||||
}
|
||||
async void RodMove()
|
||||
{
|
||||
fishingBehavior.fishingRodAnimator.SetTrigger("_pulling");
|
||||
GContext.Publish(ERightState.Pulling);
|
||||
|
||||
await Awaiters.Seconds(rodInactiveDelay);
|
||||
float delay = rodAppearDelay - rodInactiveDelay;
|
||||
fishingBehavior.ChangelineStartPos();
|
||||
GContext.Publish(ERightState.Preparing);
|
||||
await Awaiters.Seconds(delay);
|
||||
fishingBehavior.IsChangelineStartPos = false;
|
||||
fishingBehavior.ShowRod(true);
|
||||
}
|
||||
async void AniEatTimeScale()
|
||||
{
|
||||
var fishingBehaviorConf = fishingData.fishingBehaviorConf;
|
||||
await Awaiters.Seconds(fishingBehaviorConf.timeEatStartScale);
|
||||
float time = fishingBehaviorConf.timeEatEndScale - fishingBehaviorConf.timeEatStartScale;
|
||||
DOTween.To(() => fishingBehaviorConf.timeEatMinScale, x => Time.timeScale = x, 1, time)
|
||||
.SetEase(fishingBehaviorConf.timeEatScaleCurve);
|
||||
await Awaiters.Seconds(fishingBehaviorConf.timeEatEndScale);
|
||||
Time.timeScale = 1f;
|
||||
}
|
||||
void EatFishAction()
|
||||
{
|
||||
fishingBehavior.FishSwimBehaviour.gameObject.SetActive(false);
|
||||
fishingBehavior.fx_fishbosscome.SetActive(false);
|
||||
//await Awaiters.Seconds(eatFishActionDelay);
|
||||
//大鱼停止游弋
|
||||
fishingBehavior.fishCome.FishComeStop();
|
||||
var _strugglePoint = fishSpEatPoint;
|
||||
//_strugglePoint.y = _fish.transform.position.y;
|
||||
fishingBehavior.fishCome.transform.localPosition = _strugglePoint;
|
||||
fishingBehavior.FishSwimBehaviour.gameObject.SetActive(true);
|
||||
fishingBehavior.fishCome.animator.Play("FishBossPullingBiteSp");
|
||||
fishingBehavior.FishSwimBehaviour.PlayBite();
|
||||
fishingBehavior.cameraAnimator.Play("CameraAnimationWhaleSp");
|
||||
}
|
||||
|
||||
void FishSwimming()
|
||||
{
|
||||
var ver = new Vector3();
|
||||
ver.y = fishingBehavior.GetFishUnderwaterOffset();
|
||||
ver.z = fishingBehavior.WaitingZ();
|
||||
fishingBehavior.GetFish.transform.position = fishingBehavior.FishComeAnimationRoot.transform.position;
|
||||
var _strugglePoint = new Vector3(0, ver.y, ver.z);
|
||||
//fishingBehavior.GetBait.transform.position = ver;
|
||||
fishingBehavior.GetFish.transform.DOMove(_strugglePoint, fishSpSwimmingToMapTime).OnUpdate(
|
||||
(() =>
|
||||
{
|
||||
fishingBehavior.SetCurFishEffectPos();
|
||||
}));
|
||||
fishingBehavior.FishTurn();
|
||||
}
|
||||
void DarknessTimeDelay()
|
||||
{
|
||||
//天气压黑
|
||||
var _fishEatfish = GContext.container.Resolve<Tables>().TbFishEatFish.GetOrDefault(fishingData.swimFishData.EatFishID);
|
||||
if (_fishEatfish != null)
|
||||
{
|
||||
if (_fishEatfish.IsDarkness)
|
||||
{
|
||||
WeatherEvent weatherEvent = new WeatherEvent() { State = 1 };
|
||||
GContext.Publish(weatherEvent);
|
||||
fishingData.isWeather = true;
|
||||
if (weatherEvent.IsPlay)
|
||||
{
|
||||
GContext.Publish(new EventBGMSound("BGM_WeatherChange"));
|
||||
}
|
||||
}
|
||||
FishingPanel_Advanced.Instance?.ShowWarning(_fishEatfish.WarningAfterEat);
|
||||
}
|
||||
}
|
||||
async void AniExitTime()
|
||||
{
|
||||
await Awaiters.Seconds(spExitDelay);
|
||||
fishingBehavior.StartMoveFish();
|
||||
fishingBehavior.cameraAnimator.Play("Drawing01");
|
||||
fishingBehavior.fishCome.animator.Play("Idle01");
|
||||
GContext.Publish(new OnEatEndEvent());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a0639b793c76594e80ea693ff7d73a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Assets/Scripts/GampPlay/FishingB/IFishingState.cs
Normal file
22
Assets/Scripts/GampPlay/FishingB/IFishingState.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
public enum FishingStateName
|
||||
{
|
||||
Idle,
|
||||
Move,
|
||||
Jump,
|
||||
UIEating,
|
||||
SpEating,
|
||||
MaxCombo,
|
||||
Escape
|
||||
}
|
||||
public interface IFishingState
|
||||
{
|
||||
public FishingStateName fishingState { get; }
|
||||
FishingBehaviorB fishingBehavior { get; set; }
|
||||
float fishMoveSpeed { get; set; }
|
||||
void InState(FishingBehaviorB fishingBehavior, FishingData fishingData);
|
||||
void UpdateState();
|
||||
void OutState();
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/FishingB/IFishingState.cs.meta
Normal file
11
Assets/Scripts/GampPlay/FishingB/IFishingState.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9aaf29a45125e364c98a30fe2dffd8c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ParabolaHarmonicSimulation
|
||||
{
|
||||
public float allTime = 0;
|
||||
public float starTime = 0;
|
||||
public float curTime = 0;
|
||||
public Vector3 startPos = Vector3.zero;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f59617c719f201d4eb02975a4003e94f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
78
Assets/Scripts/GampPlay/FishingB/Weather.cs
Normal file
78
Assets/Scripts/GampPlay/FishingB/Weather.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using asap.core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UniRx;
|
||||
public class WeatherEvent
|
||||
{
|
||||
public int State;
|
||||
public bool IsPlay;
|
||||
}
|
||||
public class Weather : MonoBehaviour
|
||||
{
|
||||
public PlayableDirector director;
|
||||
IDisposable disposable;
|
||||
private void Start()
|
||||
{
|
||||
director = GetComponent<PlayableDirector>();
|
||||
if (director != null)
|
||||
{
|
||||
director.playOnAwake = false;
|
||||
director.extrapolationMode = DirectorWrapMode.Hold;
|
||||
director.Stop();
|
||||
director.initialTime = 0; // Start at the end of the timeline
|
||||
director.Evaluate();
|
||||
disposable = GContext.OnEvent<WeatherEvent>().Subscribe(OnWeatherEvent);
|
||||
}
|
||||
}
|
||||
void OnWeatherEvent(WeatherEvent e)
|
||||
{
|
||||
e.IsPlay = true;
|
||||
StopAllCoroutines();
|
||||
if (e.State == 1)
|
||||
{
|
||||
//timeline正着播
|
||||
director.initialTime = 0; // Start at the end of the timeline
|
||||
director.Evaluate();
|
||||
director.playableGraph.GetRootPlayable(0).SetSpeed(1); // Set playback speed to forward
|
||||
director.Play();
|
||||
}
|
||||
else if (e.State == 2)
|
||||
{
|
||||
if (director.time > director.duration / 3)
|
||||
{
|
||||
//director.Evaluate();
|
||||
//director.playableGraph.GetRootPlayable(0).SetSpeed(-1); // Set playback speed to reverse
|
||||
//director.Play();
|
||||
StartCoroutine(PlayBackwards());
|
||||
}
|
||||
else
|
||||
{
|
||||
director.initialTime = 0; // Start at the end of the timeline
|
||||
director.Evaluate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
director.initialTime = 0;
|
||||
}
|
||||
}
|
||||
IEnumerator PlayBackwards()
|
||||
{
|
||||
// Play the timeline backwards
|
||||
while (director.time > 0)
|
||||
{
|
||||
director.time -= Time.deltaTime;
|
||||
//director.Evaluate();
|
||||
yield return null;
|
||||
}
|
||||
director.Stop();
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GampPlay/FishingB/Weather.cs.meta
Normal file
11
Assets/Scripts/GampPlay/FishingB/Weather.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3efec9c3a5ecb940bcae25a7e94cd9b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user