public static BombManager Instance() { if (instance == null) { instance = new BombManager(); } return(instance); }
private void clearData() { TextureManager.Instance().clear(); ImageManager.Instance().clear(); SpriteBatchManager.Instance().clear(); SpriteProxyManager.Instance().clear(); DisplayManager.Instance().clear(); AnimManager.Instance().clear(); GameObjManager.Instance().clear(); Timer.Clear(); PlayerManager.Instance().clear(); BombManager.Instance().clear(); }
public void removeBomb(Bomb b) { if (b.state == BombState.alive) { b.state = BombState.dead; b.spriteRef.sprite.image = b.image1; GameObjManager.Instance().remove(batchEnum.bomb, b); BombManager.Instance().addBomb(b); playBombHitSound(); PlayerManager.getPlayer(b.owner).addBombSprite(); } }
public void removeBomb(Bomb b, Vector2 _pos, Color _color) { if (b.state == BombState.alive) { b.state = BombState.dead; b.spriteRef.sprite.image = b.image1; GameObjManager.Instance().addExplosion(_pos, _color); GameObjManager.Instance().remove(batchEnum.bomb, b); BombManager.Instance().addBomb(b); playBombHitSound(); PlayerManager.Instance().getPlayer(b.owner).addBombSprite(); } }
private void checkInput() { newState = Keyboard.GetState(); P1newPadState = GamePad.GetState(PlayerIndex.One); P2newPadState = GamePad.GetState(PlayerIndex.Two); if (oldState.IsKeyDown(Keys.D) || P1oldPadState.IsButtonDown(Buttons.DPadRight)) { player1.playerShip.physicsObj.body.Rotation += 0.1f; Ship_Rot_Message msg = new Ship_Rot_Message(player1, 0.1f); Debug.WriteLine("D player1.playerShip.physicsObj.body.Rotation = " + player1.playerShip.physicsObj.body.Rotation); OutputQueue.add(msg); } if (oldState.IsKeyDown(Keys.A) || P1oldPadState.IsButtonDown(Buttons.DPadLeft)) { player1.playerShip.physicsObj.body.Rotation -= 0.1f; Ship_Rot_Message msg = new Ship_Rot_Message(player1, -0.1f); Debug.WriteLine("A player1.playerShip.physicsObj.body.Rotation = " + player1.playerShip.physicsObj.body.Rotation); OutputQueue.add(msg); } if (oldState.IsKeyDown(Keys.W) || P1oldPadState.IsButtonDown(Buttons.DPadUp)) { Ship Player1Ship = player1.playerShip; Vector2 direction = new Vector2((float)(Math.Cos(Player1Ship.physicsObj.body.GetAngle())), (float)(Math.Sin(Player1Ship.physicsObj.body.GetAngle()))); Debug.WriteLine("direction - W - = " + direction); //Vector2 direction = new Vector2(.6f, .5f); direction.Normalize(); float x = (float)(Math.Cos(Player1Ship.physicsObj.body.GetAngle())); float y = (float)(Math.Sin(Player1Ship.physicsObj.body.GetAngle())); Debug.WriteLine("x = " + x); Debug.WriteLine("y = " + y); direction *= shipSpeed; Debug.WriteLine("direction - W - afterNormal = " + direction); // No action, send a message thru queue //Player1Ship.physicsObj.body.ApplyLinearImpulse(direction, Player1Ship.physicsObj.body.GetWorldCenter()); Ship_Impulse_Message msg = new Ship_Impulse_Message(player1, direction); OutputQueue.add(msg); } if ((oldState.IsKeyDown(Keys.X) && newState.IsKeyUp(Keys.X)) || (P1oldPadState.IsButtonDown(Buttons.A) && P1newPadState.IsButtonUp(Buttons.A))) { if (player1.state == PlayerState.alive && player1.missileAvailable()) { // player1.createMissile(); Ship_Create_Missile_Message msg = new Ship_Create_Missile_Message(player1); OutputQueue.add(msg); } } if (oldState.IsKeyDown(Keys.C) && newState.IsKeyUp(Keys.C) || (P1oldPadState.IsButtonDown(Buttons.B) && P1newPadState.IsButtonUp(Buttons.B))) { if (player1.state == PlayerState.alive && BombManager.Instance().bombAvailable(PlayerID.one)) { // GameObjManager.Instance().createBomb(PlayerID.one); Ship_Create_Bomb_Message msg = new Ship_Create_Bomb_Message(player1); OutputQueue.add(msg); } } if (oldState.IsKeyDown(Keys.Right) || P2oldPadState.IsButtonDown(Buttons.DPadRight)) { // player2.playerShip.physicsObj.body.Rotation += 0.1f; Ship_Rot_Message msg = new Ship_Rot_Message(player2, 0.1f); Debug.WriteLine("Right player2.playerShip.physicsObj.body.Rotation = " + player2.playerShip.physicsObj.body.Rotation); OutputQueue.add(msg); } if (oldState.IsKeyDown(Keys.Left) || P2oldPadState.IsButtonDown(Buttons.DPadLeft)) { //player2.playerShip.physicsObj.body.Rotation -= 0.1f; Ship_Rot_Message msg = new Ship_Rot_Message(player2, -0.1f); Debug.WriteLine("Left player1.playerShip.physicsObj.body.Rotation = " + player2.playerShip.physicsObj.body.Rotation); OutputQueue.add(msg); } if (oldState.IsKeyDown(Keys.Up) || P2oldPadState.IsButtonDown(Buttons.DPadUp)) { Ship Player2Ship = player2.playerShip; Vector2 direction = new Vector2((float)(Math.Cos(Player2Ship.physicsObj.body.GetAngle())), (float)(Math.Sin(Player2Ship.physicsObj.body.GetAngle()))); //Vector2 direction = new Vector2(-.5f, .5f); Debug.WriteLine("direction - up - = " + direction); float x = (float)(Math.Cos(Player2Ship.physicsObj.body.GetAngle())); float y = (float)(Math.Sin(Player2Ship.physicsObj.body.GetAngle())); Debug.WriteLine("x = " + x); Debug.WriteLine("y = " + y); direction.Normalize(); direction *= shipSpeed; // Player2Ship.physicsObj.body.ApplyLinearImpulse(direction, Player2Ship.physicsObj.body.GetWorldCenter()); // No action, send a message thru queue //Player1Ship.physicsObj.body.ApplyLinearImpulse(direction, Player1Ship.physicsObj.body.GetWorldCenter()); Ship_Impulse_Message msg = new Ship_Impulse_Message(player2, direction); OutputQueue.add(msg); } if ((oldState.IsKeyDown(Keys.OemQuestion) && newState.IsKeyUp(Keys.OemQuestion)) || (P2oldPadState.IsButtonDown(Buttons.A) && P2newPadState.IsButtonUp(Buttons.A))) { if (player2.state == PlayerState.alive && player2.missileAvailable()) { // player2.createMissile(); Ship_Create_Missile_Message msg = new Ship_Create_Missile_Message(player2); OutputQueue.add(msg); } } if (oldState.IsKeyDown(Keys.OemPeriod) && newState.IsKeyUp(Keys.OemPeriod) || (P2oldPadState.IsButtonDown(Buttons.B) && P2newPadState.IsButtonUp(Buttons.B))) { if (player2.state == PlayerState.alive && BombManager.Instance().bombAvailable(PlayerID.two)) { // GameObjManager.Instance().createBomb(PlayerID.two); Ship_Create_Bomb_Message msg = new Ship_Create_Bomb_Message(player2); OutputQueue.add(msg); } } else { } P1oldPadState = P1newPadState; P2oldPadState = P2newPadState; oldState = newState; }
private void checkInput() { newState = Keyboard.GetState(); P1newPadState = GamePad.GetState(PlayerIndex.One); P2newPadState = GamePad.GetState(PlayerIndex.Two); Player p; if (Host) { p = PlayerManager.getPlayer(PlayerID.one); } else { p = PlayerManager.getPlayer(PlayerID.two); } ////Player 1 controls if (oldState.IsKeyDown(Keys.D) || P1oldPadState.IsButtonDown(Buttons.DPadRight)) { Ship_rot_message pShip = new Ship_rot_message(p, 0.1f); pShip.serverRotvalue = p.playerShip.rotation; pShip.x = p.playerShip.location.X; pShip.y = p.playerShip.location.Y; OutQueue.add(QueueType.ship_rot_clock, pShip, p.id); } if (oldState.IsKeyDown(Keys.A) || P1oldPadState.IsButtonDown(Buttons.DPadLeft)) { Ship_rot_message pShip = new Ship_rot_message(p, -0.1f); pShip.serverRotvalue = p.playerShip.rotation; pShip.x = p.playerShip.location.X; pShip.y = p.playerShip.location.Y; OutQueue.add(QueueType.ship_rot_anti, pShip, p.id); } if (oldState.IsKeyDown(Keys.W) || P1oldPadState.IsButtonDown(Buttons.DPadUp)) { Ship Player1Ship = p.playerShip; Vector2 direction = new Vector2((float)(Math.Cos(Player1Ship.physicsObj.body.GetAngle())), (float)(Math.Sin(Player1Ship.physicsObj.body.GetAngle()))); direction.Normalize(); direction *= shipSpeed; ship_impulse p1 = new ship_impulse(p, direction); p1.rot = p.playerShip.rotation; OutQueue.add(QueueType.ship_impulse, p1, p.id); } if ((oldState.IsKeyDown(Keys.X) && newState.IsKeyUp(Keys.X)) || (P1oldPadState.IsButtonDown(Buttons.A) && P1newPadState.IsButtonUp(Buttons.A))) { if (player1.state == PlayerState.alive && player1.missileAvailable()) { Ship_Create_Bomb_Message p1 = new Ship_Create_Bomb_Message(p); p1.x = p.playerShip.location.X; p1.y = p.playerShip.location.Y; p1.rot = p.playerShip.rotation; OutQueue.add(QueueType.ship_bomb, p1, p.id); } } if (oldState.IsKeyDown(Keys.C) && newState.IsKeyUp(Keys.C) || (P1oldPadState.IsButtonDown(Buttons.B) && P1newPadState.IsButtonUp(Buttons.B))) { if (player1.state == PlayerState.alive && BombManager.Instance().bombAvailable(p.id)) { Ship_Create_Missile_Message p1 = new Ship_Create_Missile_Message(p); p1.x = p.playerShip.location.X; p1.y = p.playerShip.location.Y; p1.rot = p.playerShip.rotation; OutQueue.add(QueueType.ship_missile, p1, p.id); } } P1oldPadState = P1newPadState; P2oldPadState = P2newPadState; oldState = newState; }
public void clear() { instance = null; }
public static BombManager Instance() { if (instance == null) instance = new BombManager(); return instance; }