using System.Collections.Generic; using System.Threading; using Cysharp.Threading.Tasks; using Game.Pathfinding; using Game.Player; using Game.Room; using UnityEngine; namespace Game.Boss; public interface IBoss { string name { get; } GameObject self { get; } BossData data { get; } BossInfo info { get; } IRoom room { get; } bool isMoving { get; } void SetGameObject(GameObject gameObject, IRoom room); UniTask WaitMoveRoomAndKillAsync(CancellationToken token); // UniTask MoveAsync(List wayPoint, CancellationToken token); void Init(); void Dispose(); } public class BossData { } public class Boss : IBoss { private string _name; private GameObject _self; private IRoom _room; private bool _isMoving; private BossInfo _info; public string name => this._name; public GameObject self => this._self; public BossData data { get; } public BossInfo info => this._info; public IRoom room => this._room; public bool isMoving => this._isMoving; public void SetGameObject(GameObject gameObject, IRoom room) { this._self = gameObject; this._name = room.roomName; this._room = room; this._info = gameObject.GetComponent(); this._isMoving = true; } public async UniTask WaitMoveRoomAndKillAsync(CancellationToken token) { var wayPoints = Game.bfsManager.FindPath(_room.roomInfo.room_Center); await this.MoveAsync(wayPoints, token); Debug.Log("Move finish !!!"); var f = await this.Kill(token); return f; } private async UniTask MoveAsync(List wayPoint, CancellationToken token) { if (!this._isMoving) return false; _isMoving = false; // var endPos = this._room.roomInfo.GetJoinPosition(); // await this._info.MoveAsync(wayPoint, endPos, token); await this._info.MoveAsync(wayPoint, token); this._isMoving = true; return true; } private async UniTask Kill(CancellationToken token) { await this._info.Kill(token); var jinbei = this._room.ClearAll(); return jinbei; } public virtual void Init() { } public virtual void Dispose() { this._info.Dispose(); } }