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

89 lines
2.6 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
2021-05-01 11:27:41 +08:00
using Cal.DataTable;
2021-04-08 20:09:59 +08:00
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
{
2021-05-01 11:27:41 +08:00
private int transIndex;
private int currSceneId;
2021-04-08 20:09:59 +08:00
2021-05-01 11:27:41 +08:00
public void Awake(int transIndex, int currSceneId)
2021-04-08 20:09:59 +08:00
{
2021-05-01 11:27:41 +08:00
this.transIndex = transIndex;
this.currSceneId = currSceneId;
2021-04-08 20:09:59 +08:00
}
public async ETTask OnEnter(Scene zoneScene, Collider2D collider)
{
2021-05-01 11:27:41 +08:00
int targetSceneId = 0;
int targetLayer = 1;
UnitSceneType unitSceneType = MapHelper.GetMapType(this.currSceneId);
if (this.currSceneId == Sys_SceneId.Scene_MainCity)
2021-04-08 20:09:59 +08:00
{
2021-05-01 11:27:41 +08:00
if (this.transIndex == 0)
2021-04-08 20:09:59 +08:00
{
2021-05-01 11:27:41 +08:00
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;
}
2021-04-08 20:09:59 +08:00
return;
}
2021-05-01 11:27:41 +08:00
else if(unitSceneType == UnitSceneType.Beach || unitSceneType== UnitSceneType.MainStory)
2021-04-08 20:09:59 +08:00
{
2021-05-01 11:27:41 +08:00
targetSceneId = currSceneId;
targetLayer= zoneScene.GetComponent<GlobalVariable>().MapId % 100+1 ;
}
else
{
targetSceneId = Sys_SceneId.Scene_MainCity;
2021-04-08 20:09:59 +08:00
}
2021-05-01 11:27:41 +08:00
M2C_RequestEnterMap m2C_RequestEnterMap = await zoneScene.GetComponent<SessionComponent>().Call<M2C_RequestEnterMap>(new C2M_RequestEnterMap() { MapId = targetSceneId * 100 +targetLayer });
2021-04-08 20:09:59 +08:00
if (!m2C_RequestEnterMap.Message.IsNullOrEmpty())
{
TipHelper.OpenUI(m2C_RequestEnterMap.Message);
}
}
public void Destroy()
{
2021-05-01 11:27:41 +08:00
this.transIndex = 0;
this.currSceneId = 0;
2021-04-08 20:09:59 +08:00
}
}
}