131 lines
4.3 KiB
C#
131 lines
4.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using ET;
|
|
using Cal.DataTable;
|
|
using UnityEngine;
|
|
|
|
namespace ET
|
|
{
|
|
|
|
public class UnitySceneComponentAwakeSystem : AwakeSystem<UnitySceneComponent>
|
|
{
|
|
public override void Awake(UnitySceneComponent self)
|
|
{
|
|
self.Awake();
|
|
|
|
self.AddComponent<MainStoryMonsterTeamComponent>();
|
|
self.AddComponent<TrialCopyMonsterTeamComponent>();
|
|
self.AddComponent<BattleComponent>();
|
|
self.AddComponent<BossComponent>();
|
|
}
|
|
}
|
|
|
|
|
|
public class UnitySceneComponentDestroySystem : DestroySystem<UnitySceneComponent>
|
|
{
|
|
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();
|
|
Sys_Scene sysScene = DataTableHelper.Get<Sys_Scene>(sceneId);
|
|
if (sysScene.TransPosArr == null)
|
|
return;
|
|
if (sceneId != Sys_SceneId.Scene_MainCity)
|
|
{
|
|
//非主城情况
|
|
for (int i = 0; i < sysScene.TransPosArr.Length; i++)
|
|
{
|
|
Sys_Scene.TransPos transPos = sysScene.TransPosArr[i];
|
|
Sys_Scene.TargetMap 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++)
|
|
{
|
|
Sys_Scene.TransPos 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();
|
|
|
|
Sys_Scene sysScene = DataTableHelper.Get<Sys_Scene>(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()
|
|
{
|
|
|
|
}
|
|
}
|
|
} |