Пример #1
0
        private static void LoadScene(string levelName)
        {
            var path = PhyConfiguration.GetValue("ModDir");

            string[] searchPath =
            {
                "",
                "downloaded",
                string.Format(@"../{0}_schinese",           path),
                string.Format(@"../{0}_schinese/downloaded",path)
            };
            string filePath = null;

            foreach (var i in searchPath)
            {
                filePath = Path.Combine(path, i, levelName);
                if (File.Exists(filePath))
                {
                    Debug.LogLine("Load map {0}", filePath);

                    var bspLoader = new BspLoader(filePath);

                    _kinematicsManager?.Clear();
                    _kinematicsManager = new KinematicsManager(bspLoader.Models);
                    _sceneStaticObjects.Add(BulletHelper.CreateStaticBody(Matrix.Translation(0, 0, 0),
                                                                          new BvhTriangleMeshShape(bspLoader.Models[0], true),
                                                                          BWorld.Instance));
                    return;
                }
            }
            throw new FileNotFoundException(string.Format("Cannot found map file {0} on these paths: {1}",
                                                          levelName,
                                                          "\n" + string.Join("\n", searchPath)));
        }