Files
aibis-dream/Assets/Scripts/AnimationManage/MoveableVehicle.cs
T
2025-03-10 20:06:32 +08:00

41 lines
777 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveableVehicle : MovableObject
{
public bool shouldStop;
public float stopTime;
private bool isStopped = false;
protected override void Initialize()
{
shouldStop = Random.value > 0.5f; // 50% 概率停留
stopTime = Random.Range(1f, 3f);
}
protected override void Update()
{
if (!isStopped)
{
Move();
}
}
private IEnumerator StopCoroutine()
{
isStopped = true;
yield return new WaitForSeconds(stopTime);
isStopped = false;
}
public void StopAndWait()
{
if (shouldStop)
{
StartCoroutine(StopCoroutine());
}
}
}