public cPlayerManager(Game game) : base(game) { _players = new cPlayer[4]; _players[0] = new cPlayer(PlayerIndex.One); _players[1] = new cPlayer(PlayerIndex.Two); _players[2] = new cPlayer(PlayerIndex.Three); _players[3] = new cPlayer(PlayerIndex.Four); //LieroXNA.Instance.LieroConsole.AddCommand("spawnPlayer", "spawns a new player randomly about the world", delegate { SpawnNewPlayer(); }); PrimalDevistation.Instance.Console.AddCommand("bubbles", "activates or deactivates bubbles", delegate { for (int i = 0; i < _players.Length; i++) { _players[i].Bubbles = !_players[i].Bubbles; } }); _lastGPSs = new GamePadState[4]; _activePlayers = new List <cPlayer>(); _forces = new Vector4[4]; for (int i = 0; i < _forces.Length; i++) { _forces[i] = Vector4.Zero; } _nextForce = 0; }
protected override void LoadGraphicsContent(bool loadAllContent) { _flatTex = PrimalDevistation.Instance.CM.Load <Texture2D>(@"Sprites/particle2x2"); for (int i = 0; i < _players.Length; i++) { cPlayer p = _players[i]; p.LoadGraphicsContent(PrimalDevistation.Instance.GD, PrimalDevistation.Instance.CM); _font = PrimalDevistation.Instance.CM.Load <SpriteFont>("Other/ConsoleFont"); } }
public void SpawnNewPlayer(int playerIndex, int x, int y) { // Finding the next free player slot cPlayer p = _players[playerIndex]; p.Playing = true; PrimalDevistation.Instance.Level.AddExplosion(128, new Vector2(x, y), Vector2.Zero); p.Position = new Vector2(x, y); _activePlayers.Add(p); }
private void Respawn(cPlayer p) { int spawnSize = 128; Vector2 levSize = PrimalDevistation.Instance.Level.Size; cCollisionMap cm = PrimalDevistation.Instance.Level.CollisionMap; int x, y; do { //x = (int)cMath.Rand(600 + (spawnSize / 2), levSize.X - (spawnSize / 2)-600); //y = (int)cMath.Rand(600 + (spawnSize / 2), levSize.Y - (spawnSize / 2)-600); x = (int)cMath.Rand((spawnSize / 2), levSize.X - (spawnSize / 2)); //y = (int)cMath.Rand((spawnSize / 2), levSize.Y - (spawnSize / 2)); y = (int)cMath.Rand((spawnSize / 2), 400); } while (cm.CheckCollisionIndestructable(x - 64, y - 64, cm.Explosions[128]._data, SpriteEffects.None)); PrimalDevistation.Instance.Level.AddExplosion(128, new Vector2(x, y), Vector2.Zero); p.Position = new Vector2(x, y); p.HitPoints = p.MaxHitPoints; }
public void Explosion(Vector2 where, int size, Vector2 direction, cPlayer owner) { for (int i = 0; i < _activePlayers.Count; i++) { cPlayer p = _activePlayers[i]; Vector2 dist = where - p.Position; int lenSqr = (int)dist.LengthSquared(); if (lenSqr < size * size) { float len = dist.Length(); float mag = size / len; if (mag > 30) { mag = 30; } int sze = size; if (sze == 32) { sze = 64; } int subHPS = (int)(mag * (sze * 0.018f)); int numParticles = subHPS * 10; dist.Normalize(); dist *= -mag / 1; List <Vector2> positions = new List <Vector2>(numParticles); List <Vector2> velocities = new List <Vector2>(numParticles); List <Color> colors = new List <Color>(numParticles); //Color c = p.PrimaryColor; Color c = Color.Red; for (int j = 0; j < numParticles; j++) { positions.Add(new Vector2(p.Position.X + cMath.Rand(-10f, 10f), p.Position.Y + cMath.Rand(-10f, 10f))); velocities.Add(new Vector2(cMath.Rand(1f, 3f) * dist.X, cMath.Rand(1f, 3f) * dist.Y)); colors.Add(c); } PrimalDevistation.Instance.PhysicsParticles.SpawnParticles(positions, velocities, colors); p.HitPoints = p.HitPoints - subHPS; if (p.HitPoints < 0) { if (owner == null) { } else if (owner == p) { p.Score = p.Score - 1; } else { owner.Score = owner.Score + 1; } if (p.CurrentGrapple != null) { PrimalDevistation.Instance.Weapons.ReleaseGrapple(p.CurrentGrapple); p.CurrentGrapple = null; } numParticles = 2000; positions = new List <Vector2>(numParticles); velocities = new List <Vector2>(numParticles); colors = new List <Color>(numParticles); //c = p.PrimaryColor; c = Color.Red; float angle, x, y; for (int j = 0; j < numParticles; j++) { positions.Add(new Vector2(p.Position.X + cMath.Rand(-2f, 2f), p.Position.Y + cMath.Rand(-2f, 2f))); angle = cMath.Rand(0f, (float)(Math.PI * 2)); x = (float)Math.Sin(angle) * cMath.Rand(6f, 12f); y = (float)Math.Cos(angle) * cMath.Rand(6f, 12f); velocities.Add(new Vector2(x, y)); colors.Add(c); } PrimalDevistation.Instance.PhysicsParticles.SpawnParticles(positions, velocities, colors); Respawn(p); PrimalDevistation.Instance.Audio.play("DEATH1"); } } } }