From bb2d2bae05da9eed93e13071b0f3bb9f5e058aa8 Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期二, 16 四月 2019 19:52:14 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
---
System/HazyRegion/HazyGrassModel.cs | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 108 insertions(+), 8 deletions(-)
diff --git a/System/HazyRegion/HazyGrassModel.cs b/System/HazyRegion/HazyGrassModel.cs
index 5f0f6be..03e89df 100644
--- a/System/HazyRegion/HazyGrassModel.cs
+++ b/System/HazyRegion/HazyGrassModel.cs
@@ -6,6 +6,9 @@
{
public class HazyGrassModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
{
+ Dictionary<int, List<HazyGrassNpcInfo>> mapNpcs = new Dictionary<int, List<HazyGrassNpcInfo>>();
+ Dictionary<int, int> m_MapNpcCount = new Dictionary<int, int>();
+
public const int ReikiGrassMapId = 32040;
public const int FairyGrassMapId = 32050;
public const int Client_ReikiGrassMapID = 3240;
@@ -13,11 +16,10 @@
public bool IsInDungeon { get; private set; }
- public int grassRefreshSeconds { get; private set; }
-
- public DateTime grassBornTime { get; private set; }
+ public event Action onMapNpcCountRefresh;
HazyRegionModel hazyRegionModel { get { return ModelCenter.Instance.GetModel<HazyRegionModel>(); } }
+ DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
public override void Init()
{
@@ -41,12 +43,35 @@
void ParseConfig()
{
- grassRefreshSeconds = 20;
+ var mapNpcConfigs = MapNpcRefreshConfig.GetValues();
+ foreach (var config in mapNpcConfigs)
+ {
+ if (config.MapID == ReikiGrassMapId
+ || config.MapID == FairyGrassMapId)
+ {
+ List<HazyGrassNpcInfo> _npcs = null;
+ if (!mapNpcs.TryGetValue(config.MapID, out _npcs))
+ {
+ _npcs = new List<HazyGrassNpcInfo>();
+ mapNpcs.Add(config.MapID, _npcs);
+ }
+ for (int i = 0; i < config.NPCIDList.Length; i++)
+ {
+ _npcs.Add(new HazyGrassNpcInfo()
+ {
+ npcId = config.NPCIDList[i],
+ refreshMinute = config.RefreshPerMinutes,
+ });
+ }
+ }
+ }
}
private void OnStageLoadFinish()
{
var mapId = PlayerDatas.Instance.baseData.MapID;
+
+ m_MapNpcCount.Clear();
IsInDungeon = false;
if (IsInGrassDungeon(mapId))
@@ -89,14 +114,83 @@
return 0;
}
- public void RefreshGrassBornTime()
+ public int GetGrassMapId(int incidentId)
{
-
+ var config = HazyRegionConfig.Get(incidentId);
+ if (config != null)
+ {
+ return config.dungeonId;
+ }
+ return 0;
}
- public void RefreshGrassBornTime(DateTime _time)
+ public List<HazyGrassNpcInfo> GetGrassNpcInfos(int mapId)
{
- grassBornTime = _time;
+ if (mapNpcs.ContainsKey(mapId))
+ {
+ return mapNpcs[mapId];
+ }
+ return null;
+ }
+
+ public int GetMapNpcCount(int npcId)
+ {
+ if (m_MapNpcCount.ContainsKey(npcId))
+ {
+ return m_MapNpcCount[npcId];
+ }
+ return 0;
+ }
+
+ public bool CanCollectClientNpc(int npcId)
+ {
+ if (ClientDungeonStageUtility.isClientDungeon
+ && ClientDungeonStageUtility.clientMapId == Client_ReikiGrassMapID)
+ {
+ var config = HazyRegionConfig.Get(hazyRegionModel.processingIncidentId);
+ if (config != null)
+ {
+ var collectCount = dungeonModel.GetDugneonNpcCollectCount(npcId);
+ var hintId = dungeonModel.GetDungeonHintId(config.dungeonId, config.lineId);
+ var hintConfig = DungeonHintConfig.Get(hintId);
+ if (hintConfig.NPC1ID.Length > 0 && hintConfig.NPC1ID[0] == npcId)
+ {
+ return collectCount < hintConfig.targetValue1[0];
+ }
+ else if (hintConfig.NPC2ID.Length > 0 && hintConfig.NPC2ID[0] == npcId)
+ {
+ return collectCount < hintConfig.targetValue2[0];
+ }
+ }
+ }
+ return true;
+ }
+
+ public void ReceivePackage(HA714_tagMCNPCCntList package)
+ {
+ if (package.MapID != ReikiGrassMapId
+ && package.MapID != FairyGrassMapId)
+ {
+ return;
+ }
+ for (int i = 0; i < package.NPCInfoCnt; i++)
+ {
+ var data = package.NPCInfoList[i];
+ m_MapNpcCount[(int)data.NPCID] = (int)data.Cnt;
+ }
+ if (onMapNpcCountRefresh != null)
+ {
+ onMapNpcCountRefresh();
+ }
+ }
+
+ public void RefreshMapNpcCount(int npcId, int count)
+ {
+ m_MapNpcCount[npcId] = count;
+ if (onMapNpcCountRefresh != null)
+ {
+ onMapNpcCountRefresh();
+ }
}
public void RequestEnterClientDungeon()
@@ -145,5 +239,11 @@
});
}
}
+
+ public struct HazyGrassNpcInfo
+ {
+ public int npcId;
+ public int refreshMinute;
+ }
}
--
Gitblit v1.8.0