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.AddComponent(); self.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(); var sysScene = DataTableHelper.Get(sceneId); if (sysScene.TransPosArr == null) return; if (sceneId != Sys_SceneId.Scene_MainCity) { //非主城情况 for (int i = 0; i < sysScene.TransPosArr.Length; i++) { var transPos = sysScene.TransPosArr[i]; var tagetMap = sysScene.TargetMapArr[i]; int targetsceneId = tagetMap.TargetMap_Id; int targetMaplyar = 1; if (sysScene.Layers >= mapLayer + 1) { targetsceneId = sceneId; targetMaplyar = mapLayer + 1; } if (sceneId == Sys_SceneId.Scene_Boss) { targetsceneId = Sys_SceneId.Scene_MainCity; targetMaplyar = 1; } Game.EventSystem.Publish(new ET.EventType.CreateTransPoint { zoneScene = zoneScene, targetSceneId = targetsceneId, targetMaplayer = targetMaplyar, pos = new Vector2(transPos.TransPos_x, transPos.TransPos_y), }).Coroutine(); } } else { for (int i = 0; i < sysScene.TransPosArr.Length; i++) { var transPos = sysScene.TransPosArr[i]; int targetMaplyar = 1; if (sysScene.Layers >= mapLayer + 1) { targetMaplyar = mapLayer + 1; } Game.EventSystem.Publish(new ET.EventType.CreateTransPoint { zoneScene = zoneScene, targetSceneId = i, targetMaplayer = targetMaplyar, 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(); var sysScene = DataTableHelper.Get(sceneId); UnitComponent.MyUnit = UnitComponent.MyUnit ?? (UnitComponent.Instance.Get(GlobalVariable.MyId)); UnitComponent.MyUnit.Position = new Vector3(pos.x, pos.y, PosHelper.PlayerPos_Z); UnitComponent.MyUnit.YAngle = (int)pos.z; await Game.EventSystem.Publish(new ET.EventType.LoadUnityScene { zoneScene=zoneScene, name = sysScene.Name, id = (int)sysScene.Id }); } public void Destroy() { } } }