| | |
| | | bool hasInitializedNpc = false;
|
| | | public bool hasCompleted { get; private set; }
|
| | |
|
| | | static Clock s_CollectClock = null;
|
| | |
|
| | | static Dictionary<uint, GA_NpcClientCollect> s_CollectNpcs = new Dictionary<uint, GA_NpcClientCollect>();
|
| | | static Dictionary<uint, int> s_Sid2NpcIds = new Dictionary<uint, int>();
|
| | | static Dictionary<uint, int> s_Sid2NpcIndexs = new Dictionary<uint, int>();
|
| | |
| | | HazyGrassModel model { get { return ModelCenter.Instance.GetModel<HazyGrassModel>(); } }
|
| | | HazyRegionModel hazyRegionModel { get { return ModelCenter.Instance.GetModel<HazyRegionModel>(); } }
|
| | | DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
| | | PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
| | |
|
| | | public override void Initialize()
|
| | | {
|
| | |
| | | InitialPlayer();
|
| | | InitializeNpc();
|
| | |
|
| | | TryGotoCloserNpc();
|
| | | var npcId = TryGetScarceNpc();
|
| | | TryGotoCloserNpc(npcId);
|
| | |
|
| | | model.onMapNpcCountRefresh += OnMapNpcCountRefresh;
|
| | | }
|
| | |
| | | public override void UnInitialize()
|
| | | {
|
| | | base.UnInitialize();
|
| | |
|
| | | if (s_CollectClock != null)
|
| | | {
|
| | | Clock.Stop(s_CollectClock);
|
| | | s_CollectClock = null;
|
| | | }
|
| | |
|
| | |
|
| | | UnloadAllNpc();
|
| | |
|
| | |
| | | {
|
| | | InitializeNpc();
|
| | |
|
| | | TryGotoCloserNpc();
|
| | | var npcId = TryGetScarceNpc();
|
| | | TryGotoCloserNpc(npcId);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | s_CollectNpcs.Remove(_sid);
|
| | | }
|
| | |
|
| | | var dungeon = ClientDungeonStageUtility.dungeonInfo;
|
| | | var hintId = dungeonModel.GetDungeonHintId(dungeon.mapId, dungeon.lineId);
|
| | | var dungeonHintConfig = DungeonHintConfig.Get(hintId);
|
| | | if (dungeonHintConfig != null)
|
| | | if (s_CollectClock != null)
|
| | | {
|
| | | var collectCount = 0;
|
| | | for (int i = 0; i < dungeonHintConfig.NPC1ID.Length; i++)
|
| | | Clock.Stop(s_CollectClock);
|
| | | s_CollectClock = null;
|
| | | }
|
| | |
|
| | | s_CollectClock = Clock.AlarmAfter(0.5f, () =>
|
| | | {
|
| | | var dungeon = ClientDungeonStageUtility.dungeonInfo;
|
| | | var hintId = dungeonModel.GetDungeonHintId(dungeon.mapId, dungeon.lineId);
|
| | | var dungeonHintConfig = DungeonHintConfig.Get(hintId);
|
| | | if (dungeonHintConfig != null)
|
| | | {
|
| | | collectCount += dungeonModel.GetDugneonNpcCollectCount(dungeonHintConfig.NPC1ID[i]);
|
| | | }
|
| | | if (dungeonHintConfig.targetValue1.Length > 0
|
| | | && dungeonHintConfig.targetValue1[0] > 0)
|
| | | {
|
| | | if (collectCount < dungeonHintConfig.targetValue1[0] - 1)
|
| | | var collectCount = 0;
|
| | | for (int i = 0; i < dungeonHintConfig.NPC1ID.Length; i++)
|
| | | {
|
| | | TryGotoCloserNpc();
|
| | | collectCount += dungeonModel.GetDugneonNpcCollectCount(dungeonHintConfig.NPC1ID[i]);
|
| | | }
|
| | | if (dungeonHintConfig.targetValue1.Length > 0
|
| | | && dungeonHintConfig.targetValue1[0] > 0)
|
| | | {
|
| | | if (collectCount < dungeonHintConfig.targetValue1[0] - 1)
|
| | | {
|
| | | var npcId = TryGetScarceNpc();
|
| | | TryGotoCloserNpc(npcId);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | void InitialPlayer()
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | void TryGotoCloserNpc()
|
| | | /// <summary>
|
| | | /// |
| | | /// </summary>
|
| | | /// <param name="npcId">指定NpcId</param>
|
| | | void TryGotoCloserNpc(int npcId = 0)
|
| | | {
|
| | | var hero = PlayerDatas.Instance.hero;
|
| | | if (hero == null)
|
| | |
| | |
|
| | | foreach (var npc in s_CollectNpcs.Values)
|
| | | {
|
| | | if (npcId != 0 && npc.NpcConfig.NPCID != npcId)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | var dis = MathUtility.CalDistance(hero.Pos, npc.Pos);
|
| | | if (minDis > dis)
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | int TryGetScarceNpc()
|
| | | {
|
| | | if (ClientDungeonStageUtility.clientMapId == HazyGrassModel.REIKI_CLIENTDATAMAP)
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | List<int> npcIds = new List<int>();
|
| | | var dungeon = ClientDungeonStageUtility.dungeonInfo;
|
| | | var hintId = dungeonModel.GetDungeonHintId(dungeon.mapId, dungeon.lineId);
|
| | | var dungeonHintConfig = DungeonHintConfig.Get(hintId);
|
| | | if (dungeonHintConfig != null)
|
| | | {
|
| | | npcIds.AddRange(dungeonHintConfig.NPC1ID);
|
| | | }
|
| | |
|
| | | if (npcIds.Count > 0)
|
| | | {
|
| | | npcIds.Sort((lhs, rhs) =>
|
| | | {
|
| | | var lhs_item = model.GetGrassNpcItemId(lhs);
|
| | | var rhs_item = model.GetGrassNpcItemId(rhs);
|
| | | var lhs_npcCount = model.GetMapNpcCount(lhs);
|
| | | var rhs_npcCount = model.GetMapNpcCount(rhs);
|
| | | var lhs_empty = lhs_npcCount == 0;
|
| | | var rhs_empty = rhs_npcCount == 0;
|
| | | if (lhs_empty != rhs_empty)
|
| | | {
|
| | | return lhs_empty.CompareTo(rhs_empty);
|
| | | }
|
| | | var lhs_itemCount = packModel.GetItemCountByID(PackType.Item, lhs_item);
|
| | | var rhs_itemCount = packModel.GetItemCountByID(PackType.Item, rhs_item);
|
| | | if (lhs_itemCount != rhs_itemCount)
|
| | | {
|
| | | return lhs_itemCount.CompareTo(rhs_itemCount);
|
| | | }
|
| | | return lhs_item.CompareTo(rhs_item);
|
| | | });
|
| | |
|
| | | return npcIds[0];
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | private void OnHeroFindStop()
|
| | | {
|
| | | var hero = PlayerDatas.Instance.hero;
|
| | |
| | | }
|
| | | hero.OnPathFindStop -= OnHeroFindStop;
|
| | |
|
| | | if (ClientDungeonStageUtility.clientMapId == HazyGrassModel.REIKI_CLIENTDATAMAP)
|
| | | if (PlayerDatas.Instance.baseData.LV >= model.autoCollectLevel)
|
| | | {
|
| | | if (PlayerDatas.Instance.baseData.LV >= model.autoCollectLevel)
|
| | | if (autoNpc != null)
|
| | | {
|
| | | if (autoNpc != null)
|
| | | {
|
| | | float _chkDistSqrt = MathUtility.DistanceSqrtXZ(hero.Pos, autoNpc.Pos);
|
| | | float _chkDist = GeneralDefine.CloseNpcDist + autoNpc.NpcConfig.ModelRadius + 0.3f;
|
| | | float _chkDistSqrt = MathUtility.DistanceSqrtXZ(hero.Pos, autoNpc.Pos);
|
| | | float _chkDist = GeneralDefine.CloseNpcDist + autoNpc.NpcConfig.ModelRadius + 0.3f;
|
| | |
|
| | | if (_chkDistSqrt <= Mathf.Pow(_chkDist, 2))
|
| | | {
|
| | | hero.SelectTarget = autoNpc;
|
| | | ClientCollectUtility.HandleCallback(E_NpcType.Collect, autoNpc.NpcConfig.NPCID, autoNpc.ServerInstID);
|
| | | }
|
| | | if (_chkDistSqrt <= Mathf.Pow(_chkDist, 2))
|
| | | {
|
| | | hero.SelectTarget = autoNpc;
|
| | | ClientCollectUtility.HandleCallback(E_NpcType.Collect, autoNpc.NpcConfig.NPCID, autoNpc.ServerInstID);
|
| | | }
|
| | | }
|
| | | }
|