CTT/Unity/Assets/HotfixView/Entity/TransPoint.cs

89 lines
2.6 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Cal.DataTable;
using ET;
using UnityEngine;
namespace ET
{
public class TransPointAwakeSystem : AwakeSystem<TransPoint, int, int>
{
public override void Awake(TransPoint self, int a, int b)
{
self.Awake(a, b);
}
}
public class TransPointDestroySystem : DestroySystem<TransPoint>
{
public override void Destroy(TransPoint self)
{
self.Destroy();
}
}
public class TransPoint : Entity
{
private int transIndex;
private int currSceneId;
public void Awake(int transIndex, int currSceneId)
{
this.transIndex = transIndex;
this.currSceneId = currSceneId;
}
public async ETTask OnEnter(Scene zoneScene, Collider2D collider)
{
int targetSceneId = 0;
int targetLayer = 1;
UnitSceneType unitSceneType = MapHelper.GetMapType(this.currSceneId);
if (this.currSceneId == Sys_SceneId.Scene_MainCity)
{
if (this.transIndex == 0)
{
Game.EventSystem.Publish(new ET.EventType.TransPointUI_Right_Open
{
zoneScene = zoneScene
}).Coroutine();
return;
}
else if (this.transIndex == 1)
{
Game.EventSystem.Publish(new ET.EventType.TransPointUI_Left_Open
{
zoneScene = zoneScene
}).Coroutine();
return;
}
return;
}
else if(unitSceneType == UnitSceneType.Beach || unitSceneType== UnitSceneType.MainStory)
{
targetSceneId = currSceneId;
targetLayer= zoneScene.GetComponent<GlobalVariable>().MapId % 100+1 ;
}
else
{
targetSceneId = Sys_SceneId.Scene_MainCity;
}
M2C_RequestEnterMap m2C_RequestEnterMap = await zoneScene.GetComponent<SessionComponent>().Call<M2C_RequestEnterMap>(new C2M_RequestEnterMap() { MapId = targetSceneId * 100 +targetLayer });
if (!m2C_RequestEnterMap.Message.IsNullOrEmpty())
{
TipHelper.OpenUI(m2C_RequestEnterMap.Message);
}
}
public void Destroy()
{
this.transIndex = 0;
this.currSceneId = 0;
}
}
}