using System; using System.Collections; using System.Collections.Generic; using ET; using UnityEngine; namespace ET { public class TransPointComponentAwakeSystem : AwakeSystem { public override void Awake(TransPointComponent self) { self.Awake(); } } public class TransPointComponentDestroySystem : DestroySystem { public override void Destroy(TransPointComponent self) { self.Destroy(); } } public class TransPointComponent : Entity { public HashSet hash; public void Awake() { hash = new HashSet(); } public async ETTask Create(Scene zoneScene, int targetSceneId, int targetMaplayer, Vector2 pos) { long id = IdGenerater.Instance.GenerateId(); Unit unit = await UnitFactory.CreateTransPoint(zoneScene, id); unit.Position = new Vector3(pos.x, pos.y, 99); unit.AddComponent(targetSceneId, targetMaplayer); hash.Add(unit); } public async ETTask OnEnterTransPoint(Scene zoneScene, Collider2D collider, long Id) { if (collider.CompareTag("Player")) { if (!(collider.gameObject.GetComponent().Component is UnitView unitView) || !(unitView.Parent is Unit unit) || unit.Id != GlobalVariable.MyId || !unit.IsLeader) return; unit = UnitComponent.MyUnit; switch (unit.state) { case Unit.State.Idle: break; case Unit.State.Move: MoveComponent moveComponent = unit.GetComponent(); moveComponent.Stop(); unit.state = Unit.State.Trans; break; case Unit.State.Battle: return; case Unit.State.Trans: return; } foreach (Unit item in hash) { if (item.GetComponent().Id == Id) { await item.GetComponent().OnEnter(zoneScene, collider); } } } } public void RemoveAll() { foreach (Unit unit in hash) { UnitComponent.Instance.Remove(unit); } hash.Clear(); } public void Destroy() { RemoveAll(); hash = null; } } }