|
|
@@ -23,6 +23,7 @@ public class Yeji : TargetAnimal
|
|
|
|
|
|
void Awake()
|
|
|
{
|
|
|
+ state = new State();
|
|
|
state.animal = this;
|
|
|
animator = GetComponent<Animator>();
|
|
|
agent = GetComponent<NavMeshAgent>();
|
|
|
@@ -203,7 +204,7 @@ public class Yeji : TargetAnimal
|
|
|
}
|
|
|
|
|
|
TreeAreaRecorder.AreaInfo targetAreaInfo;
|
|
|
- bool hasCheckFlyDown = false;
|
|
|
+ bool needCheckFlyDown = false;
|
|
|
void UpdateBehavior() {
|
|
|
if (state.flyStaying) {
|
|
|
canFlyStayTime -= Time.deltaTime;
|
|
|
@@ -224,11 +225,11 @@ public class Yeji : TargetAnimal
|
|
|
if (state.landing) return;
|
|
|
|
|
|
if (state.flying && !state.down && !state.up) {
|
|
|
- if (!hasCheckFlyDown) {
|
|
|
+ if (needCheckFlyDown) {
|
|
|
float downNeedTime = flyPlaneHeight / downSpeed;
|
|
|
float keyDistance = this.agent.speed * downNeedTime; //触发下降的水平距离阈值
|
|
|
if (Vector3.Distance(this.transform.position, this.agent.destination) < keyDistance) {
|
|
|
- hasCheckFlyDown = true;
|
|
|
+ needCheckFlyDown = false;
|
|
|
if (Random.value < 0.6 && tryOccupyTree()) {
|
|
|
state.down = true;
|
|
|
} else {
|
|
|
@@ -253,7 +254,7 @@ public class Yeji : TargetAnimal
|
|
|
Vector3 newPos = YejiHuntGameMode.CalculateNewPosByTreePos(animalsBaseT, flyPlaneHeight, areaInfo);
|
|
|
SetDestination(newPos);
|
|
|
targetAreaInfo = areaInfo;
|
|
|
- hasCheckFlyDown = false;
|
|
|
+ needCheckFlyDown = true;
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
@@ -362,7 +363,7 @@ public class Yeji : TargetAnimal
|
|
|
}
|
|
|
public Yeji animal;
|
|
|
}
|
|
|
- [SerializeField] public State state = new State();
|
|
|
+ [SerializeField] public State state;
|
|
|
|
|
|
//委托
|
|
|
public System.Action<Yeji> onDie;
|