using System; using System.Collections; using System.Collections.Generic; using ET; using Cal.DataTable; using UnityEngine; namespace ET { public class UnitySceneComponentAwakeSystem : AwakeSystem { public override void Awake(UnitySceneComponent self) { self.Awake(); self.ZoneScene().AddComponent(); self.ZoneScene().AddComponent(); self.AddComponent(); self.AddComponent(); } } public class UnitySceneComponentDestroySystem : DestroySystem { public override void Destroy(UnitySceneComponent self) { self.Destroy(); } } public class UnitySceneComponent : Entity { public static UnitySceneComponent Instance { get; private set; } public void Awake() { Instance = this; } public void InitScenePoint(Scene zoneScene, int sceneId, int mapLayer) { Game.EventSystem.Publish(new ET.EventType.RemoveTransPoint { zoneScene = zoneScene }).Coroutine(); SceneTransConfig sceneTransConfig = SceneTransConfigCategory.Instance.Get(sceneId); Sys_Scene sysScene = DataTableHelper.Get(sceneId); if (sceneTransConfig.TransPosArr == null) return; if (sceneId != Sys_SceneId.Scene_MainCity) { //非主城情况 for (int i = 0; i < sceneTransConfig.TransPosArr.Length; i++) { SceneTransConfig.TransPos transPos = sceneTransConfig.TransPosArr[i]; Game.EventSystem.Publish(new ET.EventType.CreateTransPoint { zoneScene = zoneScene, transIndex = i, currSceneId = sceneId, pos = new Vector2(transPos.TransPos_x, transPos.TransPos_y), }).Coroutine(); } } else { for (int i = 0; i < sceneTransConfig.TransPosArr.Length; i++) { SceneTransConfig.TransPos transPos = sceneTransConfig.TransPosArr[i]; Game.EventSystem.Publish(new ET.EventType.CreateTransPoint { zoneScene = zoneScene, transIndex = i, currSceneId = sceneId, pos = new Vector2(transPos.TransPos_x, transPos.TransPos_y), }).Coroutine(); } } } public async ETTask LoadSceneAsync(Scene zoneScene, int sceneId, Vector3 pos) { //关闭主线怪物 BossComponent.Instance.RemoveBoss(); Game.EventSystem.Publish(new ET.EventType.RemoveTransPoint { zoneScene = zoneScene }).Coroutine(); Sys_Scene sysScene = DataTableHelper.Get(sceneId); var unitComponent = zoneScene.GetComponent(); zoneScene.GetComponent().MyUnit ??= (zoneScene.GetComponent().Get(zoneScene.GetComponent().MyId)); zoneScene.GetComponent().MyUnit.Position = new Vector3(pos.x, pos.y, PosHelper.PlayerPos_Z); zoneScene.GetComponent().MyUnit.YAngle = (int) pos.z; await Game.EventSystem.Publish(new ET.EventType.LoadUnityScene { zoneScene = zoneScene, name = sysScene.SceneName, id = (int) sysScene.Id }); } public void Destroy() { } } }