Exemplo n.º 1
0
        protected override void Initialize()
        {
            this.screen = _Screen.GetInstance();
            this.screen.SetWidth(graphics.PreferredBackBufferWidth);
            this.screen.SetHeight(graphics.PreferredBackBufferHeight);

            this.camera = new _Camera();

            this.grassTexture     = Content.Load <Texture2D>(@"Textures\grass-texture");
            this.grayPaintTexture = Content.Load <Texture2D>(@"Textures\gray-paint-texture");
            this.redPaintTexture  = Content.Load <Texture2D>(@"Textures\red-paint-texture");
            this.woodTexture      = Content.Load <Texture2D>(@"Textures\wood-texture");
            this.treeTexture      = Content.Load <Texture2D>(@"Textures\tree-texture");

            this.snowGrassTexture     = Content.Load <Texture2D>(@"Textures\snow-grass-texture");
            this.snowGrayPaintTexture = Content.Load <Texture2D>(@"Textures\snow-gray-paint-texture");
            this.snowRedPaintTexture  = Content.Load <Texture2D>(@"Textures\snow-red-paint-texture");
            this.snowWoodTexture      = Content.Load <Texture2D>(@"Textures\snow-wood-texture");
            this.snowTreeTexture      = Content.Load <Texture2D>(@"Textures\snow-tree-texture");

            this.heightMapTexture = Content.Load <Texture2D>(@"Textures\HeightMap\HMGround-texture");
            this.seaTexture       = Content.Load <Texture2D>(@"Textures\sea-texture");

            this.snowEffect = Content.Load <Effect>(@"Effects\snow-effect");
            seaEffect       = Content.Load <Effect>(@"Effects\sea-effect");
            add             = 0.001f;

            GraphicsDevice.RasterizerState = RasterizerState.CullNone;

            base.Initialize();
        }
Exemplo n.º 2
0
 public void Draw(_Camera camera)
 {
     foreach (_Tree t in treeList)
     {
         t.Draw(camera);
     }
 }
Exemplo n.º 3
0
        public _Tree(GraphicsDevice device, Vector3 position, Game game, _Camera camera, Texture2D texture, Effect effect, Texture2D snowTexture)
        {
            this.device      = device;
            this.world       = Matrix.Identity;
            this.position    = position;
            this.texture     = texture;
            this.snowTexture = snowTexture;
            this.effect      = effect;
            this.camera      = camera;

            this.verts = new VertexPositionTexture[]
            {
                new VertexPositionTexture(new Vector3(-2, 2, 0), Vector2.Zero),
                new VertexPositionTexture(new Vector3(2, 2, 0), Vector2.UnitX),
                new VertexPositionTexture(new Vector3(-2, -2, 0), Vector2.UnitY),
                new VertexPositionTexture(new Vector3(2, -2, 0), Vector2.One),
            };

            this.buffer = new VertexBuffer(this.device, typeof(VertexPositionTexture), this.verts.Length, BufferUsage.None);
            this.buffer.SetData <VertexPositionTexture>(this.verts);

            this.index = new short[]
            {
                0, 1, 2,
                1, 3, 2,
            };
            this.iBuffer = new IndexBuffer(this.device, IndexElementSize.SixteenBits, this.index.Length, BufferUsage.None);
            this.iBuffer.SetData <short>(this.index);
        }
Exemplo n.º 4
0
        public void Draw(_Camera camera)
        {
            this.device.SetVertexBuffer(this.buffer);

            this.effect.CurrentTechnique = effect.Techniques["Technique1"];
            effect.Parameters["World"].SetValue(world);
            effect.Parameters["View"].SetValue(camera.GetView());
            effect.Parameters["Projection"].SetValue(camera.GetProjection());
            effect.Parameters["colorTexture"].SetValue(texture);
            effect.Parameters["colorTextureSnow"].SetValue(this.snowTexture);
            effect.Parameters["counter"].SetValue(counter);

            foreach (EffectPass pass in this.effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                this.device.DrawUserPrimitives <VertexPositionTexture>(PrimitiveType.TriangleList, this.verts, 0, this.verts.Length / 3);
            }
        }
Exemplo n.º 5
0
        public void Draw(_Camera camera)
        {
            this.device.SetVertexBuffer(this.buffer);
            this.device.BlendState = BlendState.AlphaBlend;
            this.device.Indices    = this.iBuffer;

            this.effect.CurrentTechnique = effect.Techniques["Technique1"];
            this.effect.Parameters["World"].SetValue(world);
            this.effect.Parameters["View"].SetValue(camera.GetView());
            this.effect.Parameters["Projection"].SetValue(camera.GetProjection());
            this.effect.Parameters["time"].SetValue(this.time);
            this.effect.Parameters["colorTexture"].SetValue(seaTexture);

            foreach (EffectPass pass in this.effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                //device.DrawUserIndexedPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, this.verts, 0, this.verts.Length, this.index, 0, 2);
                device.DrawUserIndexedPrimitives <VertexPositionTexture>(PrimitiveType.TriangleList, this.verts, 0, verts.Length, this.indexes, 0, this.indexes.Length / 3);
            }
        }
Exemplo n.º 6
0
        public _TreeManager(GraphicsDevice device, Game game, _Camera camera, Vector3 position, int column, int line, Texture2D treeTexture, Effect effect, Texture2D snowTreeTexture)
        {
            this.device          = device;
            this.world           = Matrix.Identity;
            this.game            = game;
            this.treeTexture     = treeTexture;
            this.snowTreeTexture = snowTreeTexture;
            this.effect          = effect;
            this.column          = column;
            this.line            = line;
            this.camera          = camera;
            this.position        = position;

            for (int c = 0; c < column; c++)
            {
                for (int l = 0; l < line; l++)
                {
                    x = 20 - c * 4;
                    z = -3 - l * 7;
                    treeList.Add(new _Tree(device, new Vector3(x, 2, z), game, camera, treeTexture, effect, snowTreeTexture));
                }
            }
        }
Exemplo n.º 7
0
        public void Draw(_Camera camera)
        {
            this.effect.CurrentTechnique = this.effect.Techniques["Technique1"];
            this.effect.Parameters["World"].SetValue(this.world);
            this.effect.Parameters["View"].SetValue(camera.GetView());
            this.effect.Parameters["Projection"].SetValue(camera.GetProjection());
            this.effect.Parameters["colorTexture"].SetValue(this.grassTexture);
            this.effect.Parameters["colorTextureSnow"].SetValue(this.snowGrassTexture);
            this.effect.Parameters["counter"].SetValue(counter);

            foreach (EffectPass pass in this.effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                this.device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList,
                                                      this.verts,
                                                      0,
                                                      this.verts.Length,
                                                      this.indexes,
                                                      0,
                                                      this.indexes.Length / 3);
            }
        }