| | |
| | | }
|
| | | }
|
| | |
|
| | | public void MoveToNPC(int npcID)
|
| | | public void MoveToNPC(int npcID, int sid = 0)
|
| | | {
|
| | | if (sid != 0)
|
| | | {
|
| | | GActor _actor = GAMgr.Instance.GetBySID((uint)sid);
|
| | | if (_actor != null)
|
| | | {
|
| | | NpcID = npcID;
|
| | | MapTransferDoType = E_MapTransferDoType.Npc;
|
| | |
|
| | | MoveToExistNpc(npcID, _actor);
|
| | |
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | NPCConfig _config = Config.Instance.Get<NPCConfig>(npcID);
|
| | |
|
| | | if (_config == null)
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | //Debug.LogFormat(" |-- 在本地图");
|
| | | if (PlayerDatas.Instance.baseData.FBID != 0)
|
| | | {
|
| | | if (BossFakeLineUtility.Instance.IsShuntBoss(npcID))
|
| | | {
|
| | | //Debug.LogFormat(" |-- BossFakeLineUtility.Instance.makeFakeLineTimes = 1");
|
| | | BossFakeLineUtility.Instance.makeFakeLineTimes = 1;
|
| | | }
|
| | | }
|
| | | //Debug.LogFormat(" |-- 在本地图"); |
| | | // Debug.LogFormat("lastMoveToWorldBossNpcID: {0}, Time: {1}, FBID: {2}, showFakeLine: {3}, FairyBoss: {4}",
|
| | | // lastMoveToWorldBossNpcID,
|
| | | // Time.realtimeSinceStartup - lastMoveToWorldBossTime,
|
| | | // PlayerDatas.Instance.baseData.FBID,
|
| | | // BossFakeLineUtility.Instance.showFakeLine,
|
| | | // _fairyBossModel.bosses != null
|
| | | // && _fairyBossModel.bosses.Contains(npcID));
|
| | |
|
| | | if (((lastMoveToWorldBossNpcID == npcID
|
| | | && Time.realtimeSinceStartup - lastMoveToWorldBossTime < 60)
|
| | | && PlayerDatas.Instance.baseData.FBID == 0)
|
| | | || BossFakeLineUtility.Instance.showFakeLine
|
| | | || (_fairyBossModel.bosses != null
|
| | | && _fairyBossModel.bosses.Contains(npcID)))
|
| | | && Time.realtimeSinceStartup - lastMoveToWorldBossTime < 60)
|
| | | && PlayerDatas.Instance.baseData.FBID == 0)
|
| | | || BossFakeLineUtility.Instance.showFakeLine
|
| | | || (_fairyBossModel.bosses != null
|
| | | && _fairyBossModel.bosses.Contains(npcID)))
|
| | | {
|
| | | //Debug.LogFormat(" |-- 非想去的boss为60秒内行为产生且为同一只boss, {0}, {1}", BossFakeLineUtility.Instance.showFakeLine,
|
| | | //PlayerDatas.Instance.baseData.FBID);
|
| | |
| | | else
|
| | | {
|
| | | // 处于相同地图
|
| | | if (BossFakeLineUtility.Instance.lastBossNpcID != npcID
|
| | | || Time.realtimeSinceStartup - BossFakeLineUtility.Instance.inMistakeForBossAliveOverTime > 60)
|
| | | if (!BossFakeLineUtility.Instance.HasSawBossRecently(npcID))
|
| | | {
|
| | | if (BossFakeLineUtility.Instance.IsShuntBoss(npcID))
|
| | | {
|
| | | //Debug.LogFormat(" |-- BossFakeLineUtility.Instance.makeFakeLineTimes = 1");
|
| | | BossFakeLineUtility.Instance.makeFakeLineTimes = 1;
|
| | | }
|
| | |
|
| | | //Debug.LogFormat(" |-- 非想去的boss记录,或则见到boss时差超过60秒");
|
| | | Send_WorldTransfer(_npcLocation.mapId, new Vector3(_hero.Pos.x * 2, 0, _hero.Pos.z * 2), MapTransferType.WorldTransport, 0, npcID);
|
| | | }
|
| | |
| | | {
|
| | | _npc = GAMgr.Instance.GetCloserNPC(_hero.Pos, npcID);
|
| | |
|
| | | // 目标点, 默认为主角坐标, 找不到任务终点的时候不移动
|
| | | Vector3 _destPos = _hero.Pos;
|
| | | MoveToExistNpc(npcID, _npc);
|
| | | }
|
| | | }
|
| | |
|
| | | // 计算当前坐标与目标角色的坐标差
|
| | | //GActor _npc = GAMgr.Instance.GetCloserNPC(_hero.Pos, npcID);
|
| | | //// 如果在当前地图找得到已创建出来最近的目标
|
| | | //if (_npc != null)
|
| | | //{
|
| | | // _destPos = _npc.Pos;
|
| | | //}
|
| | | //else
|
| | | //{
|
| | | Vector2 _calculPos = _destPos;
|
| | | if (_findLocation)
|
| | | private void MoveToExistNpc(int npcID, GActor npc)
|
| | | {
|
| | | GA_Hero _hero = PlayerDatas.Instance.hero;
|
| | |
|
| | | NPCConfig _config = Config.Instance.Get<NPCConfig>(npcID);
|
| | |
|
| | | // 目标点, 默认为主角坐标, 找不到任务终点的时候不移动
|
| | | Vector3 _destPos = _hero.Pos;
|
| | |
|
| | | // 获取NPC位置数据
|
| | | GAStaticDefine.NPCLocation _npcLocation;
|
| | | var _findLocation = GAStaticDefine.TryGetMapNPCLocation(npcID, out _npcLocation);
|
| | |
|
| | | Vector2 _calculPos = _destPos;
|
| | | if (_findLocation)
|
| | | {
|
| | | _calculPos = _npcLocation.position;
|
| | | }
|
| | | _destPos = new Vector3(_calculPos.x, _hero.Pos.y, _calculPos.y);
|
| | | //}
|
| | |
|
| | | // 判断距离
|
| | | float _distSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _destPos);
|
| | |
|
| | | // 判断是否需要骑马移动
|
| | | if (_distSqrt > Mathf.Pow(7, 2))
|
| | | {
|
| | | DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(true);
|
| | | }
|
| | |
|
| | | float _chkDist = Mathf.Max(GeneralConfig.Instance.CloseNpcDist + _config.ModelRadius - 0.3f, 0);
|
| | |
|
| | | if (_config.NPCType == (int)E_NpcType.OpenWorldMap)
|
| | | {
|
| | | _chkDist = 1;
|
| | | }
|
| | |
|
| | | // 针对挖洞对象保持距离为0
|
| | | if (npc != null && _config.Dig == 1)
|
| | | {
|
| | | _chkDist = 0;
|
| | | }
|
| | |
|
| | | // 大于配置的距离, 移动至
|
| | | if (_distSqrt > Mathf.Pow(_chkDist, 2))
|
| | | {
|
| | | if (_config.NPCType == (int)E_NpcType.Fight)
|
| | | {
|
| | | _calculPos = _npcLocation.position;
|
| | | _hero.MoveToPosition(_destPos, _npcLocation.scope);
|
| | | }
|
| | | _destPos = new Vector3(_calculPos.x, _hero.Pos.y, _calculPos.y);
|
| | | //}
|
| | |
|
| | | // 判断距离
|
| | | float _distSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _destPos);
|
| | |
|
| | | // 判断是否需要骑马移动
|
| | | if (_distSqrt > Mathf.Pow(7, 2))
|
| | | else
|
| | | {
|
| | | DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(true);
|
| | | if (npc != null)
|
| | | {
|
| | | _destPos = npc.Pos;
|
| | | }
|
| | |
|
| | | _hero.MoveToPosition(_destPos, _chkDist);
|
| | | }
|
| | |
|
| | | float _chkDist = Mathf.Max(GeneralConfig.Instance.CloseNpcDist + _config.ModelRadius - 0.3f, 0);
|
| | |
|
| | | if (_config.NPCType == (int)E_NpcType.OpenWorldMap)
|
| | | if (s_OnHeroStartMoveToNPC != null)
|
| | | {
|
| | | _chkDist = 1;
|
| | | s_OnHeroStartMoveToNPC();
|
| | | }
|
| | |
|
| | | // 针对挖洞对象保持距离为0
|
| | | if (_npc != null && _config.Dig == 1)
|
| | | {
|
| | | _chkDist = 0;
|
| | | }
|
| | |
|
| | | // 大于配置的距离, 移动至
|
| | | if (_distSqrt > Mathf.Pow(_chkDist, 2))
|
| | | }
|
| | | // 小于距离则判断目标的类型,执行相应的逻辑
|
| | | else
|
| | | {
|
| | | if (_config != null)
|
| | | {
|
| | | if (_config.NPCType == (int)E_NpcType.Fight)
|
| | | {
|
| | | _hero.MoveToPosition(_destPos, _npcLocation.scope);
|
| | | _hero.Behaviour.StartHandupAI();
|
| | | }
|
| | | else if (_config.NPCType == (int)E_NpcType.Collect)
|
| | | {
|
| | | GA_NpcCollect _collect = npc as GA_NpcCollect;
|
| | | if (_collect != null)
|
| | | {
|
| | | _collect.Arrive();
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (_npc != null)
|
| | | // 如果目标已经在之前搜索中确定了
|
| | | // 没确定其实在这里应该是异常情况
|
| | | if (npc != null)
|
| | | {
|
| | | _destPos = _npc.Pos;
|
| | | }
|
| | | _hero.LockTarget = npc;
|
| | | _hero.SelectTarget = npc;
|
| | |
|
| | | _hero.MoveToPosition(_destPos, _chkDist);
|
| | | }
|
| | | NPCInteractProcessor.InvokeEvent((E_NpcType)_config.NPCType, npcID, npc.ServerInstID);
|
| | |
|
| | | if (s_OnHeroStartMoveToNPC != null)
|
| | | {
|
| | | s_OnHeroStartMoveToNPC();
|
| | | }
|
| | | }
|
| | | // 小于距离则判断目标的类型,执行相应的逻辑
|
| | | else
|
| | | {
|
| | | if (_config != null)
|
| | | {
|
| | | if (_config.NPCType == (int)E_NpcType.Fight)
|
| | | {
|
| | | _hero.Behaviour.StartHandupAI();
|
| | | }
|
| | | else if (_config.NPCType == (int)E_NpcType.Collect)
|
| | | {
|
| | | GA_NpcCollect _collect = _npc as GA_NpcCollect;
|
| | | if (_collect != null)
|
| | | Vector3 _npc2heroDir = MathUtility.ForwardXZ(npc.Pos, _hero.Pos);
|
| | |
|
| | | if (_config.AutomaticFace == 1)
|
| | | {
|
| | | _collect.Arrive();
|
| | | npc.Forward = -_npc2heroDir;
|
| | | }
|
| | | _hero.Forward = _npc2heroDir;
|
| | | }
|
| | | // 会有为空的时候, 例如是小飞鞋飞的情况, 这里直接判断与配置的坐标的距离
|
| | | else
|
| | | {
|
| | | // 如果目标已经在之前搜索中确定了
|
| | | // 没确定其实在这里应该是异常情况
|
| | | if (_npc != null)
|
| | | {
|
| | | _hero.LockTarget = _npc;
|
| | | _hero.SelectTarget = _npc;
|
| | |
|
| | | NPCInteractProcessor.InvokeEvent((E_NpcType)_config.NPCType, npcID, _npc.ServerInstID);
|
| | |
|
| | | Vector3 _npc2heroDir = MathUtility.ForwardXZ(_npc.Pos, _hero.Pos);
|
| | |
|
| | | if (_config.AutomaticFace == 1)
|
| | | {
|
| | | _npc.Forward = -_npc2heroDir;
|
| | | }
|
| | | _hero.Forward = _npc2heroDir;
|
| | | }
|
| | | // 会有为空的时候, 例如是小飞鞋飞的情况, 这里直接判断与配置的坐标的距离
|
| | | else
|
| | | {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | else if (_npcConfig.NPCType == (int)E_NpcType.Collect)
|
| | | {
|
| | | float _chkDist = GeneralConfig.Instance.CloseNpcDist + _npcConfig.ModelRadius + 0.3f;
|
| | | if (_chkDistSqrt <= Mathf.Pow(_chkDist, 2))
|
| | | {
|
| | | if (!UserInputHandler.isTouched
|
| | | && (_hero.SkillMgr.CurCastSkill == null || _hero.SkillMgr.CurCastSkill.SkillCompelete))
|
| | | {
|
| | | NPCInteractProcessor.InvokeEvent(E_NpcType.Func, NpcID, _npc.ServerInstID);
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|