示例#1
0
        //-------------------------------------------------------------------------------------------------------

        /**
         * @brief 屏幕点击位置转换到场景坐标
         * @param pos 屏幕位置
         * @param scenePos 场景位置
         */
        public bool GetScenePos(Vector2 pos, out Engine.TerrainInfo terrainInfo)
        {
            terrainInfo = null;
            Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
            if (rs == null)
            {
                return(false);
            }

            // 再计算移动速度
            Engine.IScene scene = rs.GetActiveScene();
            if (scene == null)
            {
                return(false);
            }

            return(scene.GetPickupPos(pos, out terrainInfo));
        }
示例#2
0
        //-------------------------------------------------------------------------------------------------------

        /**
         * @brief 添加草扰动力
         * @param pos 力中心点位置
         * @param fForce 力大小
         * @param fRadius 力影响范围
         */
        public void AddGrassWaveForce(Vector3 pos, float fForce, float fRadius)
        {
            if (!m_bGrassForce)
            {
                return;
            }

            Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
            if (rs == null)
            {
                return;
            }

            // 再计算移动速度
            Engine.IScene scene = rs.GetActiveScene();
            if (scene == null)
            {
                return;
            }

            scene.AddGrassWaveForce(pos, fForce, fRadius);
        }
示例#3
0
        public void Update(float dt)
        {
            if (m_ClientGlobal.MainPlayer == null)
            {
                return;
            }

            if (m_enterZoneEvent != null)
            {
                Client.IEntity mainPlayer = m_ClientGlobal.MainPlayer;
                if (mainPlayer != null)
                {
                    int zoneid = this.IsEnterZone(mainPlayer.GetPos());
                    if (zoneid != -1)
                    {
                        m_enterZoneEvent(zoneid);
                    }
                }
            }

            // 检测遮挡物
            Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
            if (rs == null)
            {
                return;
            }

            // 再计算移动速度
            Engine.IScene scene = rs.GetActiveScene();
            if (scene == null)
            {
                return;
            }

            scene.CheckOcclusion(m_ClientGlobal.MainPlayer.GetPos());
        }
示例#4
0
        public float GetTerrainHeight(Vector3 pos)
        {
            Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
            if (rs == null)
            {
                return(0.0f);
            }

            // 再计算移动速度
            Engine.IScene curScene = rs.GetActiveScene();
            if (curScene == null)
            {
                return(0.0f);
            }


            Engine.TerrainInfo info;
            if (!curScene.GetTerrainInfo(ref pos, out info))
            {
                return(0.0f);
            }

            return(info.pos.y);
        }
示例#5
0
        //-------------------------------------------------------------------------------------------------------

        /**
         * @brief 进入地图
         * @param nMapID 地图ID
         */
        public void EnterMap(uint nMapID, Vector3 pos)
        {
            // 读取地图配置表
            Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
            Engine.Utility.Log.Info("EnterMapStart");
            if (rs != null)
            {
                if (nMapID == mapID)
                {
                    return;
                }

                Engine.Utility.Log.Info("EnterMapStart mapID");
                // 停止背景音乐
                Engine.IAudio audio = Engine.RareEngine.Instance().GetAudio();
                if (audio != null)
                {
                    audio.StopMusic();
                }

                // 离开当前场景
                Process = 0f;
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ENTITYSYSTEM_LEAVEMAP, mapID);
                //进入下一个地图
                Engine.Utility.Log.Info("EnterMapStart 离开当前场景");
                table.MapDataBase mapDB = GameTableManager.Instance.GetTableItem <table.MapDataBase>(nMapID);
                if (mapDB == null)
                {
                    Engine.Utility.Log.Error("MapSystem:找不到地图配置数据{0}", nMapID);
                    return;
                }
                Engine.Utility.Log.Info("EnterMapStart 离开当前场景 table.MapDataBase mapDB ");
                table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(mapDB.dwResPath);
                if (resDB == null)
                {
                    Engine.Utility.Log.Error("MapSystem:找不到地图资源路径配置{0}", mapDB.dwResPath);
                    return;
                }
                temptime = Time.realtimeSinceStartup;
                lastInfo = "none";
                // 创建寻路模块
                mapID = nMapID;
                // 预加载
                mapName = mapDB.strName;// string.Format("{0}({1})", mapDB.strName, uCountryid);

                // 不是中转空场景
                if (nMapID != GameTableManager.Instance.GetClientGlobalConst <int>("map", "emptyid"))
                {
                    Engine.Utility.Log.Info("EnterMapStart 读取地图配置表 ");
                    // 读取地图配置表
                    string strMapName = resDB.strPath.ToLower();
                    m_strMapTexturePath = strMapName.Replace(".map", "").Substring(strMapName.LastIndexOf('/') + 1);
                    Engine.IScene scene = rs.EnterScene(ref strMapName, this);
                    if (scene != null)
                    {
                        scene.StartLoad(pos);
                    }

                    Engine.Utility.Log.Info("EnterMapStart EnterScene name:{0} ", strMapName);
                    // 场景npc配置
                    LoadClientMap(mapDB.miniMapInfo.ToLower());

                    //LoadClienMapArea(strMapName.ToLower().Replace(".map", ".ar"));

                    //SpanUtil.Start();
                    //if (Application.platform == RuntimePlatform.WindowsEditor)
                    //{
                    Profiler.BeginSample("LoadARFile");
                    MapAreaDisplay.Instance.LoadARFile(strMapName.ToLower().Replace(".map", ".ar"));
                    Profiler.EndSample();
                    //}
                    //SpanUtil.Stop(strMapName + "  ar  ");

                    string strMPSName = strMapName.Replace(".map", ".mps").ToLower();
                    // 读取地表障碍信息
                    LoadObstacle(strMPSName);
                    //SpanUtil.Stop(strMapName + "  地表障碍信息  ");
                }
            }
            else
            {
                Engine.Utility.Log.Error("MapSystem:IRenderSystem为空");
            }
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)(int)Client.GameEventID.ENTITYSYSTEM_ENTERMAP, mapID);
        }