Ejemplo n.º 1
0
        public bool LoadNavMesh(string mapName)
        {
            bool   retCode = false;
            string path    = ConfigFileDir + mapName + ".bytes";

            NavMeshInfo navInfo = MapMgr.Inst().GetNavMeshInfo(mapName);

            if (navInfo == null)
            {
                retCode = LoadNavMeshByJsonFile(path, ref m_MapNavMesh);
                if (MapNavMesh == null || retCode == false)
                {
                    Console.WriteLine("LoadNavMeshByJsonFile {0} failed", path);
                    return(false);
                }

                m_MapNavMeshQuery = new NavMeshQuery();

                m_MapNavMeshQuery.Init(MapNavMesh, (int)MapDefine.MAX_NAV_POLYS);

                NavMeshInfo newNavInfo = new NavMeshInfo();
                newNavInfo.pdtNavMesh      = MapNavMesh;
                newNavInfo.pdtNavMeshQuery = MapNavMeshQuery;

                MapMgr.Inst().AddNavMeshInfo(mapName, newNavInfo);
            }
            else
            {
                m_MapNavMesh      = navInfo.pdtNavMesh;
                m_MapNavMeshQuery = navInfo.pdtNavMeshQuery;
            }

            return(true);
        }
Ejemplo n.º 2
0
        public Scene CreateScene(uint mapId)
        {
            uint sceneId = mapId;
            Map  map     = MapMgr.Inst().GetMap(mapId);

            if (map == null)
            {
                Console.WriteLine("CreateScene failed! mapId:{0} is not exist", mapId);
                return(null);
            }

            if (map.MapType != (uint)MapMainType.DYNAMIC_MAP && map.MapType != (uint)MapMainType.NONE_MAP)
            {
                sceneId = mapId;
            }
            else
            {
                return(null);
            }

            Scene scene = new Scene();
            bool  ret   = scene.Init(mapId, sceneId);

            if (ret == false)
            {
                Console.WriteLine("CreateScene failed! scene Init failed");
                return(null);
            }

            MapScenes.Add(sceneId, scene);

            Console.WriteLine("create Scene:{0} -- {0}", scene.SceneId, scene.MapId);
            return(scene);
        }
Ejemplo n.º 3
0
 public static MapMgr Inst()
 {
     if (_Inst == null)
     {
         _Inst = new MapMgr();
     }
     return(_Inst);
 }
Ejemplo n.º 4
0
 public bool Init()
 {
     foreach (KeyValuePair <uint, Map> item in MapMgr.Inst().MapInfoDict)
     {
         Map map = item.Value;
         if (map.MapId > 0 && map.MapConfig.mapType > 0)
         {
             CreateScene(map.MapId);
         }
     }
     return(true);
 }
Ejemplo n.º 5
0
        public virtual bool Init(UInt32 mapId, UInt32 sceneId)
        {
            m_MapScenePlayer.Clear();
            m_MapSceneOtherCreature.Clear();
            m_Grid9Manager.Clear();

            Map = MapMgr.Inst().GetMap(mapId);
            if (Map == null)
            {
                return(false);
            }

            Grid9Manager.InitGridSize(Map.Width, Map.Height);

            MapId   = mapId;
            SceneId = sceneId;

            return(true);
        }