68 lines
2.5 KiB
C#
68 lines
2.5 KiB
C#
using Cal.DataTable;
|
|
using ET.EventType;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ET
|
|
{
|
|
public class AfterChangeMapEvent : AEvent<AfterChangeMap>
|
|
{
|
|
public override async ETTask Run(AfterChangeMap args)
|
|
{
|
|
Unit unit = args.unit;
|
|
int mapId = args.mapId;
|
|
|
|
//竞技场
|
|
PvpMap.inatance.Remove(unit);
|
|
|
|
try
|
|
{
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
//!发送切换地图
|
|
MessageHelper.SendActor(unit, new M2C_ChangeMap() { X = unitScene.Position.x, Y = unitScene.Position.y, MapId = unitScene.MapId });
|
|
UnitSceneType unitSceneType = MapSceneComponent.Instance.GetUnitSceneType(unitScene.MapId / 100);
|
|
await TimerComponent.Instance.WaitAsync(500);
|
|
if (unit.IsTeamLeader)
|
|
{
|
|
Unit monster = MapCoinComponent.instance.GetCoinMonster(mapId);
|
|
if (monster)
|
|
{
|
|
Game.EventSystem.Publish(new ET.EventType.OnCreateUnit
|
|
{
|
|
Actor_UnitId = unit.Id,
|
|
unit = monster,
|
|
pos = monster.GetComponent<UnitScene>().Position,
|
|
configId = (int)monster.GetComponent<ConfigIdComponent>().configId,
|
|
monsterType = MapMonsterType.MapCoin
|
|
}).Coroutine();
|
|
}
|
|
}
|
|
|
|
if (unitSceneType == UnitSceneType.MainStory || unitSceneType == UnitSceneType.Beach)
|
|
{
|
|
MainStoryMap.Instance.Init(unit, unitScene.MapId);
|
|
}
|
|
else if (unitSceneType == UnitSceneType.Trial)
|
|
{
|
|
TrialCopyMap.Instance.InitTrailCopyMap(unit, unitScene.MapId);
|
|
}
|
|
else
|
|
{
|
|
await TimerComponent.Instance.WaitAsync(500);
|
|
StartupTransPoint(unit, unitScene.MapId);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error(e);
|
|
}
|
|
|
|
static void StartupTransPoint(Unit unit, int mapId)
|
|
{
|
|
MessageHelper.SendActor(unit, new M2C_StartupTransPoint() { MapId = mapId });
|
|
}
|
|
await ETTask.CompletedTask;
|
|
}
|
|
}
|
|
}
|