Files
MinFt/Client/Assets/Scripts/GampPlay/Fishing/HandPosController.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

98 lines
2.3 KiB
C#

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;
}
}