public override void Draw(Batch Batch, Vector2 Position, Color Color, float Opacity, float Angle, Origin Origin, float Scale, SpriteEffects Effect = SpriteEffects.None, float Layer = 0) { /*Batch.Draw(Textures.Get("Players.1-" + Mod.Weapons[Weapon].Texture), Position, null, (Color.Black * (Opacity * .65f)), Angle, new Origin(Mod.Weapons[Weapon].Player.X, Mod.Weapons[Weapon].Player.Y), * Scale, SpriteEffects.None, .425002f);*/ if (!Dead) { if (Vector2.Distance(InterpolatedPosition, Position) <= 50) { Vector2 ShadowPosition = Globe.Move(InterpolatedPosition, Globe.Angle(new Vector2((Map.Width / 2f), (Map.Height / 2f)), InterpolatedPosition), (4 + (Vector2.Distance(new Vector2((Map.Width / 2f), (Map.Height / 2f)), InterpolatedPosition) / 250))); Batch.Draw(Textures.Get("Players.1-" + Mod.Weapons[Weapon].Texture), ShadowPosition, null, (Color.Black * (Opacity * .35f)), InterpolatedAngle, new Origin(Mod.Weapons[Weapon].Player.X, Mod.Weapons[Weapon].Player.Y), Scale, SpriteEffects.None, .425001f); Batch.Draw(Textures.Get("Players.1-" + Mod.Weapons[Weapon].Texture), InterpolatedPosition, null, (Color * Opacity), InterpolatedAngle, new Origin(Mod.Weapons[Weapon].Player.X, Mod.Weapons[Weapon].Player.Y), Scale, SpriteEffects.None, .425f); } else { Vector2 ShadowPosition = Globe.Move(Position, Globe.Angle(new Vector2((Map.Width / 2f), (Map.Height / 2f)), Position), (4 + (Vector2.Distance(new Vector2((Map.Width / 2f), (Map.Height / 2f)), Position) / 250))); Batch.Draw(Textures.Get("Players.1-" + Mod.Weapons[Weapon].Texture), ShadowPosition, null, (Color.Black * (Opacity * .35f)), Angle, new Origin(Mod.Weapons[Weapon].Player.X, Mod.Weapons[Weapon].Player.Y), Scale, SpriteEffects.None, .425001f); Batch.Draw(Textures.Get("Players.1-" + Mod.Weapons[Weapon].Texture), Position, null, (Color.Black * (Opacity * .65f)), Angle, new Origin(Mod.Weapons[Weapon].Player.X, Mod.Weapons[Weapon].Player.Y), Scale, SpriteEffects.None, .425001f); } } //Mask.Draw(Color.White, 1); }
public static void UpdateMenuWorld(GameTime time) { if (!CamWaypoint.HasValue) { var nextSurface = new Point((((int)(MenuWorld.X / Tile.Size)) + ((CamNorm > 0) ? 1 : -1)), (int)(MenuWorld.Y / Tile.Size)); for (var y = 1; y < MenuWorld.Height - 1; y++) { if (MenuWorld.Tiles[nextSurface.X, y].Solid) { nextSurface.Y = (y - 1); break; } } var tileHalved = (Tile.Size / 2f); CamWaypoint = (new Vector2(((nextSurface.X * Tile.Size) + tileHalved), ((nextSurface.Y * Tile.Size) + tileHalved))); } else { Globe.Move(ref CamPos, CamWaypoint.Value, (Math.Abs(CamNorm * 32) * (float)(time.ElapsedGameTime.TotalSeconds * 4))); const float camNormVel = .8f; MenuWorld.Position = new Vector2((int)Math.Round(CamPos.X), (int)Math.Round(CamPos.Y)); if (Vector2.Distance(CamPos, CamWaypoint.Value) <= 4) { CamWaypoint = null; } if (CamPos.X >= (((MenuWorld.Width * Tile.Size) - (Screen.BackBufferWidth / 2f)) - (Tile.Size * 8))) { CamNorm = MathHelper.Max(-1, (CamNorm - (camNormVel * (float)time.ElapsedGameTime.TotalSeconds))); } else if (CamPos.X <= ((Screen.BackBufferWidth / 2f) + (Tile.Size * 9))) { CamNorm = MathHelper.Min(1, (CamNorm + (camNormVel * (float)time.ElapsedGameTime.TotalSeconds))); } } }
public void Cast(Vector2 Position, float Length, float Field, float Angle, params Polygon[] Obstacles) { var Rays = new Ray[this.Rays.Length]; for (uint i = 0; i < Rays.Length; i++) { var RayAngle = ((Angle - (Field / 2)) + ((i / (float)Rays.Length) * Field)); Rays[i] = new Ray(Position, Globe.Move(Position, RayAngle, Math.Max(1, Length))); foreach (var Obstacle in Obstacles) { if (Obstacle.Intersects(Rays[i], ref Rays[i].End)) { Rays[i].Obstacle = Obstacle; } } } this.Rays = Rays; }
public override void Update(GameTime Time) { if ((Animation == null) || Animation.Finished) { ; } if (FireRate > 0) { FireRate -= Time.ElapsedGameTime.TotalSeconds; } if (this == Self) { if (Globe.Active && !Dead) { var OldPosition = Position; var Run = (Keyboard.Holding(Keyboard.Keys.LeftShift) || Keyboard.Holding(Keyboard.Keys.RightShift)); if (Keyboard.Holding(Keyboard.Keys.W)) { if (Keyboard.Holding(Keyboard.Keys.A)) { Move(new Vector2(-(float)(Speed.X * Time.ElapsedGameTime.TotalSeconds), -(float)(Speed.Y * Time.ElapsedGameTime.TotalSeconds))); } else if (Keyboard.Holding(Keyboard.Keys.D)) { Move(new Vector2((float)(Speed.X * Time.ElapsedGameTime.TotalSeconds), -(float)(Speed.Y * Time.ElapsedGameTime.TotalSeconds))); } else { Move(new Vector2(0, -(float)(Speed.Y * Time.ElapsedGameTime.TotalSeconds))); } } else if (Keyboard.Holding(Keyboard.Keys.S)) { if (Keyboard.Holding(Keyboard.Keys.A)) { Move(new Vector2(-(float)(Speed.X * Time.ElapsedGameTime.TotalSeconds), (float)(Speed.Y * Time.ElapsedGameTime.TotalSeconds))); } else if (Keyboard.Holding(Keyboard.Keys.D)) { Move(new Vector2((float)(Speed.X * Time.ElapsedGameTime.TotalSeconds), (float)(Speed.Y * Time.ElapsedGameTime.TotalSeconds))); } else { Move(new Vector2(0, (float)(Speed.Y * Time.ElapsedGameTime.TotalSeconds))); } } else if (Keyboard.Holding(Keyboard.Keys.A)) { Move(new Vector2(-(float)(Speed.X * Time.ElapsedGameTime.TotalSeconds), 0)); } else if (Keyboard.Holding(Keyboard.Keys.D)) { Move(new Vector2((float)(Speed.X * Time.ElapsedGameTime.TotalSeconds), 0)); } if (OldPosition != Position) { } Angle = Globe.Lerp(Angle, Globe.Angle(Position, Mouse.CameraPosition), .1f); Camera.Position = Globe.Move(Position, Globe.Angle(Position, Mouse.CameraPosition), (Vector2.Distance(Position, Mouse.CameraPosition) / 4)); //Camera.Angle = Angle; if (Mouse.Pressed(Mouse.Buttons.Left) && (FireRate <= 0)) { Fire(Position, Angle); } } if (RespawnTimer > 0) { RespawnTimer -= Time.ElapsedGameTime.TotalSeconds; } else if (Dead) { if ((GameType == GameTypes.Deathmatch) || (GameType == GameTypes.TeamDeathmatch)) { Point Spawn = Map.GetSpawn(Team); Respawn(new Vector2(((Spawn.X * Tile.Width) + (Tile.Width / 2f)), ((Spawn.Y * Tile.Height) + (Tile.Height / 2f)))); } } if ((Health <= 0) && !Dead) { Die(); } if (Timers.Tick("Positions") && (MultiPlayer.Type("Game") == MultiPlayer.Types.Client)) { MultiPlayer.Send("Game", MultiPlayer.Construct("Game", Game.Packets.Position, Position, Angle), NetDeliveryMethod.UnreliableSequenced, 1); } } Globe.Move(ref InterpolatedPosition, Position, (Vector2.Distance(InterpolatedPosition, Position) / 6)); InterpolatedAngle = Globe.Lerp(InterpolatedAngle, Angle, .125f); base.Update(Time); }
public void Fire(Vector2 Position, float Angle) { FireRate = (1 / Mod.Weapons[Weapon].RoundsPerSecond); Vector2 Start = (Position + Globe.Rotate((Mod.Weapons[Weapon].Bullet * Scale), Angle)), End = Globe.Move(Start, Angle, 2500); Line Bullet = new Line(Start, End); for (int x = 0; x < Map.Tiles.GetLength(0); x++) { for (int y = 0; y < Map.Tiles.GetLength(1); y++) { if (Map.Tiles[x, y].HasFore && (Mod.Fore[Map.Tiles[x, y].Fore].Type == Mod.Tile.Types.Wall)) { Polygon Mask = Polygon.CreateCross(new Vector2(Tile.Width, Tile.Height), Vector2.Zero); Mask.Position = new Vector2(((x * Tile.Width) + (Tile.Width / 2f)), ((y * Tile.Height) + (Tile.Height / 2f))); Vector2 Intersection = Vector2.Zero; if (Mask.Intersects(Bullet, ref Intersection)) { Bullet.End = Intersection; } } } } if (this == Self) { if (MultiPlayer.Type() == MultiPlayer.Types.Client) { MultiPlayer.Send(MultiPlayer.Construct(Packets.Fire, Position, Angle)); } else if (MultiPlayer.Type() == MultiPlayer.Types.Server) { MultiPlayer.Send(MultiPlayer.Construct(Packets.Fire, Slot, Position, Angle)); } } else { for (byte i = 0; i < Players.Length; i++) { if ((Players[i] != null) && (Players[i] != this) && (Players[i] != Self) && ((Players[i].Team == 0) || (Team == 0) || (Players[i].Team != Team))) { Vector2 Intersection = Vector2.Zero; if (Players[i].Mask.Intersects(Bullet, ref Intersection)) { Bullet.End = Intersection; } } } if (((Team == 0) || (Self.Team == 0) || (Team != Self.Team)) && Self.Mask.Intersects(Bullet)) { Self.Health -= Mod.Weapons[Weapon].Damage; Self.Killer = this; } } //Bullets.Add(Bullet); }