public Player(World world, Vector2 position, float width, float height, float mass, int turn, Texture2D texture, CharacterTexture chTexture) : base(world, position, width, height, mass, turn, texture) { this.world = world; this.chTexture = chTexture; this.bodyOrigin = new Vector2(chTexture.body.Width / 2, chTexture.body.Height / 2); this.cannonOrigin = new Vector2(chTexture.cannon.Width / 2, chTexture.cannon.Height / 2); this.turretOrigin = new Vector2(chTexture.turret.Width / 2, chTexture.turret.Height / 2); this.wheelOrigin = new Vector2(chTexture.wheel.Width / 2, chTexture.wheel.Height / 2); if (width > height) { throw new Exception("Error width > height: can't make character because wheel would stick out of body"); } activity = Activity.Idle; wheel.OnCollision += new OnCollisionEventHandler(OnCollision); fixture.OnCollision += new OnCollisionEventHandler(BodyOnCollision); cannon.OnCollision += new OnCollisionEventHandler(BodyOnCollision); }
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); }