Beispiel #1
0
 public void Render(GraphicsDevice device, TileEffect effect)
 {
     _model.Render(device, effect, Tint);
 }
Beispiel #2
0
        public void OnEnter()
        {
            // setup
            SpriteSheetFactory.Initialize(GameInstance.Content);
            HardcodedAnimations.CreateAnimations();

            // music
            MusicManager.PlayMusic("music/e1m1", true);

            // fonts
            FloatingTexts = new List<TimedText>();
            DamageFont = GameInstance.Content.Load<SpriteFont>("fonts/Doom12");

            // camera
            float aspectRatio = (float)GameInstance.Window.ClientBounds.Width / GameInstance.Window.ClientBounds.Height;
            Camera = new Camera("camera", new Vector3(0, 210f, 0), new Vector3(180f, 130f, 216f), Vector3.Up,
                                aspectRatio);
            MessagingSystem.Subscribe(Camera.MoveCamera, DoomEventType.CameraMoveEvent, "camera", null);
            MessagingSystem.Subscribe(OnChargeTimeReached, DoomEventType.ChargeTimeReached, "gamestate", null);
            MessagingSystem.Subscribe(OnActorSpawn, DoomEventType.SpawnActor, "gamestate", null);
            MessagingSystem.Subscribe(OnActorDespawn, DoomEventType.DespawnActor, "gamestate", null);
            MessagingSystem.Subscribe(OnRemoveActorFromTile, DoomEventType.RemoveFromCurrentTile, "gamestate", null);
            MessagingSystem.Subscribe(OnDisplayDamage, DoomEventType.DisplayDamage, "gamestate", null);
            MessagingSystem.Subscribe(OnDespawnText, DoomEventType.DespawnText, "gamestate", null);
            MessagingSystem.Subscribe(OnActorDeath, DoomEventType.ActorDied, "gamestate", null);

            Effect = new TileEffect(GameInstance.Content);

            CreateLevelTemp(GameInstance.Content);

            SpriteBatch = new SpriteBatch(GameInstance.GraphicsDevice);
            SpriteEffect = new BasicEffect(GameInstance.GraphicsDevice);
            AlphaTestEffect = new AlphaTestEffect(GameInstance.GraphicsDevice);
            TextEffect = new AlphaTestEffect(GameInstance.GraphicsDevice);
        }
Beispiel #3
0
        public void Render(GraphicsDevice device, TileEffect effect, Vector4 tint)
        {
            using (var buffer = new VertexBuffer(
                device,
                VertexPositionNormalTexture.VertexDeclaration,
                NumVertexes,
                BufferUsage.WriteOnly))
            {

                // Load the buffer
                buffer.SetData(_vertexes);

                // Send the vertex buffer to the device
                device.SetVertexBuffer(buffer);

                // top
                foreach (EffectPass pass in effect.GetEffect().CurrentTechnique.Passes)
                {
                    effect.Texture = _tileTextures.Top;
                    pass.Apply();
                    device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
                }

                if (tint != DefaultTint)
                {
                    foreach (EffectPass pass in effect.GetEffect().CurrentTechnique.Passes)
                    {
                        effect.Texture = _tileTextures.Top;
                        effect.Tint = tint;
                        pass.Apply();
                        device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
                    }

                    effect.Tint = DefaultTint;
                }

                // north
                foreach (EffectPass pass in effect.GetEffect().CurrentTechnique.Passes)
                {
                    effect.Texture = _tileTextures.North;
                    pass.Apply();
                    device.DrawPrimitives(PrimitiveType.TriangleList, 6, 2);
                }

                // south
                foreach (EffectPass pass in effect.GetEffect().CurrentTechnique.Passes)
                {
                    effect.Texture = _tileTextures.South;
                    pass.Apply();
                    device.DrawPrimitives(PrimitiveType.TriangleList, 12, 2);
                }

                // east
                foreach (EffectPass pass in effect.GetEffect().CurrentTechnique.Passes)
                {
                    effect.Texture = _tileTextures.East;
                    pass.Apply();
                    device.DrawPrimitives(PrimitiveType.TriangleList, 18, 2);
                }

                // west
                foreach (EffectPass pass in effect.GetEffect().CurrentTechnique.Passes)
                {
                    effect.Texture = _tileTextures.West;
                    pass.Apply();
                    device.DrawPrimitives(PrimitiveType.TriangleList, 24, 2);
                }
            }
        }