// another player moved private void PlayerMove(PsObject psobj) { string name = psobj.GetString(ServerConstants.PLAYER_NAME); Player player = FindPlayer(name); if (player == null) return; List<int> position = psobj.GetIntArray(ServerConstants.PLAYER_POSITION); player.MoveTo(Utility.ListToVector2(position)); }
// another player shot private void PlayerShoot(PsObject psobj) { string name = psobj.GetString(ServerConstants.PLAYER_NAME); Player player = FindPlayer(name); if (player == null) return; List<int> position = psobj.GetIntArray(ServerConstants.PLAYER_POSITION); List<int> heading = psobj.GetIntArray(ServerConstants.PLAYER_HEADING); Shot.Create(player, Utility.ListToVector2(position), Utility.ListToVector2(heading)); }
// add a single player. generally when somebody new joins after the game has started private void AddPlayer(PsObject psobj, bool updateStatus) { string name = psobj.GetString(ServerConstants.PLAYER_NAME); if (_otherPlayers.ContainsKey(name)) return; int type = psobj.GetInt(ServerConstants.PLAYER_TYPE); List<int> position = psobj.GetIntArray(ServerConstants.PLAYER_POSITION); Player player = CreateCharacter(type, Utility.ListToVector2(position), OthersLayer); player.Face(PlayerDirection.Down); _otherPlayers.Add(name, player); // update chat a player entered if (updateStatus) _chat.UserAction(name, ChatAction.Enter); }