2021-04-08 20:09:59 +08:00
|
|
|
|
using Cal.DataTable;
|
|
|
|
|
using ET.EventType;
|
|
|
|
|
using ET;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
public class ChangeMapEvent : AEvent<ChangeMap>
|
|
|
|
|
{
|
|
|
|
|
public override async ETTask Run(ChangeMap args)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int sceneId = args.mapId / 100;
|
|
|
|
|
int mapLayer = args.mapId % 100;
|
|
|
|
|
Vector3 pos = args.pos;
|
2021-04-20 00:25:04 +08:00
|
|
|
|
var zoneScene = args.zoneScene;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.TranslateSceneStart
|
|
|
|
|
{
|
|
|
|
|
isAutoEnd = false
|
|
|
|
|
});
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//相机
|
2021-05-01 11:27:41 +08:00
|
|
|
|
Sys_Scene cameraPosition = Sys_SceneCategory.Instance.Get(sceneId);
|
2021-04-20 00:25:04 +08:00
|
|
|
|
Unit unit = zoneScene.GetComponent<UnitComponent>().MyUnit;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
CameraComponent cameraComponent = unit.GetComponent<CameraComponent>();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
cameraComponent.ChangeRange(cameraPosition);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await UnitySceneComponent.Instance.LoadSceneAsync(args.zoneScene, sceneId, pos);
|
|
|
|
|
await TimerComponent.Instance.WaitAsync(500);
|
|
|
|
|
//关闭所有UI
|
|
|
|
|
FUIHelper.CloseAllWindows();
|
|
|
|
|
//地图名字
|
|
|
|
|
if ((FUIComponent.Instance.Get(FUIPackage.Common_MainUI) is FUI_MainUI mainUi))
|
|
|
|
|
{
|
|
|
|
|
Sys_Scene sys_Scene = DataTableHelper.Get<Sys_Scene>(sceneId);
|
|
|
|
|
if (sys_Scene == null)
|
|
|
|
|
throw new Exception($"sysScene == null where Id = {sceneId}");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mainUi.m_txtMapName.text = $"{sys_Scene.Desc}{(sys_Scene.Layers > 1 ? $"——{mapLayer}层" : "")}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//清空玩家列表
|
|
|
|
|
MainUI.ClearUnitList();
|
2021-04-20 00:25:04 +08:00
|
|
|
|
foreach (Unit u in zoneScene.GetComponent<UnitComponent>().GetAll())
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
switch (u.UnitType)
|
|
|
|
|
{
|
|
|
|
|
case UnitType.None:
|
|
|
|
|
break;
|
|
|
|
|
case UnitType.Player:
|
|
|
|
|
case UnitType.OtherPlayer:
|
|
|
|
|
case UnitType.TeamMember:
|
|
|
|
|
ClientUnitCharacter clientUnitCharacter = ClientUnitCharacterComponent.Instance.Get(u.Id);
|
|
|
|
|
MainUI.AddUnit(clientUnitCharacter.Id, clientUnitCharacter.Job, clientUnitCharacter.NickName);
|
|
|
|
|
break;
|
2021-05-05 13:36:19 +08:00
|
|
|
|
case UnitType.Monster:
|
2021-04-08 20:09:59 +08:00
|
|
|
|
case UnitType.Enermy:
|
|
|
|
|
break;
|
|
|
|
|
case UnitType.NPC:
|
|
|
|
|
NPCBase nPCBase = NPCBaseCategory.Instance.Get(u.ConfigId);
|
|
|
|
|
MainUI.AddUnit(u.Id, "NPC", nPCBase.Name);
|
|
|
|
|
break;
|
|
|
|
|
case UnitType.MapMonster:
|
|
|
|
|
break;
|
|
|
|
|
case UnitType.TransPoint:
|
|
|
|
|
MainUI.AddUnit(u.Id, "传送门", "");
|
|
|
|
|
break;
|
|
|
|
|
case UnitType.SceneUnit:
|
|
|
|
|
MainUI.AddUnit(u.Id, "交互", "");
|
|
|
|
|
break;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.TranslateSceneEnd
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|