Esempio n. 1
0
        public Deathmatch()
            : base()
        {
            Projectiles = new List<Projectile>();
            BackgroundImages = new List<Sprite>();
            BackgroundImagesFar = new List<Sprite>();
            BackgroundTracks = new List<Sprite>();
            BackgroundGameObjects = new List<GameObject>();
            Players = new List<Actor>();
            Mailman = new ClientMailman(this);

            shader = new RenderStates(new Shader(null, "Content/bgPrlx.frag"));
            Image mapImg = new Image("Content/mapCol.png");
            mapBytes = mapImg.Pixels;
            mapSprite = new Sprite(new Texture(mapImg));
            mapWidth = (int)mapImg.Size.X;
            mapHeight = (int)mapImg.Size.Y;

            player = new ClientPlayer(this);
            player.Pos = new Vector2f(46, 62);
            Players.Add(player);

            trainSoundExterior = new SoundInstance(Content.GetSound("trainSpeed2.wav"), 1f, 0, 15, true);
            trainSoundInterior = new SoundInstance(Content.GetSound("trainSpeed0.wav"), 1, 0, 15, true);
            trainSound = trainSoundExterior;

            MainGame.Camera.Center = player.Pos - new Vector2f(0, 90);
        }
Esempio n. 2
0
        public override void Draw()
        {
            base.Draw();
            //MainGame.Camera.Center = player.Pos - new Vector2f(0,90);

            Vector2f focus = player.Core +
                new Vector2f(Input.screenMousePos.X - MainGame.WindowSize.X / 2,
                Input.screenMousePos.Y - MainGame.WindowSize.Y / 2) * player.CrosshairCameraRatio;

            if (Helper.Distance(player.Core, focus) > PlayerAimSphereRadius)
                focus = player.Core + Helper.PolarToVector2(PlayerAimSphereRadius, player.AimAngle, 1, 1);//player.Core + Helper.normalize(focus) * 100;

            Helper.MoveCameraTo(MainGame.Camera, focus, .04f);

            if (MainGame.Camera.Center.Y > 180 - 90)
            {
                focus.Y = player.Pos.Y - 90;
                MainGame.Camera.Center = new Vector2f(MainGame.Camera.Center.X, 180 - 90);
            }

            //Camera2D.returnCamera(player.ActorCenter +
            //            new Vector2(Main.screenMousePos.X - Main.graphics.PreferredBackBufferWidth / 2,
            //                Main.screenMousePos.Y - Main.graphics.PreferredBackBufferHeight / 2) *
            //                Main.graphics.GraphicsDevice.Viewport.AspectRatio / player.currentWeapon.viewDistance);

            MainGame.window.SetView(MainGame.window.DefaultView);
            shader.Shader.SetParameter("offsetY", MainGame.Camera.Center.Y);
            RectangleShape rs = new RectangleShape
            {
                Size = new Vector2f(800, 600)
            };
            MainGame.window.Draw(rs, shader);
            MainGame.window.SetView(MainGame.Camera);

            //foreach (Sprite s in BackgroundImagesFar)
            //{
            //    s.Position = new Vector2f(s.Position.X, 280 - MAPYOFFSET + (player.Pos.Y / 15));
            //}

            BackgroundImagesFar.ForEach(p => { p.Draw(MainGame.window, RenderStates.Default); });
            BackgroundImages.ForEach(p => { p.Draw(MainGame.window, RenderStates.Default); });
            BackgroundGameObjects.ForEach(p => { p.Draw(); });
            BackgroundTracks.ForEach(p => { p.Draw(MainGame.window, RenderStates.Default); });
            HandleBackground();

            MainGame.window.Draw(new Sprite(Content.GetTexture("mapDecor.png")));
            int insideY = 65;

            if (player.Pos.Y > insideY)
            {
                //trainSoundExterior.volume = 1;
                trainSound = trainSoundExterior;
                // trainSoundInterior.volume = 0;
                interiorAlpha += (255f - interiorAlpha) * .1f;
            }
            else
            {
                //trainSoundInterior.volume = 0;
                interiorAlpha *= .95f;
                //trainSound = trainSoundInterior;
                //trainSoundExterior.volume = 0;
            }
            Render.Draw(Content.GetTexture("mapInterior.png"), new Vector2f(0, 0), new Color(255, 255, 255, (byte)interiorAlpha), new Vector2f(0, 0), 1, 0f);
            // MainGame.window.Draw(new Sprite(Content.GetTexture("mapInterior.png")));

            Players.ForEach(p => { p.Draw(); });
            Projectiles.ForEach(p => { p.Draw(); });
            GameObjects.ForEach(p => { p.Draw(); });

            if (player.Pos.Y < insideY)
                Render.Draw(Content.GetTexture("mapDecor.png"), new Vector2f(0, 0), new Color(255, 255, 255, (byte)(255 - interiorAlpha)), new Vector2f(0, 0), 1, 0f);
            //MainGame.window.Draw(mapSprite);
            Gui.Draw();
        }
Esempio n. 3
0
        public override void Draw()
        {
            base.Draw();
            //MainGame.Camera.Center = player.Pos - new Vector2f(0,90);


            Vector2f focus = player.Core +
                             new Vector2f(Input.screenMousePos.X - MainGame.WindowSize.X / 2,
                                          Input.screenMousePos.Y - MainGame.WindowSize.Y / 2) * player.CrosshairCameraRatio;

            if (Helper.Distance(player.Core, focus) > PlayerAimSphereRadius)
            {
                focus = player.Core + Helper.PolarToVector2(PlayerAimSphereRadius, player.AimAngle, 1, 1);//player.Core + Helper.normalize(focus) * 100;
            }
            Helper.MoveCameraTo(MainGame.Camera, focus, .04f);

            if (MainGame.Camera.Center.Y > 180 - 90)
            {
                focus.Y = player.Pos.Y - 90;
                MainGame.Camera.Center = new Vector2f(MainGame.Camera.Center.X, 180 - 90);
            }

            //Camera2D.returnCamera(player.ActorCenter +
            //            new Vector2(Main.screenMousePos.X - Main.graphics.PreferredBackBufferWidth / 2,
            //                Main.screenMousePos.Y - Main.graphics.PreferredBackBufferHeight / 2) *
            //                Main.graphics.GraphicsDevice.Viewport.AspectRatio / player.currentWeapon.viewDistance);

            MainGame.window.SetView(MainGame.window.DefaultView);
            shader.Shader.SetParameter("offsetY", MainGame.Camera.Center.Y);
            RectangleShape rs = new RectangleShape
            {
                Size = new Vector2f(800, 600)
            };

            MainGame.window.Draw(rs, shader);
            MainGame.window.SetView(MainGame.Camera);

            //foreach (Sprite s in BackgroundImagesFar)
            //{
            //    s.Position = new Vector2f(s.Position.X, 280 - MAPYOFFSET + (player.Pos.Y / 15));
            //}

            BackgroundImagesFar.ForEach(p => { p.Draw(MainGame.window, RenderStates.Default); });
            BackgroundImages.ForEach(p => { p.Draw(MainGame.window, RenderStates.Default); });
            BackgroundGameObjects.ForEach(p => { p.Draw(); });
            BackgroundTracks.ForEach(p => { p.Draw(MainGame.window, RenderStates.Default); });
            HandleBackground();



            MainGame.window.Draw(new Sprite(Content.GetTexture("mapDecor.png")));
            int insideY = 65;

            if (player.Pos.Y > insideY)
            {
                //trainSoundExterior.volume = 1;
                trainSound = trainSoundExterior;
                // trainSoundInterior.volume = 0;
                interiorAlpha += (255f - interiorAlpha) * .1f;
            }
            else
            {
                //trainSoundInterior.volume = 0;
                interiorAlpha *= .95f;
                //trainSound = trainSoundInterior;
                //trainSoundExterior.volume = 0;
            }
            Render.Draw(Content.GetTexture("mapInterior.png"), new Vector2f(0, 0), new Color(255, 255, 255, (byte)interiorAlpha), new Vector2f(0, 0), 1, 0f);
            // MainGame.window.Draw(new Sprite(Content.GetTexture("mapInterior.png")));

            Players.ForEach(p => { p.Draw(); });
            Projectiles.ForEach(p => { p.Draw(); });
            GameObjects.ForEach(p => { p.Draw(); });



            if (player.Pos.Y < insideY)
            {
                Render.Draw(Content.GetTexture("mapDecor.png"), new Vector2f(0, 0), new Color(255, 255, 255, (byte)(255 - interiorAlpha)), new Vector2f(0, 0), 1, 0f);
            }
            //MainGame.window.Draw(mapSprite);
            Gui.Draw();
        }