コード例 #1
0
ファイル: MainEntry.cs プロジェクト: minime100/ProjectBee
        public MainGame()
        {
            levelParser = new LevelParser();
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            activeLevel = levelParser.LoadLevel("test");

            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 600;
        }
コード例 #2
0
ファイル: LevelParser.cs プロジェクト: minime100/ProjectBee
        private Level Parse(XmlLevel toParse)
        {
            Level parsed = new Level();

            parsed.AmbientLight = new Vector4(toParse.ambientLightColor.red, toParse.ambientLightColor.blue,
                toParse.ambientLightColor.blue, toParse.ambientLightIntensity);

            parsed.Lights = new List<LightSource>();
            foreach (XmlLightSource lightSource in toParse.lightSources)
            {
                LightSource parsedLightSource = new LightSource();

                parsedLightSource.Light = new Vector4(lightSource.color.red, lightSource.color.green,
                    lightSource.color.blue, lightSource.lightIntensity);
                parsedLightSource.PositionInWorld = new Vector4(lightSource.position.x,
                    lightSource.position.y, lightSource.position.z, lightSource.position.w);

                parsed.Lights.Add(parsedLightSource);
            }

            parsed.gameObjects = new List<GameObject>();
            foreach (XmlGameObject gameObject in toParse.gameObjects)
            {
                GameObject parsedObject = new GameObject();

                // TODO error handling
                parsedObject.ObjectModelContentName = gameObject.model;

                parsedObject.PositionInWorld = new Vector3(gameObject.position.x,
                    gameObject.position.y, gameObject.position.z);

                parsedObject.RotationAxis = new Vector3(gameObject.rotationAxis.x,
                    gameObject.rotationAxis.y, gameObject.rotationAxis.z);

                parsedObject.ScalingInWorld = gameObject.scaling;

                parsedObject.World = Matrix.Identity;

                parsed.gameObjects.Add(parsedObject);
            }

            return parsed;
        }