36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Cal.DataTable;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace ET
|
|
{
|
|
public class BackHomeNode : AINode
|
|
{
|
|
public override bool Check(Unit unit)
|
|
{
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
if (unitScene.MapId / 100 != Sys_SceneId.Scene_MainCity)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
public override async ETVoid Run(Unit unit, ETCancellationToken cancelToken)
|
|
{
|
|
while (true)
|
|
{
|
|
bool ret = await TimerComponent.Instance.WaitAsync(1000, cancelToken);
|
|
if (!ret) return;
|
|
if (AppConfig.inst.isTest)
|
|
Log.Info($"【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】回城");
|
|
Game.EventSystem.Publish(new ET.EventType.BackMainCity
|
|
{
|
|
unit = unit,
|
|
isForce = true
|
|
}).Coroutine();
|
|
unit.GetComponent<AIComponent>().SetData("hasBuyInShop", false);
|
|
}
|
|
}
|
|
}
|
|
}
|