示例#1
0
文件: World.cs 项目: thormme/Chimera
        public void AddLevelFromFile(String mapName, Vector3 position, Quaternion orientation, Vector3 scale)
        {
            if (!mapName.Contains(".lvl"))
            {
                mapName += ".lvl";
            }

            FileInfo fileInfo = new FileInfo(mapName);
            Tuple<Level, List<DummyObject>> newLevel = LevelFileLoader.LoadLevelFromFile(fileInfo);
            List<DummyObject> objects = newLevel.Item2;

            foreach (DummyObject dummy in objects)
            {
                if (dummy.Type == "Root")
                {
                    continue;
                }
                Type type = Type.GetType(dummy.Type);

                if (type != null)
                {
                    Quaternion objectOrientation = dummy.Rotation;
                    object[] parameters = new object[5];
                    parameters[0] = dummy.Model;
                    parameters[1] = Vector3.Multiply(dummy.Position, scale) + position;
                    parameters[2] = Quaternion.Concatenate(orientation, objectOrientation);
                    parameters[3] = Vector3.Multiply(dummy.Scale, scale);
                    parameters[4] = dummy.Parameters;
                    object obj = Activator.CreateInstance(type, parameters);

                    if (obj is IGameObject)
                    {
                        Add(obj as IGameObject);
                    }

                    CheckSpecialObject(obj);
                }
            }

            Level level = newLevel.Item1;
            level.AddBlocksToWorld(mUncommittedGameObjectAdditions);

            SkyBox skydome = new SkyBox("default");
            Add(skydome);

            LevelTheme = SoundManager.LookupSound("dragonRoostIsland").CreateInstance();
            LevelTheme.IsLooped = true;
            LevelTheme.Play();
        }
示例#2
0
        public void New()
        {
            if (mLevel != null)
            {
                AssetLibrary.ClearHeightMaps();
                mLevel.IterateOverEveryBlock(RemoveBlockFromSpace, new object[] { Space });
            }

            mName = "default";
            mLevel = new ModifiableLevel(LevelFileLoader.GenerateNewLevel(mName, "default_terrain_detail"), Space);

            FileInfo fileInfo = new FileInfo(mName);

            mLevel.IterateOverEveryBlock(AddBlockToSpace, new object[] { Space });

            mSkyBox = new SkyBox("default");
            mWater = new Water("waterTexture", 0.1f);
        }