Esempio n. 1
0
 public void AddPathPoint(AutoSearchPoint point)
 {
     if (null != m_AutoSearchPointCache)
     {
         m_AutoSearchPointCache.Add(point);
     }
 }
Esempio n. 2
0
    // 立即前往
    void ButtonGo()
    {
        Tab_MissionDictionary DicTab = TableManager.GetMissionDictionaryByID(GlobeVar.PAOSHANG_MISSIONID_H, 0);

        if (DicTab == null)
        {
            LogModule.ErrorLog("Can not find missionDictionary {0}", GlobeVar.PAOSHANG_MISSIONID_H);
            return;
        }

        // 自动寻路
        AutoSearchPoint point = new AutoSearchPoint(DicTab.AccepteNpcSceneID, DicTab.AccepteNpcPosX, DicTab.AccepteNpcPosZ);

        if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
        {
            string           sAutoSearchTargetName = string.Empty;
            Tab_RoleBaseAttr RoleBase = TableManager.GetRoleBaseAttrByID(DicTab.AcceptNpcDataID, 0);
            if (null != RoleBase)
            {
                sAutoSearchTargetName = RoleBase.Name;
            }
            else
            {
                LogModule.ErrorLog("Can not find roleBaseAttr {0}", DicTab.AcceptNpcDataID);
            }
            GameManager.gameManager.AutoSearch.ProcessAutoSearch(point, sAutoSearchTargetName, false);
        }
    }
Esempio n. 3
0
    void OnSceneMapClick()
    {
        Vector3 worldPos = UICamera.currentCamera.ScreenToWorldPoint(UICamera.lastTouchPosition);
        Vector3 localPos = m_TextureMap.transform.InverseTransformPoint(worldPos);
        Vector3 mapPos   = MapPosToScenePos(localPos, m_curTabScene);

        AutoSearchPoint point = new AutoSearchPoint(m_curSceneID, mapPos.x, mapPos.z);

        if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
        {
            if (Singleton <ObjManager> .GetInstance().MainPlayer)
            {
                //验证导航是否可达,如果不可达,不进行移动
                Vector3 testVec = new Vector3(point.PosX, 0, point.PosZ);
                testVec = ActiveScene.GetTerrainPosition(testVec);
                if (!Singleton <ObjManager> .GetInstance().MainPlayer.IsMoveNavAgent(testVec))
                {
                    return;
                }
            }

            GameManager.gameManager.AutoSearch.ProcessAutoSearch(point);
        }

        if (m_ClickEffectSprite != null && m_ClickEffectTran != null)
        {
            m_ClickEffectTran.localPosition = localPos;
            m_ClickEffectSprite.gameObject.SetActive(true);
        }
        else
        {
            LogModule.ErrorLog("OnSceneMapClick::m_ClickEffectSprite = null || m_ClickEffectTran = null");
        }
    }
    public void Init()
    {
        if (_hasInited)
        {
            return;
        }
        m_circleTrans = transform;
        m_arrowTrans  = m_circleTrans.FindChild(m_arrowObjectName);
        if (m_arrowTrans != null)
        {
            m_arrowTrans.parent = null;
        }
        Transform rotatedObjTrans = m_circleTrans.FindChild(m_rotatedCircleName);

        if (rotatedObjTrans != null)
        {
            Quaternion.Euler(90, 360, 0);
            EffectObjRotatedY.AddToObj(rotatedObjTrans.gameObject, 180);
        }
        if (LoadDestEffect())
        {
            HideDestEffect();
        }
        if (LoadArrowEffect())
        {
            HideArrawEffect();
        }
        arrowAnims          = new ArrowAnim[8];
        arrowAnims[0]       = new ArrowAnim();
        arrowAnims[0].idx   = 0;
        arrowAnims[0].timer = .21875f;
        arrowAnims[1]       = new ArrowAnim();
        arrowAnims[1].idx   = 1;
        arrowAnims[1].timer = .1875f;
        arrowAnims[2]       = new ArrowAnim();
        arrowAnims[2].idx   = 2;
        arrowAnims[2].timer = .15625f;
        arrowAnims[3]       = new ArrowAnim();
        arrowAnims[3].idx   = 3;
        arrowAnims[3].timer = .125f;
        arrowAnims[4]       = new ArrowAnim();
        arrowAnims[4].idx   = 4;
        arrowAnims[4].timer = .09375f;
        arrowAnims[5]       = new ArrowAnim();
        arrowAnims[5].idx   = 5;
        arrowAnims[5].timer = .0625f;
        arrowAnims[6]       = new ArrowAnim();
        arrowAnims[6].idx   = 6;
        arrowAnims[6].timer = .03125f;
        arrowAnims[7]       = new ArrowAnim();
        arrowAnims[7].idx   = 7;
        arrowAnims[7].timer = 0f;

        m_bHasDestination = false;
        m_Destination     = new AutoSearchPoint();
        m_Path            = new AutoSearchPath();
        m_NavPath         = new NavMeshPath();
        _hasInited        = true;
    }
Esempio n. 5
0
    void OnButton1(GameObject obj)
    {
        if (m_Mode == DIVORCE_MODE)
        {
            m_Mode = DIVORCE_MODE_STEP1;
            UpdateButtons();
            return;
        }
        if (m_Mode == DIVORCE_MODE_STEP1)
        {
            m_Mode = DIVORCE_MODE_STEP2;
            UpdateButtons();
            return;
        }
        if (m_Mode == DIVORCE_MODE_STEP2)
        {
            OnCloseClick();
            return;
        }
        if (m_Mode == PARADE_MODE)
        {
            AutoSearchPoint point = new AutoSearchPoint(13, 36.0f, 99.0f);
            if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
            {
                GameManager.gameManager.AutoSearch.ProcessAutoSearch(point);
            }
            OnCloseClick();
            return;
        }

        if (GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID == GlobeVar.INVALID_ID)
        {
            Singleton <ObjManager> .GetInstance().MainPlayer.SendNoticMsg(false, "#{2531}");

            OnCloseClick();
            return;
        }
        UInt64 otherGUID = GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(1).Guid;

        if (otherGUID == GlobeVar.INVALID_GUID)
        {
            Singleton <ObjManager> .GetInstance().MainPlayer.SendNoticMsg(false, "#{2534}");

            OnCloseClick();
            return;
        }

        if (m_Mode == MARRY_MODE)
        {
            CG_REQ_MARRAGE Pack = (CG_REQ_MARRAGE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_MARRAGE);
            Pack.SetId(otherGUID);
            Pack.SetType((int)MARRY_PACKET_TYPE.MARRY_PACKET_ASKMARRY);
            Pack.SendPacket();
            OnCloseClick();
        }
    }
Esempio n. 6
0
    //初始化
    void Awake()
    {
        m_Path = new AutoSearchPath();
        m_Path.ResetPath();

        m_bIsAutoSearching = false;

        m_EndPointCache = new AutoSearchPoint();
        //InitMapConnectPath();
    }
    /// <summary>
    /// 重计算路径
    /// </summary>
    /// <returns><c>true</c>, if path was calculated, <c>false</c> otherwise.</returns>
    private bool CalculatePath()
    {
        if (null == m_mainPlayer)
        {
            return(false);
        }
        m_fReCalcPathtimer = m_fReCalcPathInterval;
        if (m_mainPlayer.NavAgent == null || m_mainPlayer.NavAgent.enabled == false)
        {
            return(false);
        }
        // navMeshAgent寻路的当前场景目标点
        Vector3 currentSceneDestination = Vector3.zero;

        // 如果目标点在当前场景
        if (m_Destination.SceneID == GameManager.gameManager.RunningScene)
        {
            currentSceneDestination = new Vector3(m_Destination.PosX, 0, m_Destination.PosZ);
            currentSceneDestination = ActiveScene.GetTerrainPosition(currentSceneDestination);
            // 判断是否已经到了目标点
            Vector3 playerPos   = m_mainPlayer.Position;
            float   distanceSqr = (playerPos.x - currentSceneDestination.x) * (playerPos.x - currentSceneDestination.x) +
                                  (playerPos.y - currentSceneDestination.y) * (playerPos.y - currentSceneDestination.y) +
                                  (playerPos.z - currentSceneDestination.z) * (playerPos.z - currentSceneDestination.z);
            if (distanceSqr < m_fCornerReachCheckDistanceSqr)
            {
                return(false);
            }
        }
        else
        {
            // todo
            AutoSearchPoint startPoint = AutoSearchPoint.MakePoint(m_mainPlayer.gameObject);

            m_Path.ResetPath();
            if (GameManager.gameManager.AutoSearch.FindPath(startPoint, m_Destination, ref m_Path))
            {
            }
            return(false);
        }

        // 利用NavMeshAgent寻得路径
        if (m_mainPlayer.NavAgent.CalculatePath(currentSceneDestination, m_NavPath))
        {
            m_NavPathCorners = m_NavPath.corners;
            // 第0个点是当前位置
            m_nNextCornerIdx = 1;
            return(true);
        }
        else
        {
            CancelGuide();
            return(false);
        }
    }
Esempio n. 8
0
    //创建一条路径,并且在Update中判断是否抵达
    private void BuildPath(AutoSearchPoint endPoint)
    {
        Obj_MainPlayer _mainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer;

        if (null == _mainPlayer)
        {
            return;
        }


        // 轻功状态下无法自动寻路
        if (_mainPlayer.IsLightState)
        {
            //轻功状态无法自动寻路
            _mainPlayer.SendNoticMsg(false, "#{4646}");
            return;
        }

        // 同一个点,直接跳过
        if (m_EndPointCache.SceneID == endPoint.SceneID &&
            m_EndPointCache.PosX == endPoint.PosX &&
            m_EndPointCache.PosZ == endPoint.PosZ)
        {
            return;
        }

        //停止正在进行的移动
        if (true == _mainPlayer.IsMoving)
        {
            _mainPlayer.StopMove();
        }

        m_EndPointCache = endPoint;
        m_Path.ResetPath();
        m_bNotEnamyNpcFlag = 0;
        //判断主角是否存在

        //如果是当前场景,则直接生成单点路径,进行移动
        if (GameManager.gameManager.RunningScene == endPoint.SceneID)
        {
            m_Path.AddPathPoint(endPoint);
            //设置开始自动寻路
            IsAutoSearching = true;
            return;
        }

        //根据当前点和目的地点来确定路径
        AutoSearchPoint startPoint = AutoSearchPoint.MakePoint(_mainPlayer.gameObject);

        if (true == FindPath(startPoint, endPoint, ref m_Path))
        {
            IsAutoSearching = true;
            return;
        }
    }
Esempio n. 9
0
    //根据一个obj的信息来构建一个AutoSearchPoint
    public static AutoSearchPoint MakePoint(GameObject obj)
    {
        if (null == obj)
        {
            return(null);
        }

        AutoSearchPoint point = new AutoSearchPoint();

        point.SceneID = GameManager.gameManager.RunningScene;
        point.m_fPosX = obj.transform.position.x;
        point.m_fPosZ = obj.transform.position.z;

        return(point);
    }
Esempio n. 10
0
 /// <summary>
 /// added by mawenbin
 /// 封装自动寻路代理接口
 /// </summary>
 /// <param name="endPoint">目标点</param>
 /// <param name="sAutoSearchTargetName">目标Object名称</param>
 /// <param name="bEnableTeleport">是否允许弹出传送界面</param>
 public void ProcessAutoSearch(AutoSearchPoint endPoint, string sAutoSearchTargetName = "", bool bEnableTeleport = true)
 {
     if (null != endPoint && -1 < endPoint.SceneID)
     {
         BuildPath(endPoint);
         if (null != Path && 0 < Path.AutoSearchPosCache.Count && IsAutoSearching)
         {
             Path.AutoSearchTargetName = sAutoSearchTargetName;
             if (bEnableTeleport && CheckTeleportCondition(endPoint.SceneID))
             {
                 Tab_SceneClass sceneClass = TableManager.GetSceneClassByID(endPoint.SceneID, 0);
                 if (null != sceneClass)
                 {
                     MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{1644}", sceneClass.Name), "", DoTeleport);
                 }
             }
         }
     }
 }
Esempio n. 11
0
    void TransmitPointOnClicked(GameObject value)
    {
        //根据记录的点进行寻路
        AutoSearchPoint point = new AutoSearchPoint(m_EndSceneId, m_fPosX, m_fPosZ);

        if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
        {
            GameManager.gameManager.AutoSearch.ProcessAutoSearch(point, m_LabelRight.text);
            //如果成功,则设置目标名字等信息
            if (null != GameManager.gameManager.AutoSearch &&
                true == GameManager.gameManager.AutoSearch.IsAutoSearching)
            {
                if (null != SceneMapLogic.Instance())
                {
                    SceneMapLogic.Instance().CloseWindow();
                }
            }
        }
    }
Esempio n. 12
0
        public void AutoFightInFourVillain()
        {
            if (IsOpenAutoCombat == false)
            {
                return;
            }

            /*if (GameManager.gameManager.RunningScene != (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_FOURVILLAIN)
             * {
             *  return;
             * }*/
            if (m_FourVillainAutoCombatTargetPos == null)
            {
                return;
            }
            AutoSearchPoint point = new AutoSearchPoint(GameManager.gameManager.RunningScene, m_FourVillainAutoCombatTargetPos.x, m_FourVillainAutoCombatTargetPos.y);

            if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
            {
                BreakAutoCombatState();
                GameManager.gameManager.AutoSearch.ProcessAutoSearch(point);
            }
        }
Esempio n. 13
0
 public void UpdateAutoAnteMortem()
 {
     if (IsOpenAutoCombat == false)
     {
         return;
     }
     if (IsDie())
     {
         m_nAutoSceneId = GameManager.gameManager.RunningScene;
         m_AutoPos      = m_ObjTransform.position;
     }
     else
     {
         if (m_nAutoSceneId == GameManager.gameManager.RunningScene)
         {
             NavAgent.destination = m_AutoPos;
             AutoSearchPoint point = new AutoSearchPoint(m_nAutoSceneId, m_AutoPos.x, m_AutoPos.z);
             if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
             {
                 GameManager.gameManager.AutoSearch.ProcessAutoSearch(point);
             }
         }
     }
 }
Esempio n. 14
0
        //////////////////////////////////////////////////////////////////////////
        //系统设置
//         protected int m_nSystemNameBoard = 0;   //名字板
//         public int SystemNameBoard
//         {
//             get { return m_nSystemNameBoard; }
//             set { m_nSystemNameBoard = value; }
//         }
//         protected int m_nSystemMusic = 0;   //声音
//         public int SystemMusic
//         {
//             get { return m_nSystemMusic; }
//             set { m_nSystemMusic = value; }
//         }
//         protected int m_nSystemSoundEffect = 0;   //声效
//         public int SystemSoundEffect
//         {
//             get { return m_nSystemSoundEffect; }
//             set { m_nSystemSoundEffect = value; }
//         }
//         protected int m_nTableau = 0;   //图像
//         public int SystemTableau
//         {
//             get { return m_nTableau; }
//             set { m_nTableau = value; }
//         }
//         public void InitSystemInfo()
//         {
//             SystemNameBoard = PlayerPreferenceData.SystemNameBoard;
//             SystemMusic = PlayerPreferenceData.SystemMusic;
//             SystemSoundEffect = PlayerPreferenceData.SystemSoundEffect;
//             SystemTableau = PlayerPreferenceData.SystemTableau;
//
//             GameManager.gameManager.SoundManager.EnableBGM = !(SystemMusic == 1 ? true : false);
//             GameManager.gameManager.SoundManager.EnableSFX = !(SystemSoundEffect == 1 ? true : false);
//
//
        public void AutoFightInYanziwu()
        {
            if (IsOpenAutoCombat == false
                /*|| GameManager.gameManager.RunningScene != (int) Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_YANZIWU)*/
                )
            {
                return;
            }

            Vector3 targetPos = new Vector3();

            GameObject[] m_QinggongList = GameManager.gameManager.ActiveScene.QingGongPointList;
            if (m_QinggongList.Length < 0 || m_QinggongList.Length > 3)
            {
                return;
            }
            Vector2[] PointVector2 = new Vector2[3];
            PointVector2[0] = new Vector2(56.2f, 27.4f); //轻功点1 起跳点
            PointVector2[2] = new Vector2(41.5f, 50.9f); //轻功点2 起跳点
            PointVector2[1] = new Vector2(3.8f, 41.7f);  //轻功点3 起跳点
            if (m_QinggongList[1].activeInHierarchy)     //轻功点3开启表示 向区域四中心移动
            {
                targetPos.x = 18.5f;
                targetPos.z = 19.6f;
            }
            else if (m_QinggongList[2].activeInHierarchy) //轻功点2  向区域三中心移动
            {
                targetPos.x = 17.8f;
                targetPos.z = 51.2f;
            }
            else if (m_QinggongList[0].activeInHierarchy) //轻功点1  向区域二中心移动
            {
                targetPos.x = 54.5f;
                targetPos.z = 47.2f;
            }
            else //向区域一中心移动
            {
                targetPos.x = 55.0f;
                targetPos.z = 17.0f;
            }
            //Vector3 _vec3Tar = new Vector3(targetPos.x, Position.y, targetPos.z);
            //float fDis = Vector3.Distance(_vec3Tar, Position);
            //if (fDis > 16) //距离目标中心点过远 则改为向最近开启过的轻功点移动
            //{
            //    float fMinDis = 9999999.0f;
            //    int nSelePointId = -1;
            //    float fPointDis = -1;
            //    for (int i = 0; i < m_QinggongList.Length; i++)
            //    {
            //        if (m_QinggongList[i].activeInHierarchy)
            //        {
            //            if (Position.z > PointVector2[i].y)
            //            {
            //                continue; //不往回走
            //            }
            //            fPointDis = Vector3.Distance(new Vector3(PointVector2[i].x, Position.y, PointVector2[i].y), Position);
            //            if (fPointDis < fMinDis)
            //            {
            //                fMinDis = fPointDis;
            //                targetPos.x = PointVector2[i].x;
            //                targetPos.z = PointVector2[i].y;
            //            }
            //        }
            //    }
            //}
            AutoSearchPoint point = new AutoSearchPoint(GameManager.gameManager.RunningScene, targetPos.x, targetPos.z);

            if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
            {
                BreakAutoCombatState();
                GameManager.gameManager.AutoSearch.ProcessAutoSearch(point);
            }
        }
Esempio n. 15
0
    void LinkOnClick(GameObject obj)
    {
        int index = 0;

        if (obj != null && int.TryParse(obj.name, out index) && index >= 0 && index < m_LinkTypeList.Count)
        {
            m_LinkType = m_LinkTypeList[index];
        }

        if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_ITEM)
        {
            ItemTooltipsLogic.ShowItemTooltip(m_EquipOrItemLink, ItemTooltipsLogic.ShowType.ChatLink);
        }
        else if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_EQUIP)
        {
            EquipTooltipsLogic.ShowEquipTooltip(m_EquipOrItemLink, EquipTooltipsLogic.ShowType.ChatLink);
        }
        else if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_COPYTEAM)
        {
            //检查自己
            if (GameManager.gameManager.PlayerDataPool.IsHaveTeam())
            {
                Singleton <ObjManager> .GetInstance().MainPlayer.SendNoticMsg(false, "#{2179}");

                return;
            }
            //Singleton<ObjManager>.GetInstance().MainPlayer.SendNoticMsg(false, "#{2178}");
            //发送请求
            CG_REQ_TEAM_JOIN packet = (CG_REQ_TEAM_JOIN)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_TEAM_JOIN);
            packet.SetTeamMemberGuid(m_playerGUID);
            packet.SendPacket();
        }
        else if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_MOVETO)
        {
            AutoSearchPoint point = new AutoSearchPoint(m_MoveToLink.SceneClassID, m_MoveToLink.PosX, m_MoveToLink.PosZ);
            GameManager.gameManager.AutoSearch.ProcessAutoSearch(point);
        }
        else if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_SWORDSMAN)
        {
            //            SwordsManToolTipsLogic.ShowSwordsManTooltip(m_SwordsManLink, SwordsManToolTipsLogic.SwordsMan_ShowType.ChatLink);
        }
        else if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_PLAYERINFO)
        {
            if (null == Singleton <ObjManager> .GetInstance().MainPlayer)
            {
                return;
            }
            Singleton <ObjManager> .GetInstance().MainPlayer.ReqViewOtherPlayer(m_playerInfoGUID, OtherRoleViewLogic.OPEN_TYPE.OPEN_TYPE_LASTSPEAKER);
        }
        else if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_GUILDCRUITE)
        {
            //如果符合要求,则发送申请加入帮会的请求
            ApplyToJoinGuild();
        }
        else if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_HONGBAO)
        {
            CG_ASK_HONGBAO_ROB Pak = (CG_ASK_HONGBAO_ROB)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_HONGBAO_ROB);
            Pak.SetHongbaoguid(m_HongBaoInfoLink.m_HongBaoGuid);
            Pak.SetSenderguid(m_HongBaoInfoLink.m_SenderGuid);
            Pak.SendPacket();
        }
        else if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_PROPAGATE)
        {
            LogModule.DebugLog("m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_PROPAGATE  " + m_fellow.Name);
            ChatInfoLinkFellowTipLogic.ShowTooltips(m_fellow);
        }
        else if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_MISSION)
        {
            LogModule.DebugLog("m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_MISSION  " + m_missionLink.missionId);
            MissionTooltipsLogic.ShowTooltips(m_missionLink);
        }
        else if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_SUB_PROPAGATE)
        {
            LogModule.DebugLog("m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_SUB_PROPAGATE  ");
            if (null != ChatInfoLogic.Instance())
            {
                if (m_chatHistoryItem.SenderGuid == Singleton <ObjManager> .GetInstance().MainPlayer.GUID)
                {
                    Singleton <ObjManager> .GetInstance().MainPlayer.SendNoticMsg(false, "#{11054}");

                    return;
                }
                ChatInfoSelectLinkLogic.M_OPEN_TYPE = ChatInfoSelectLinkLogic.OPEN_TYPE.PROPAGATE;
                ChatInfoLogic.Instance().BeginChat(m_chatHistoryItem.SenderGuid, m_chatHistoryItem.SenderName);
                ChatInfoLogic.Instance().ShowEmotionRoot();
            }
        }
        else if (m_LinkType == GC_CHAT.LINKTYPE.LINK_TYPE_PROPAGATE_AGREE)
        {
            // do send add a team
            ReqAddTeam();
        }
        else
        {
            if (m_bNameLink)
            {
                if (Singleton <ObjManager> .GetInstance().MainPlayer == null)
                {
                    return;
                }

                if (m_playerGUID == GlobeVar.INVALID_GUID)
                {
                    return;
                }

                if (m_playerGUID == Singleton <ObjManager> .GetInstance().MainPlayer.GUID)
                {
                    return;
                }

                if (null == ChatInfoLogic.Instance())
                {
                    UIManager.ShowUI(UIInfo.ChatInfoRoot, ShowChatInfoRootOver);
                }
                else
                {
                    ChatInfoLogic.Instance().BeginChat(m_playerGUID, m_playerName);
                }
            }
        }
    }
Esempio n. 16
0
    //搜索路径算法,根据DJ算法生成最短路径
    public bool FindPath(AutoSearchPoint startPoint, AutoSearchPoint endPoint, ref AutoSearchPath autoSearchPath)
    {
        List <int> path = new List <int>();       //最后生成的最短路径图

        //统计所有节点,计算srcid的逆临街表,放在nodeMap中
        Dictionary <int, PathNodeInfo> nodeMap = new Dictionary <int, PathNodeInfo>();

        foreach (MapConnectPath connectPath in m_ConnectPath)
        {
            if (false == nodeMap.ContainsKey(connectPath.SrcSceneId))
            {
                PathNodeInfo info = new PathNodeInfo();
                info.sceneId  = connectPath.SrcSceneId;
                info.dis      = GetDisBySceneID(startPoint.SceneID, info.sceneId);
                info.prevNode = startPoint.SceneID;
                nodeMap.Add(info.sceneId, info);
            }

            if (false == nodeMap.ContainsKey(connectPath.DstSceneId))
            {
                PathNodeInfo info = new PathNodeInfo();
                info.sceneId  = connectPath.DstSceneId;
                info.dis      = GetDisBySceneID(startPoint.SceneID, info.sceneId);
                info.prevNode = startPoint.SceneID;
                nodeMap.Add(info.sceneId, info);
            }
        }

        List <int> openList  = new List <int>();
        List <int> closeList = new List <int>();

        //放入开始点
        openList.Add(startPoint.SceneID);

        while (openList.Count > 0)
        {
            int minPt  = openList[0];
            int minDis = m_nMinDistanceMaxValue;

            foreach (int openPoint in openList)
            {
                if (!nodeMap.ContainsKey(openPoint))
                {
                    continue;
                }

                if (nodeMap[openPoint].dis < minDis)
                {
                    minPt  = openPoint;
                    minDis = nodeMap[openPoint].dis;
                }
            }

            int minDisNode = minPt;
            openList.Remove(minDisNode);
            closeList.Add(minDisNode);

            //展开该节点,更新所有邻接表的距离,并把下一个(或几个)最短路径上的点放入openList。
            foreach (MapConnectPath connectPath in m_ConnectPath)
            {
                if (connectPath.SrcSceneId == minDisNode)
                {
                    int newDis = nodeMap[minDisNode].dis + GetDisBySceneID(minDisNode, connectPath.DstSceneId);
                    if (newDis < nodeMap[connectPath.DstSceneId].dis)
                    {
                        nodeMap[connectPath.DstSceneId].dis      = newDis;
                        nodeMap[connectPath.DstSceneId].prevNode = minDisNode;
                    }

                    if (!openList.Contains(connectPath.DstSceneId) && !closeList.Contains(connectPath.DstSceneId))
                    {
                        openList.Add(connectPath.DstSceneId);
                    }
                }
            }
        }


        if (!nodeMap.ContainsKey(endPoint.SceneID))
        {
            return(false);
        }

        //这里生成最短路径和下一个场景号,这里的邻接表已经记录了最短路径信息
        if (nodeMap[endPoint.SceneID].dis < m_nMinDistanceMaxValue)
        {
            path.Insert(0, endPoint.SceneID);
            int backId = nodeMap[endPoint.SceneID].prevNode;
            while (backId != -1)
            {
                if (backId == startPoint.SceneID)
                {
                    //int nextScn = path[0];
                    path.Insert(0, backId);
                    break;
                }

                path.Insert(0, backId);
                backId = nodeMap[backId].prevNode;
            }
        }

        if (path.Count > 1)
        {
            //生成路径
            int beginScene = path[0];
            int endScene   = -1;
            for (int i = 1; i < path.Count; ++i)
            {
                endScene = path[i];
                foreach (MapConnectPath connectPath in m_ConnectPath)
                {
                    if (connectPath.SrcSceneId == beginScene && connectPath.DstSceneId == endScene)
                    {
                        AutoSearchPoint point = new AutoSearchPoint(connectPath.SrcSceneId, connectPath.TelePosX, connectPath.TelePosZ);
                        autoSearchPath.AutoSearchPosCache.Add(point);

                        beginScene = endScene;
                    }
                }
            }

            //最后加入目标点
            autoSearchPath.AutoSearchPosCache.Add(endPoint);
            return(true);
        }

        return(false);
    }
Esempio n. 17
0
    void UpdateMap()
    {
        if (!m_bLoadMap)
        {
            return;
        }

        Obj_MainPlayer curPlayer = Singleton <ObjManager> .GetInstance().MainPlayer;

        if (null == curPlayer)
        {
            return;
        }

        arrowPos = GetMapPos(curPlayer.transform.position);
        ObjArrow.transform.localPosition = arrowPos;

        arrowRot.z = -curPlayer.transform.localRotation.eulerAngles.y;
        ObjArrow.transform.rotation = Quaternion.Euler(arrowRot);

        mapPos.x = Mathf.Min(-MapScreenHalfWidth, Mathf.Max(-arrowPos.x, MapScreenHalfWidth - m_mapTexWidth));
        mapPos.y = Mathf.Min(-MapScreenHalfHeight, Mathf.Max(-arrowPos.y, MapScreenHalfHeight - m_mapTexHeight));
        MapClip.transform.localPosition = mapPos;

        if (null != LabelPos)
        {
            LabelPos.text = ((int)curPlayer.transform.position.x).ToString() + ", " + ((int)curPlayer.transform.position.z).ToString();
        }

        if (GameManager.gameManager && GameManager.gameManager.AutoSearch && GameManager.gameManager.AutoSearch.IsAutoSearching)
        {
            AutoSearchPath path = GameManager.gameManager.AutoSearch.Path;
            if (path.AutoSearchPosCache.Count > 0)
            {
                AutoSearchPoint lastPoint = path.AutoSearchPosCache[path.AutoSearchPosCache.Count - 1];
                if (lastPoint.SceneID == GameManager.gameManager.RunningScene)
                {
                    TexTarget.transform.localPosition = GetMapPos(lastPoint.PosX, lastPoint.PosZ);
                }
            }
        }
        else
        {
            TexTarget.transform.localPosition = GetMapPos(100000, 10000);
        }



        int curFriendCount  = 0;
        int curNeutralCount = 0;
        int curEnemyCount   = 0;
        int curOtherCount   = 0;

        foreach (Obj curObj in Singleton <ObjManager> .GetInstance().ObjPools.Values)
        {
            //MainPlayer在前面设置过位置,伙伴不显示,所以这两个排除
            if (curObj.ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_MAIN_PLAYER || curObj.ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_FELLOW)
            {
                continue;
            }

            //只显示如下三种类型
            if (curObj.ObjType != Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_CHARACTER &&
                curObj.ObjType != Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_NPC &&
                curObj.ObjType != Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER)
            {
                continue;
            }

            Obj_Character curChar = curObj as Obj_Character;
            if (null == curChar)
            {
                continue;
            }

            if (curObj.ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_NPC)
            {
                if (Singleton <ObjManager> .GetInstance().DeleteNPCList != null)
                {
                    if (Singleton <ObjManager> .GetInstance().DeleteNPCList.ContainsKey(curObj.ServerID.ToString()))
                    {
                        continue;
                    }
                }
            }

            float xPosDiff = curChar.transform.localPosition.x - curPlayer.transform.localPosition.x;
            float yPosDiff = curChar.transform.localPosition.z - curPlayer.transform.localPosition.z;

            if (Mathf.Abs(xPosDiff) * m_scale > MapScreenHalfWidth || Mathf.Abs(yPosDiff) * m_scale > MapScreenHalfHeight)
            {
                continue;
            }

            CharacterDefine.REPUTATION_TYPE type = Reputation.GetObjReputionType(curChar);
            if (CharacterDefine.REPUTATION_TYPE.REPUTATION_FRIEND == type)
            {
                AddDotToList(TexListFriend, curFriendCount, FriendPoint, curObj.gameObject, CharacterDefine.NPC_COLOR_FRIEND);
                curFriendCount++;
            }
            else if (CharacterDefine.REPUTATION_TYPE.REPUTATION_NEUTRAL == type)
            {
                AddDotToList(TexListNeutral, curNeutralCount, NeutralPoint, curObj.gameObject, CharacterDefine.NPC_COLOR_NEUTRAL);
                curNeutralCount++;
            }
            else if (CharacterDefine.REPUTATION_TYPE.REPUTATION_HOSTILE == type)
            {
                AddDotToList(TexListEnemy, curEnemyCount, EnemyPoint, curObj.gameObject, CharacterDefine.NPC_COLOR_ENEMY);
                curEnemyCount++;
            }
            else
            {
                AddDotToList(TexListOther, curOtherCount, OtherPoint, curObj.gameObject, Color.white);
                curOtherCount++;
            }
        }

        DeActiveList(curFriendCount, TexListFriend, arrowPos);
        DeActiveList(curNeutralCount, TexListNeutral, arrowPos);
        DeActiveList(curEnemyCount, TexListEnemy, arrowPos);
        DeActiveList(curOtherCount, TexListOther, arrowPos);
    }