Core/GameEngine/DataToCtl/PackageRegedit.cs
@@ -25,6 +25,7 @@ public static void Init() { // 登记相应的数据体及对应的数据转逻辑类 Register(typeof(HA307_tagMCFairyAdventuresInfo), typeof(DTCA307_tagMCFairyAdventuresInfo)); Register(typeof(HA306_tagMCFairyDomainInfo), typeof(DTCA306_tagMCFairyDomainInfo)); Register(typeof(HB107_tagMCRolePointInfo), typeof(DTCB107_tagMCRolePointInfo)); Register(typeof(HA327_tagMCRealmExpInfo), typeof(DTCA327_tagMCRealmExpInfo)); Core/GameEngine/Model/Config/AdventureDialogueConfig.cs
New file @@ -0,0 +1,219 @@ //-------------------------------------------------------- // [Author]: Fish // [ Date ]: Tuesday, April 09, 2019 //-------------------------------------------------------- using System.Collections.Generic; using System.IO; using System.Threading; using System; using UnityEngine; [XLua.LuaCallCSharp] public partial class AdventureDialogueConfig { public readonly int id; public readonly int type; public readonly int gear; public readonly int npcId; public readonly string[] dialogues; public readonly int[] speakType; public AdventureDialogueConfig() { } public AdventureDialogueConfig(string input) { try { var tables = input.Split('\t'); int.TryParse(tables[0],out id); int.TryParse(tables[1],out type); int.TryParse(tables[2],out gear); int.TryParse(tables[3],out npcId); dialogues = tables[4].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); string[] speakTypeStringArray = tables[5].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); speakType = new int[speakTypeStringArray.Length]; for (int i=0;i<speakTypeStringArray.Length;i++) { int.TryParse(speakTypeStringArray[i],out speakType[i]); } } catch (Exception ex) { DebugEx.Log(ex); } } static Dictionary<string, AdventureDialogueConfig> configs = new Dictionary<string, AdventureDialogueConfig>(); public static AdventureDialogueConfig Get(string id) { if (!inited) { Debug.Log("AdventureDialogueConfig 还未完成初始化。"); return null; } if (configs.ContainsKey(id)) { return configs[id]; } AdventureDialogueConfig config = null; if (rawDatas.ContainsKey(id)) { config = configs[id] = new AdventureDialogueConfig(rawDatas[id]); rawDatas.Remove(id); } return config; } public static AdventureDialogueConfig Get(int id) { return Get(id.ToString()); } public static List<string> GetKeys() { var keys = new List<string>(); keys.AddRange(configs.Keys); keys.AddRange(rawDatas.Keys); return keys; } public static List<AdventureDialogueConfig> GetValues() { var values = new List<AdventureDialogueConfig>(); values.AddRange(configs.Values); var keys = new List<string>(rawDatas.Keys); foreach (var key in keys) { values.Add(Get(key)); } return values; } public static bool Has(string id) { return configs.ContainsKey(id) || rawDatas.ContainsKey(id); } public static bool Has(int id) { return Has(id.ToString()); } public static bool inited { get; private set; } protected static Dictionary<string, string> rawDatas = new Dictionary<string, string>(); public static void Init(bool sync=false) { inited = false; var path = string.Empty; if (AssetSource.refdataFromEditor) { path = ResourcesPath.CONFIG_FODLER +"/AdventureDialogue.txt"; } else { path = AssetVersionUtility.GetAssetFilePath("config/AdventureDialogue.txt"); } var tempConfig = new AdventureDialogueConfig(); var preParse = tempConfig is IConfigPostProcess; if (sync) { var lines = File.ReadAllLines(path); if (!preParse) { rawDatas = new Dictionary<string, string>(lines.Length - 3); } for (int i = 3; i < lines.Length; i++) { try { var line = lines[i]; var index = line.IndexOf("\t"); if (index == -1) { continue; } var id = line.Substring(0, index); if (preParse) { var config = new AdventureDialogueConfig(line); configs[id] = config; (config as IConfigPostProcess).OnConfigParseCompleted(); } else { rawDatas[id] = line; } } catch (System.Exception ex) { Debug.LogError(ex); } } inited = true; } else { ThreadPool.QueueUserWorkItem((object _object) => { var lines = File.ReadAllLines(path); if (!preParse) { rawDatas = new Dictionary<string, string>(lines.Length - 3); } for (int i = 3; i < lines.Length; i++) { try { var line = lines[i]; var index = line.IndexOf("\t"); if (index == -1) { continue; } var id = line.Substring(0, index); if (preParse) { var config = new AdventureDialogueConfig(line); configs[id] = config; (config as IConfigPostProcess).OnConfigParseCompleted(); } else { rawDatas[id] = line; } } catch (System.Exception ex) { Debug.LogError(ex); } } inited = true; }); } } } Core/GameEngine/Model/Config/AdventureDialogueConfig.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 4bb7f23bbb7b6ad42b314de10a7abc1b timeCreated: 1554788345 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Core/GameEngine/Model/TelPartialConfig/PartialAdventureDialogueConfig.cs
New file @@ -0,0 +1,23 @@ using System; using System.Collections.Generic; public partial class AdventureDialogueConfig : IConfigPostProcess { static Dictionary<int, AdventureDialogueConfig> adventureDialogues = new Dictionary<int, AdventureDialogueConfig>(); public void OnConfigParseCompleted() { var key = type * 1000 + gear; adventureDialogues.Add(key, this); } public static AdventureDialogueConfig Get(int type, int gear) { var key = type * 1000 + gear; if (adventureDialogues.ContainsKey(key)) { return adventureDialogues[key]; } return null; } } Core/GameEngine/Model/TelPartialConfig/PartialAdventureDialogueConfig.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 2d9e840934f98914f8271a7229baad8b timeCreated: 1554789684 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Core/NetworkPackage/DTCFile/ServerPack/HA3_Function/DTCA307_tagMCFairyAdventuresInfo.cs
New file @@ -0,0 +1,25 @@ //-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Tuesday, April 09, 2019 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using Snxxz.UI; public class DTCA307_tagMCFairyAdventuresInfo : DtcBasic { public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); var package = vNetPack as HA307_tagMCFairyAdventuresInfo; ModelCenter.Instance.GetModel<HazyRegionModel>().ReceivePackage(package); } } Core/NetworkPackage/DTCFile/ServerPack/HA3_Function/DTCA307_tagMCFairyAdventuresInfo.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 26f2b0ac048588a4ca60fef985c49252 timeCreated: 1554788566 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Core/NetworkPackage/ServerPack/HA3_Function/HA307_tagMCFairyAdventuresInfo.cs
New file @@ -0,0 +1,31 @@ using UnityEngine; using System.Collections; // A3 07 缥缈奇遇信息 #tagMCFairyAdventuresInfo public class HA307_tagMCFairyAdventuresInfo : GameNetPackBasic { public byte Cnt; public tagMCFairyAdventuresData[] InfoList; // 信息 public HA307_tagMCFairyAdventuresInfo () { _cmd = (ushort)0xA307; } public override void ReadFromBytes (byte[] vBytes) { TransBytes (out Cnt, vBytes, NetDataType.BYTE); InfoList = new tagMCFairyAdventuresData[Cnt]; for (int i = 0; i < Cnt; i ++) { InfoList[i] = new tagMCFairyAdventuresData(); TransBytes (out InfoList[i].EventID, vBytes, NetDataType.BYTE); TransBytes (out InfoList[i].Gear, vBytes, NetDataType.BYTE); TransBytes (out InfoList[i].Condition, vBytes, NetDataType.DWORD); } } public struct tagMCFairyAdventuresData { public byte EventID; public byte Gear; //第几档 public uint Condition; //条件 } } Core/NetworkPackage/ServerPack/HA3_Function/HA307_tagMCFairyAdventuresInfo.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 299918965692bc94e99b397fd4d3c61c timeCreated: 1554788525 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: System/Dungeon/DungeonModel.cs
@@ -914,6 +914,13 @@ public void ProcessResult(string _msg) { m_DungeonResult = LitJson.JsonMapper.ToObject<DungeonResult>(_msg); if (AdventureStage.Instance.IsInAdventureStage) { WindowCenter.Instance.Open<DungeonAdventureVictoryWin>(); return; } if (m_DungeonResult.isSweep == 1) { switch (m_DungeonResult.dataMapID) System/HazyRegion/DungeonAdventureVictoryWin.cs
New file @@ -0,0 +1,136 @@ //-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Tuesday, April 09, 2019 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { public class DungeonAdventureVictoryWin : Window { [SerializeField] Transform m_ContainerPoivt; [SerializeField] DemonJarRewardBehaviour[] m_Items; [SerializeField] Button m_Exit; [SerializeField] Text m_ExitTimer; const float totalTime = 5f; float timer = 0f; float clockTimer = 0f; DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } } #region Built-in protected override void BindController() { } protected override void AddListeners() { m_Exit.AddListener(ExitDungeon); } protected override void OnPreOpen() { m_ContainerPoivt.gameObject.SetActive(false); timer = 0f; clockTimer = 0f; } protected override void OnActived() { base.OnActived(); StartCoroutine(Co_DelayDisplay()); } protected override void OnAfterOpen() { } protected override void OnPreClose() { AdventureStage.Instance.Exit(); } protected override void OnAfterClose() { } #endregion protected override void LateUpdate() { clockTimer += Time.deltaTime; if (clockTimer >= 0.5f) { clockTimer = 0f; var seconds = Mathf.CeilToInt(totalTime - timer); DrawExitTimer(seconds); } timer += Time.deltaTime; if (timer >= totalTime) { Close(); } } IEnumerator Co_DelayDisplay() { yield return WaitingForSecondConst.WaitMS500; Display(); } void Display() { m_ContainerPoivt.gameObject.SetActive(true); DisplayExit(); DisplayItems(); } void DisplayExit() { m_Exit.gameObject.SetActive(true); var seconds = Mathf.CeilToInt(totalTime - timer); DrawExitTimer(seconds); } void DrawExitTimer(int seconds) { m_ExitTimer.text = Language.Get("DungeonVictoryWin_Btn_Exit_1", Mathf.Clamp(seconds, 0, int.MaxValue)); } void DisplayItems() { var result = dungeonModel.dungeonResult; for (int i = 0; i < m_Items.Length; i++) { if (result.itemInfo != null && i < result.itemInfo.Length) { var serverItem = result.itemInfo[i]; m_Items[i].gameObject.SetActive(true); m_Items[i].Display(new Item(serverItem.ItemID, serverItem.Count)); } else { m_Items[i].gameObject.SetActive(false); } } } private void ExitDungeon() { Close(); } } } System/HazyRegion/DungeonAdventureVictoryWin.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 116e810bc1fe9954d815c4fd53536e7e timeCreated: 1554791976 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: System/HazyRegion/HazyRegionDialogueWin.cs
New file @@ -0,0 +1,152 @@ //-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Tuesday, April 09, 2019 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { public class HazyRegionDialogueWin : Window { [SerializeField] Button m_Skip; [SerializeField] Button m_EmptyAccepter; [SerializeField] Transform m_ContainerNpc; [SerializeField] RawImage m_RawNpc; [SerializeField] Text m_NpcName; [SerializeField] Text m_NpcDialogue; [SerializeField] Transform m_ContainerPlayer; [SerializeField] RawImage m_RawPlayer; [SerializeField] Text m_PlayerName; [SerializeField] Text m_PlayerDialogue; int dialogueIndex = 0; public static int adventureDialogueId = 0; HazyRegionModel model { get { return ModelCenter.Instance.GetModel<HazyRegionModel>(); } } #region Built-in protected override void BindController() { } protected override void AddListeners() { m_EmptyAccepter.AddListener(OnClickEmpty); m_Skip.AddListener(OnSkip); } protected override void OnPreOpen() { dialogueIndex = 0; DisplayDialogue(); } protected override void OnAfterOpen() { } protected override void OnPreClose() { UI3DModelExhibition.Instance.StopShow(); } protected override void OnAfterClose() { if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>()) { WindowCenter.Instance.Open<MainInterfaceWin>(); } } protected override void LateUpdate() { GA_Hero _hero = PlayerDatas.Instance.hero; if (_hero == null) { return; } if (_hero.LockTarget == null) { return; } float _chkDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _hero.LockTarget.Pos); if (_chkDistSqrt > Mathf.Pow(GeneralDefine.FarawayNpcDist, 2)) { _hero.LockTarget = null; Close(); } } #endregion private void DisplayDialogue() { var config = AdventureDialogueConfig.Get(adventureDialogueId); var speakType = config.speakType[dialogueIndex]; m_ContainerNpc.gameObject.SetActive(speakType == 0); m_ContainerPlayer.gameObject.SetActive(speakType == 1); switch (speakType) { case 0: var job = PlayerDatas.Instance.baseData.Job; UI3DModelExhibition.Instance.ShowPlayer(m_RawPlayer, job, true); m_PlayerName.text = PlayerDatas.Instance.baseData.PlayerName; m_PlayerDialogue.text = Language.Get(config.dialogues[dialogueIndex]); break; case 1: var npcId = config.npcId; var npcConfig = NPCConfig.Get(npcId); m_NpcName.text = npcConfig.charName; m_NpcDialogue.text = Language.Get(config.dialogues[dialogueIndex]); var data = new UI3DNPCExhibitionData() { npcId = npcId, isDialogue = true, }; UI3DModelExhibition.Instance.ShowNPC(m_RawNpc, data); break; } } private void OnSkip() { Close(); model.SendSwitchAdventureState(model.processingIncidentId, 3); } private void OnClickEmpty() { var config = AdventureDialogueConfig.Get(adventureDialogueId); if (dialogueIndex < config.dialogues.Length - 1) { dialogueIndex += 1; DisplayDialogue(); } else { Close(); model.SendSwitchAdventureState(model.processingIncidentId, 3); } } } } System/HazyRegion/HazyRegionDialogueWin.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: d898556f396977c41b6231935e4fd466 timeCreated: 1554779979 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: System/HazyRegion/HazyRegionEntrancePanel.cs
@@ -114,10 +114,23 @@ switch (error) { case 1: DailyQuestOpenTime dailyQuestOpenTime; if (dailyQuestModel.TryGetOpenTime((int)DailyQuestType.HazyRegion, out dailyQuestOpenTime)) { HourMinute hourMinute; if (dailyQuestOpenTime.TryGetTodayNearestOpenTime(out hourMinute)) { SysNotifyMgr.Instance.ShowTip("OpenHazyRegionError_1", hourMinute.hourBegin.ToString("D2"), hourMinute.hourEnd.ToString("D2")); } } break; case 2: WindowCenter.Instance.Open<HazyRegionBuyTimesWin>(); break; case 3: SysNotifyMgr.Instance.ShowTip("OpenHazyRegionError_3"); break; } } System/HazyRegion/HazyRegionModel.cs
@@ -7,9 +7,11 @@ public class HazyRegionModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk { Dictionary<int, Incident> m_Incidents = new Dictionary<int, Incident>(); Dictionary<int, AdventureInfo> m_AdventureInfos = new Dictionary<int, AdventureInfo>(); public int limitPoint { get; private set; } public int point { get; private set; } public int processingIncidentId { get; private set; } public bool playing { get; private set; } public bool isServerPrepare { get; private set; } @@ -30,6 +32,8 @@ } } int cacheMapId = 0; public event Action selectIncidentRefresh; public event Action<int> onHazyRegionStateRefresh; //0-结束拜访 1-开始拜访 2-强制刷新 public event Action onHazyRegionIncidentRefresh; @@ -40,6 +44,8 @@ public override void Init() { ParseConfig(); StageLoad.Instance.onStageLoadFinish += OnStageLoadFinish; } public void OnBeforePlayerDataInitialize() @@ -48,6 +54,7 @@ point = 0; playing = false; m_Incidents.Clear(); m_AdventureInfos.Clear(); } public void OnPlayerLoginOk() @@ -57,7 +64,37 @@ public override void UnInit() { StageLoad.Instance.onStageLoadFinish -= OnStageLoadFinish; } private void OnStageLoadFinish() { if (!(StageLoad.Instance.currentStage is DungeonStage)) { cacheMapId = 0; } else { var mapId = PlayerDatas.Instance.baseData.MapID; if (!MapUtility.IsDungeon(mapId)) { if (IsIncidentDungeon(cacheMapId)) { SnxxzGame.Instance.StartCoroutine(Co_TryOpenHazyRegionWin()); } } } } IEnumerator Co_TryOpenHazyRegionWin() { yield return WaitingForSecondConst.WaitMS1000; if (NewBieCenter.Instance.inGuiding || ModelCenter.Instance.GetModel<TreasureModel>().newGotShowing) { yield break; } WindowCenter.Instance.Open<CrossServerWin>(false, 2); } void ParseConfig() @@ -141,6 +178,11 @@ return true; } public bool TryGetAdventureInfo(int id, out AdventureInfo adventureInfo) { return m_AdventureInfos.TryGetValue(id, out adventureInfo); } public ICollection<int> GetAllIncidents() { return m_Incidents.Keys; @@ -159,6 +201,23 @@ return 0; } public bool IsIncidentDungeon(int mapId) { if (mapId == 0) { return false; } var configs = HazyRegionConfig.GetValues(); foreach (var config in configs) { if (config.dungeonId == mapId) { return true; } } return false; } public void DisplayErrorRemind(int error) { switch (error) @@ -168,12 +227,63 @@ } } public void StartAdventureDialogue() { var config = HazyRegionConfig.Get(processingIncidentId); if (config != null) { AdventureInfo adventureInfo; if (TryGetAdventureInfo(processingIncidentId, out adventureInfo)) { bool satisfyCondition = false; switch (config.lineId) { case 1: satisfyCondition = PlayerDatas.Instance.baseData.LV >= adventureInfo.condition; break; case 2: satisfyCondition = PlayerDatas.Instance.baseData.realmLevel >= adventureInfo.condition; break; case 3: satisfyCondition = PlayerDatas.Instance.baseData.FightPoint >= adventureInfo.condition; break; case 4: satisfyCondition = PlayerDatas.Instance.extersion.luckValue >= adventureInfo.condition; break; } var dialogueConfig = AdventureDialogueConfig.Get(config.lineId, satisfyCondition ? adventureInfo.gear : 0); if (dialogueConfig == null) { SendSwitchAdventureState(processingIncidentId, 3); } else { WindowCenter.Instance.Close<MainInterfaceWin>(); HazyRegionDialogueWin.adventureDialogueId = dialogueConfig.id; WindowCenter.Instance.Open<HazyRegionDialogueWin>(); } } } } public void SendGotoIncident(int id) { processingIncidentId = id; var config = HazyRegionConfig.Get(id); switch ((HazyRegionIncidentType)config.incidentType) { case HazyRegionIncidentType.Adventure: AdventureStage.Instance.Enter(); Incident incident; if(TryGetIncident(id,out incident)) { if (incident.state == IncidentState.UnStart) { SendSwitchAdventureState(id, 2); } } break; case HazyRegionIncidentType.Boss: case HazyRegionIncidentType.FairyGrass: @@ -195,6 +305,14 @@ { var pak = new CA526_tagCMVisitFairyDomain(); pak.Type = 0; GameNetSystem.Instance.SendInfo(pak); } public void SendSwitchAdventureState(int id, int state) { var pak = new CA504_tagCMPlayerGetReward(); pak.DataEx = (uint)id; pak.DataExStr = state.ToString(); GameNetSystem.Instance.SendInfo(pak); } @@ -242,6 +360,21 @@ } } public void ReceivePackage(HA307_tagMCFairyAdventuresInfo package) { m_AdventureInfos.Clear(); for (int i = 0; i < package.Cnt; i++) { var data = package.InfoList[i]; m_AdventureInfos[data.EventID] = new AdventureInfo() { gear = data.Gear, condition = (int)data.Condition, }; } } public enum IncidentState { UnStart = 1, @@ -254,6 +387,12 @@ public int id; public IncidentState state; } public struct AdventureInfo { public int gear; public int condition; } } public enum HazyRegionIncidentType Utility/ConfigInitiator.cs
@@ -289,7 +289,8 @@ normalTasks.Add(new ConfigInitTask("LegendPropertyConfig", () => { LegendPropertyConfig.Init(); }, () => { return LegendPropertyConfig.inited; })); normalTasks.Add(new ConfigInitTask("EquipSuitNameConfig", () => { EquipSuitNameConfig.Init(); }, () => { return EquipSuitNameConfig.inited; })); normalTasks.Add(new ConfigInitTask("ReikiRootConfig", () => { ReikiRootConfig.Init(); }, () => { return ReikiRootConfig.inited; })); normalTasks.Add(new ConfigInitTask("HazyRegionConfig", () => { HazyRegionConfig.Init(); }, () => { return HazyRegionConfig.inited; })); normalTasks.Add(new ConfigInitTask("HazyRegionConfig", () => { HazyRegionConfig.Init(); }, () => { return HazyRegionConfig.inited; })); normalTasks.Add(new ConfigInitTask("AdventureDialogueConfig", () => { AdventureDialogueConfig.Init(); }, () => { return AdventureDialogueConfig.inited; })); } static List<ConfigInitTask> doingTasks = new List<ConfigInitTask>();