This commit is contained in:
liuliang 2024-11-16 00:22:59 +08:00
commit bad526453c
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() private void Start()
{ {
FishPrice = 10; FishPrice = 10;
} }
async void addman(int type, int number) async void addman(int type, int number)
{ {
@ -203,12 +205,29 @@ public class roomcontroller : MonoBehaviour
dig(); dig();
} }
async void dig() void dig()
{ {
//动作变化,捕鱼 //动作变化,捕鱼
fishManShipContorl.SetAni(2); fishManShipContorl.SetAni(2);
StartCoroutine(movetoStatrPos());
RangNumber(); }
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) public void UpdateShipNumberTextPro(string str)