149 lines
5.1 KiB
C#
Executable File
149 lines
5.1 KiB
C#
Executable File
using Cal.DataTable;
|
|
using ET.EventType;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace ET
|
|
{
|
|
public class MapSceneComponentAwakeSystem: AwakeSystem<MapSceneComponent>
|
|
{
|
|
public override void Awake(MapSceneComponent self)
|
|
{
|
|
MapSceneComponent.Instance = self;
|
|
self.Load();
|
|
|
|
self.AddComponent<BattleEventComponent>();
|
|
self.AddComponent<BattleMgrCompnent>();
|
|
self.AddComponent<MainStoryMap>();
|
|
self.AddComponent<TrialCopyMap>();
|
|
self.AddComponent<BossComponent>();
|
|
self.AddComponent<BattleIdleMap>();
|
|
self.AddComponent<PvpMap>();
|
|
self.AddComponent<ManulEquipMap>();
|
|
self.AddComponent<MapCoinComponent>();
|
|
}
|
|
}
|
|
|
|
public static class MapSceneComponentSystem
|
|
{
|
|
class CheckPerMinute: AEvent<ET.EventType.UpdatePer1MinuteOfDay>
|
|
{
|
|
public override async ETTask Run(UpdatePer1MinuteOfDay args)
|
|
{
|
|
foreach (MapScene map in MapSceneComponent.Instance.GetAllMap())
|
|
{
|
|
try
|
|
{
|
|
foreach (Tier tier in map.tierDic.Values)
|
|
{
|
|
try
|
|
{
|
|
using ListComponent<long> listComponent = ListComponent<long>.Create();
|
|
listComponent.List.AddRange(tier.unitDic.Keys);
|
|
foreach (long id in listComponent.List)
|
|
{
|
|
if (!tier.Get(id))
|
|
{
|
|
Log.Error($"unitId:{id}");
|
|
tier.Remove(id);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error(e);
|
|
}
|
|
}
|
|
|
|
if (AppConfig.inst.isTest)
|
|
{
|
|
if (map.GetAll().ToArray().Length != 0)
|
|
{
|
|
Log.Info($"{map.GetAll().ToCustomString()}");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error(e);
|
|
}
|
|
}
|
|
|
|
await ETTask.CompletedTask;
|
|
}
|
|
}
|
|
|
|
public static void Load(this MapSceneComponent self)
|
|
{
|
|
foreach (KeyValuePair<int, MapScene> item in self.m_MapSceneDic)
|
|
{
|
|
item.Value.Dispose();
|
|
}
|
|
|
|
self.m_MapSceneDic.Clear();
|
|
IEnumerable<Sys_Scene> list = DataTableHelper.GetAll<Sys_Scene>();
|
|
foreach (Sys_Scene item in list)
|
|
{
|
|
for (int i = 0; i < item.Layers; i++)
|
|
{
|
|
MapScene map = EntityFactory.CreateWithParent<MapScene>(self);
|
|
int id = (int) (item.Id * 100 + i + 1);
|
|
self.m_MapSceneDic.Add(id, map);
|
|
map.mapId = id;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static Sys_Scene GetMapInfo(this MapSceneComponent self, int id)
|
|
{
|
|
Sys_Scene sys_Scene = Sys_SceneCategory.Instance.Get(id);
|
|
return sys_Scene;
|
|
}
|
|
|
|
public static IEnumerable<MapScene> GetAllMap(this MapSceneComponent self)
|
|
{
|
|
return self.m_MapSceneDic.Values;
|
|
}
|
|
|
|
public static IEnumerable<int> GetAllMapId(this MapSceneComponent self)
|
|
{
|
|
return self.m_MapSceneDic.Keys;
|
|
}
|
|
|
|
public static MapScene GetMap(this MapSceneComponent self, int mapId)
|
|
{
|
|
self.m_MapSceneDic.TryGetValue(mapId, out MapScene map);
|
|
return map;
|
|
}
|
|
|
|
public static MapScene GetMap(this MapSceneComponent self, Unit unit)
|
|
{
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
return self.GetMap(unitScene.MapId);
|
|
}
|
|
|
|
public static async ETTask ChangeMap(this MapSceneComponent self, UnitScene unitScene, int mapId)
|
|
{
|
|
Unit unit = unitScene.GetParent<Unit>();
|
|
MapScene mapScene = MapSceneComponent.Instance.GetMap(unitScene.MapId) ??
|
|
MapSceneComponent.Instance.GetMap(Sys_SceneId.Scene_MainCity * 100 + 1);
|
|
mapScene.Leave(unit);
|
|
unitScene.MapId = mapId;
|
|
mapScene = MapSceneComponent.Instance.GetMap(unitScene.MapId) ?? MapSceneComponent.Instance.GetMap(Sys_SceneId.Scene_MainCity * 100 + 1);
|
|
await mapScene.Enter(unit);
|
|
}
|
|
|
|
public static void RemoveUnit(this MapSceneComponent self, Unit unit)
|
|
{
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
if (unitScene)
|
|
{
|
|
MapScene map = self.GetMap(unitScene.MapId);
|
|
map?.Leave(unit, true);
|
|
}
|
|
}
|
|
|
|
}
|
|
} |