修复老鼠转向问题

This commit is contained in:
huyulong 2024-11-15 23:57:06 +08:00
parent 09cf4ae9e3
commit 13a403c7f8
2 changed files with 4639 additions and 62 deletions

File diff suppressed because it is too large Load Diff

View File

@ -77,8 +77,10 @@ public class roomcontroller : MonoBehaviour
private void Start()
{
FishPrice = 10;
}
async void addman(int type, int number)
{
@ -203,12 +205,29 @@ public class roomcontroller : MonoBehaviour
dig();
}
async void dig()
void dig()
{
//动作变化,捕鱼
fishManShipContorl.SetAni(2);
//RangNumber();
StartCoroutine(movetoStatrPos());
}
IEnumerator movetoStatrPos()
{
yield return new WaitForSeconds(3);
Debug.Log("朝向左边");
fishMan.transform.rotation = Quaternion.Euler(0, 180, 0);
fishManShipContorl.SetAni(1);
Vector3[] ve = { endPos.position, startPos.position };
// 使用 DOPath 沿着路径移动到捕鱼点,并禁用旋转变化
yield return fishMan.transform.DOPath(ve, pathsNeedTimer, PathType.CatmullRom)
.SetOptions(false) // 禁用旋转
.SetEase(Ease.InOutSine)
.WaitForCompletion();
fishManShipContorl.SetAni(0);
yield return new WaitForSeconds(3);
MoveToFishingPos();
}
@ -230,63 +249,6 @@ public class roomcontroller : MonoBehaviour
}
// 随机生成状态
void RangNumber()
{
// 计算概率总和并进行归一化
float totalProbability = probabilityOfStand + probabilityOfWalk + probabilityOfDig;
if (totalProbability != 1f)
{
probabilityOfStand /= totalProbability;
probabilityOfWalk /= totalProbability;
probabilityOfDig /= totalProbability;
}
// 根据概率范围随机生成状态
float randomValue = Random.value;
if (randomValue < probabilityOfStand)
{
fishManShipContorl.SetAni(0);
RangNumber();
}
else if (randomValue < probabilityOfStand + probabilityOfWalk)
{
fishManShipContorl.SetAni(1);
StartCoroutine(movego());
RangNumber();
}
else
{
StartCoroutine(workgo());
RangNumber();
}
}
IEnumerator movego()
{
float x = Random.Range(startPos.position.x,endPos.position.x);
Vector3 newV = new Vector3(x,fishMan.transform.position.y, fishMan.transform.position.z);
ChangeShipLook(fishMan.transform.position, newV);
fishMan.transform.DOMove(newV,3f);
yield return new WaitForSeconds(3f);
}
IEnumerator workgo()
{
if ((fishMan.transform.position.x - endPos.position.x) < 0.01f)
{
fishManShipContorl.SetAni(2);
yield return new WaitForSeconds(3f);
}
else
{
fishMan.transform.DOMove(endPos.position, 3f);
yield return new WaitForSeconds(3f);
fishManShipContorl.SetAni(2);
}
}
//更新精灵数量显示
public void UpdateShipNumberTextPro(string str)