2021-04-08 20:09:59 +08:00
|
|
|
|
using Cal.DataTable;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public class MainStoryMapAwakeSystem : AwakeSystem<MainStoryMap>
|
|
|
|
|
{
|
|
|
|
|
public override void Awake(MainStoryMap self)
|
|
|
|
|
{
|
|
|
|
|
MainStoryMap.Instance = self;
|
|
|
|
|
self.Awake();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class MainStoryMapLoadSystem : LoadSystem<MainStoryMap>
|
|
|
|
|
{
|
|
|
|
|
public override void Load(MainStoryMap self)
|
|
|
|
|
{
|
|
|
|
|
self.Load();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class MainStoryMapSystem
|
|
|
|
|
{
|
|
|
|
|
public static void Awake(this MainStoryMap self)
|
|
|
|
|
{
|
|
|
|
|
self.Load();
|
|
|
|
|
}
|
|
|
|
|
public static void Load(this MainStoryMap self)
|
|
|
|
|
{
|
|
|
|
|
self.MainStoryDataDic.Clear();
|
2021-04-11 19:50:39 +08:00
|
|
|
|
IEnumerable<MainStory> list = DataTableHelper.GetAll<MainStory>();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
foreach (MainStory item in list)
|
|
|
|
|
{
|
|
|
|
|
self.MainStoryDataDic.Add(item.SceneId * 100 + item.Layer, item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static MainStory GetMainStoryData(this MainStoryMap self, int mapId)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
self.MainStoryDataDic.TryGetValue(mapId, out MainStory mainStory);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
return mainStory;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化主线场景信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="self"></param>
|
|
|
|
|
/// <param name="unit"></param>
|
|
|
|
|
/// <param name="sceneId"></param>
|
|
|
|
|
/// <param name="mapLayer"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static void Init(this MainStoryMap self, Unit unit, int mapId)
|
|
|
|
|
{
|
|
|
|
|
MainStory mainStory = self.GetMainStoryData(mapId);
|
|
|
|
|
if (mainStory == null) {
|
|
|
|
|
Log.Error(" mainStory == null");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageHelper.SendActor(unit, new M2C_InitMainStoryMap() { MainStoryId = (int)mainStory.Id });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化主线玩家交互信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="self"></param>
|
|
|
|
|
/// <param name="leaderId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static MainStoryInteractive InitBattleInteractiveInfo(this MainStoryMap self, long leaderId)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
MainStoryInteractive info = self.GetBattleInteractiveInfo(leaderId);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (info == null)
|
|
|
|
|
{
|
|
|
|
|
info = EntityFactory.CreateWithParent<MainStoryInteractive>(self);
|
|
|
|
|
}
|
|
|
|
|
self.MainStoryInteractiveInfoDic[leaderId] = info;
|
|
|
|
|
return info;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取主线交互信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="self"></param>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static MainStoryInteractive GetBattleInteractiveInfo(this MainStoryMap self, long id)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
self.MainStoryInteractiveInfoDic.TryGetValue(id, out MainStoryInteractive info);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
public static void UpdateBattleInteractiveInfo(this MainStoryMap self, long oldId, long id)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if (self.MainStoryInteractiveInfoDic.TryGetValue(oldId, out MainStoryInteractive info))
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
self.MainStoryInteractiveInfoDic.Remove(oldId);
|
|
|
|
|
self.MainStoryInteractiveInfoDic.Add(id, info);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"没有此交互信息id ={oldId}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static void RemoveBattleInteractiveInfo(this MainStoryMap self, long id)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if(self.MainStoryInteractiveInfoDic.TryGetValue(id, out MainStoryInteractive info))
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
info.Dispose();
|
|
|
|
|
}
|
|
|
|
|
if (!self.MainStoryInteractiveInfoDic.Remove(id))
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"没有此交互信息id ={id}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|