You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
3 years ago
|
namespace ET
|
||
|
{
|
||
|
public class PeopleAIComponentAwakeSystem: AwakeSystem<PeopleAIComponent>
|
||
|
{
|
||
|
public override void Awake(PeopleAIComponent self)
|
||
|
{
|
||
|
self.Awake();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[FriendClass(typeof(PeopleViewComponent))]
|
||
|
[FriendClass(typeof(People))]
|
||
|
public static class PeopleAIComponentSystem
|
||
|
{
|
||
|
public static void Awake(this PeopleAIComponent self)
|
||
|
{
|
||
|
self.RunAI().Coroutine();
|
||
|
}
|
||
|
|
||
|
public static async ETTask RunAI(this PeopleAIComponent self)
|
||
|
{
|
||
|
while (true)
|
||
|
{
|
||
|
// 检测时间
|
||
|
await TimerComponent.Instance.WaitAsync(1000);
|
||
|
|
||
|
var peopleViewComp = self.Parent.GetComponent<PeopleViewComponent>();
|
||
|
if (peopleViewComp.People.GetBehaveType() == ConstBehaveType.BEHAVE_IDLE)
|
||
|
{
|
||
|
var radius = RandomHelper.RandomNumber(5, 10);
|
||
|
peopleViewComp.MoveToPos(PeopleViewHelper.GetRandomMovePos(peopleViewComp, radius));
|
||
|
|
||
|
|
||
|
var moveTime = RandomHelper.RandomNumber(10000,30000);
|
||
|
await TimerComponent.Instance.WaitAsync(moveTime);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|