public PlayerDataObject Join() { // Only 2 players allowed (could change this accordingly) if (GameData.gameState == GAMESTATE.PLAYING) { return(null); } // Create a new player Data Object PlayerDataObject player = new PlayerDataObject { ConnectionClientID = Context.ConnectionId, lives = 3, textureName = GameData.playerCharacters.Pop(), position = new Point(GameData.r.Next((int)GameData.WorldBound.X), GameData.r.Next((int)GameData.WorldBound.Y)), health = 100, score = 0 }; // Just looking at two player game to begin GameData.Players.Add(Context.ConnectionId, player); // First tme we get two players if (GameData.Players.Count > 1 && GameData.gameState == GAMESTATE.STARTING) { GameData.gameState = GAMESTATE.PLAYING; //Clients.All.play(); //Clients.All.registerOpponents(Players); // Other player(s) } return(player); }
public PlayerDataObject Join() { // Check and if the charcters if (characters.Count > 0) { // pop name string character = characters.Pop(); // if there is a registered player if (RegisteredPlayers.Count > 0) { PlayerDataObject newPlayer = RegisteredPlayers.Dequeue(); newPlayer.textureName = character; newPlayer.position = new Point { X = new Random().Next(700), Y = new Random().Next(500) }; // Tell all the other clients that this player has Joined Clients.Others.Joined(newPlayer); // Tell this client about all the other current Clients.Caller.CurrentPlayers(Players); // Finaly add the new player on teh server Players.Add(newPlayer); return(newPlayer); } } return(null); }
public void removeMe() { GameData.ConnectedIds.Remove(Context.ConnectionId); PlayerDataObject found = GameData.Players[Context.ConnectionId]; GameData.playerCharacters.Push(found.textureName); GameData.Players.Remove(Context.ConnectionId); Clients.All.removeOpponent(Context.ConnectionId); GameData.gameState = GAMESTATE.STARTING; }
public void SetPlayerData(PlayerDataObject data, Vector3 spawner, string name, int index) { playerName = name; playerIndex = index; playerSpawner = spawner; horizontalAxis = data.horizontalAxis; verticalAxis = data.verticalAxis; jumpInput = data.jumpInput; hitBallInput = data.hitBallInput; isControlledByPlayer = data.isPlayer; }
private void CreatePlayer(PlayerDataObject player) { //ID = player.GamerTag; PlayerInfo = player; //new SimplePlayerSprite(this, player, Playerimage, // new Point(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2)); //Playerimage = Content.Load<Texture2D>(player.textureName); //new FadeText(this, Vector2.Zero, " Welcome " + player.GamerTag + " you are playing as " + player.textureName); //totalPlayers.Add(player); //cam.follow(new Vector2((int)player.playerPosition.X, (int)player.playerPosition.Y), GraphicsDevice.Viewport); }
// Constructor epects to see a loaded Texture // and a start position public SimplePlayerSprite(Game game, PlayerDataObject data, Texture2D spriteImage, Point startPosition) : base(game) { pData = data; DrawOrder = 1; game.Components.Add(this); // Take a copy of the texture passed down Image = spriteImage; // Take a copy of the start position previousPosition = Position = startPosition; // Calculate the bounding rectangle BoundingRect = new Rectangle((int)Position.X, Position.Y, Image.Width, Image.Height); }
private Point _topPegLocation = new Point(13, 114); // for 768 pixels high public InnerTraditionalBoard() { InitializeComponent(); DataContext = this; _player = new PlayerDataObject(PlayerType.Player, _sbMovePFPeg, _sbMovePBPeg, _playerFrontPeg, _playerBackPeg); _computer = new PlayerDataObject(PlayerType.Computer, _sbMoveCFPeg, _sbMoveCBPeg, _computerFrontPeg, _computerBackPeg); BuildPegLists(); if (DesignMode.DesignModeEnabled) { _targetCenterBottom.Opacity = 0.5; _targetCenterTop.Opacity = 0.5; } }
public override void Bind(UIContextData bound) { Bound = (PlayerDataObject)bound; GrowthRayButton.onClick.AddListener(FindObjectOfType <WorldEnlarger>().GrowWorld); }