public void initObjects() { playernum = game.peer.currentRoom.getIDOnRoom(game.peer.peerInfo.getID()); players = game.peer.currentRoom.getConnectedPeers().Count; turn = (game.peer.isCreator) ? game.peer.turn : game.peer.msgReceived.turn; Console.WriteLine(playernum + " : " + players + " : " + turn); player1 = new Player[players / 2]; player2 = new Player[players / 2]; // Team 1 for (int i = 0, x = 16; i < player1.Length; i++, x += 64) { CharacterTexture chTexture = new CharacterTexture(body[i], cannon[i], turret[i], wheel[i], projectileTexture, shootTexture, healthTexture); player1[i] = new Player(world, new Vector2(x, 0), 32, 64, 20, 2 * i, squareTexture, chTexture); } team1 = new Team(player1); // Team 2 // int mid = players / 2; for (int i = 0, x = GraphicsDevice.Viewport.Width - 16; i < player2.Length; i++, x -= 64) { CharacterTexture chTexture = new CharacterTexture(bodya[i], cannona[i], turreta[i], wheela[i], projectileTexture, shootTexture, healthTexture); player2[i] = new Player(world, new Vector2(x, 0), 32, 64, 20, (2 * i) + 1, squareTexture, chTexture); } team2 = new Team(player2); }
public Team(Player[] players) { this.players = players; }
public bool isColide(Player p) { Boolean isColiding = false; Rectangle bulletRect = new Rectangle((int)position.X, (int)position.Y, image.Width, image.Height); Rectangle playerRect = new Rectangle((int)p.getPosition().X, (int)p.getPosition().Y, 100,100); return (bulletRect.Intersects(playerRect)); }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here AssetsManager.LoadContent(Content); connection.Start(); System.Diagnostics.Debug.WriteLine("Sent Init"); Random rand = new Random(); Vector2 vec = new Vector2(rand.Next(800), 300); lock (Players) { Players.Add(connection.peerID, (myPlayer = new Player(connection.peerID, vec))); } Message msg = new Message(); msg.msgCode = Message.INIT; msg.playerPos0 = vec; msg.PeerID = connection.peerID; msg.playerTexture = myPlayer.getPlayerTextureNumber(); connection.SendBroadCastMessage(msg.Construct()); myPlayer.setIsCurrentPlayer(true); System.Diagnostics.Debug.WriteLine("Sent Init"); if (IsCreator) { WhoseTurn = connection.peerID; myPlayer.setFire(false); } }