internal void DrawOnShiftInterface(ShiftInterface shiftInterface) { Particles.ForEach(p => shiftInterface.drawOnOverlay(p)); Projectiles.ForEach(p => shiftInterface.drawOnOverlay(p)); Collectables.ForEach(c => shiftInterface.drawOnOverlay(c)); Enemies.ForEach(e => shiftInterface.drawOnOverlay(e)); shiftInterface.drawOnOverlay(MainPlayer); }
internal void DrawMinimap(Camera camera) { Map.DrawMap(camera); Particles.ForEach(p => camera.DrawMinimap(p)); Projectiles.ForEach(p => camera.DrawMinimap(p)); Collectables.ForEach(c => camera.DrawMinimap(c)); Enemies.ForEach(e => camera.DrawMinimap(e)); camera.DrawMinimap(MainPlayer); }
internal void DrawObjects(Camera camera) { Map.DrawTiles(camera); Particles.ForEach(p => camera.Draw(p)); Projectiles.ForEach(p => camera.Draw(p)); Collectables.ForEach(c => camera.Draw(c)); Enemies.ForEach(e => camera.Draw(e)); camera.Draw(MainPlayer); }
private void UpdateProjectiles(float deltaTime) { try { Projectiles.ForEach(projectile => projectile.Update(deltaTime)); } catch { return; } }
internal void Update(float deltaTime) { //Update the FarseerPhysics physics PhysicsWorld.Step(deltaTime); Projectiles.ForEach(p => p.Update(deltaTime)); Particles.ForEach(p => p.Update(deltaTime)); Collectables.ForEach(c => c.Update(deltaTime)); Enemies.ForEach(e => e.Update(deltaTime)); MainPlayer.Update(deltaTime); Map.Update(deltaTime); EnemyDirector.Update(deltaTime); MainCamera.Update(deltaTime); Cull(Projectiles); Cull(Particles); Cull(Collectables); Cull(Enemies); }
internal void ClearGame() { Projectiles.ForEach(p => p.WasCleared()); Projectiles.Clear(); Particles.ForEach(p => p.WasCleared()); Particles.Clear(); Collectables.ForEach(c => c.WasCleared()); Collectables.Clear(); Enemies.ForEach(e => e.WasCleared()); Enemies.Clear(); Map.ClearGame(); EnemyDirector.ClearGame(); MainPlayer.WasCleared(); MainPlayer = null; MainCamera = null; }
public override void Update() { base.Update(); shittyTimerDontUse++; roundStarted = true; //Console.WriteLine(roundTimeLeft); if (roundTimeLeft % 60 == 0 && !tunnel) { tunnel = true; tunnelsTimer = 3; } if (roundTimeLeft < 15 && !resetMatch) { resetMatch = true; player.gold = 100; player.weapons = new List <Weapon>() { new Revolver(player), null, null, null, }; player.weapon = player.weapons[0]; MainGame.dm.Mailman.sendWeaponSwitch(0); for (int i = 0; i < GameObjects.Count; i++) { if (GameObjects[i] is Coin) { GameObjects.RemoveAt(i); } } } if (roundTimeLeft > 15) { firstPlacePlayer = MainGame.dm.Players.OrderByDescending(x => x.gold).ThenBy(x => (int)x.UID).ToList()[0]; resetMatch = false; } if (Input.isKeyDown(Keyboard.Key.F1)) { player.gold = 10000; player.MaxJumps = 10000000; player.Health = 1000000; } if (Input.isKeyOverride(Keyboard.Key.F12)) { devMode = true; player.MaxJumps = 10000; player.JumpsLeft = 10000; } if (tunnelsTimer > 0) { if (shittyTimerDontUse % (60 * 2) == 0) { if (!tunnel) { MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("TrainWhistle.wav"), 1, 0, 8)); } //if (Input.isKeyTap(Keyboard.Key.C)) //{ tunnelsTimer--; CliffFace c = new CliffFace(); BackgroundGameObjects.Add(c); } } //if (Input.isKeyTap(Keyboard.Key.C)) //{ // tunnelsTimer = 5; //} if (Input.isKeyTap(Keyboard.Key.T)) { MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("fart.wav"), 0, 1)); } tunnel = false; Mailman.HandleMessages(); Players.ForEach(p => { p.Update(); }); Projectiles.ForEach(p => { p.Update(); }); GameObjects.ForEach(p => { p.Update(); }); BackgroundGameObjects.ForEach(p => { p.Update(); }); CheckProjectileCollisions(); ApplyShake(); if (MainGame.rand.Next(4) == 0) { for (int i = 0; i < 5; i++) { GameObjects.Add(new TrainDust(new Vector2f(60 + (i * 440) + MainGame.rand.Next(70), 215), (float)MainGame.rand.NextDouble() * 90)); GameObjects.Add(new TrainDust(new Vector2f(304 + (i * 440) + MainGame.rand.Next(70), 215), (float)MainGame.rand.NextDouble() * 90)); } } TrainDust td = new TrainDust(new Vector2f(2190 + MainGame.rand.Next(10), 75), (float)MainGame.rand.NextDouble() * 90, 2); GameObjects.Add(td); GameObjects.Add(new TrainDust(new Vector2f(1978 + MainGame.rand.Next(10), 75), (float)MainGame.rand.NextDouble() * 90, 1)); if (Input.isKeyTap(Keyboard.Key.LShift) && !player.Alive) { if (player.respawnTimer <= 0) { //Players.Remove(player); //player = new ClientPlayer(this); //Players.Add(player); player.deathTimer = 0; player.respawnTimer = player.respawnLength * 60; player.Pos = new Vector2f(42 + MainGame.rand.Next(1000), 142); player.Health = 100; player.Alive = true; } //player.Pos = new Vector2f(MainGame.rand.Next(42,1800), 142); //Mailman.SendRespawn(player.UID); } if (Input.isKeyDown(Keyboard.Key.P)) { Console.WriteLine(player.Pos); } if (Input.isKeyDown(Keyboard.Key.R)) { MainGame.Camera.Center += new Vector2f(MainGame.rand.Next(-4, 5) * shakeFactor / 5, MainGame.rand.Next(-4, 5) * shakeFactor / 5); } trainSound.Update(); Gui.Update(); }
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(); }