private void 处理_C_能否进入(int p, byte[][] p_2) { var selectedServiceID = BitConverter.ToInt32(p_2[2], 0); byte[][] sendData = new byte[][] { BitConverter.GetBytes(p), BitConverter.GetBytes((int)DDZActions.C_能否进入) }; if (selectedServiceID == 0) { foreach (var service in _gameService) //随机加入 { if (service.Value.Length < 3) { lock (_sync_sendWhispers) { _sendWhispers.Enqueue(new KeyValuePair <int, byte[][]>(service.Key, sendData)); var tempPlayer = new DDZCharacter(); tempPlayer.TableID = service.Key; tempPlayer.ProxyID = p; _player.Add(p, tempPlayer); } } } } else //选择加入 { lock (_sync_sendWhispers) { _sendWhispers.Enqueue(new KeyValuePair <int, byte[][]>(selectedServiceID, sendData)); var tempPlayer = new DDZCharacter(); tempPlayer.TableID = selectedServiceID; tempPlayer.ProxyID = p; _player.Add(p, tempPlayer); } } }
public void CreateGame(string[] names, DeckType decktype, Form f) { welcomeform = f; howmanydudes = (byte)names.Length; expl_kittens = (byte)(howmanydudes - 1); // Create Deck ExploadingDeck = new Deck(decktype, howmanydudes); ExploadingDeck.Shuffle(); Player.D = ExploadingDeck; // Create Players for (int i = 0; i < howmanydudes; i++) { Player new_plr = new Player(names[i]); new_plr.TakeFirstCards(); new_plr.TakeDefuse((byte)i); AllPlayers.Add(new_plr); } ExploadingDeck.AddExKittens(); if (decktype == DeckType.Impladings) { ExploadingDeck.AddImplKitten(); DisplayVector(); if (howmanydudes == 2) { expl_kittens += 1; } } ExploadingDeck.Shuffle(); // First player AllPlayers.SetWhoIsFirst(); ImageWorker.LoadPlayerCards(CurrentPlayer); label1.Text = "Хід граця " + CurrentPlayer.Name; DisplayExploadingInfo(); }
/* * Fetch all players from the database and rturn the resulant playerList object */ public PlayerCollection getPlayers() { PlayerCollection playerList = new PlayerCollection(); const string selectStatement = "SELECT * FROM player"; cmd = new SqlCommand(selectStatement, conn); try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) playerList.Add(new Player(reader["playerName"].ToString(), (int)reader["rating"], (int)reader["wins"], (int)reader["losses"], (int)reader["draws"], (int)reader["id"])); reader.Close(); } catch (SqlException) { } finally { conn.Close(); } return playerList; }
/// <summary> /// </summary> protected virtual void Initialize() { _player = new TPlayer(); var instance = _player as IPlayerFactory; if (instance == null) { return; } var channel = instance.GetPlayerKey(); if (!_playerChannels.ContainsKey(channel)) { _playerChannels.Add(channel, _player); Trace.WriteLine(string.Format("Channel '{0}' added to {1} channel cache: {2} channels cached." , channel.ChannelName , _player.PlayerType.ToString() , _playerChannels.Count), TraceCategory.PlayerLoading.ToString()); // Channel foo added to player bar. Bar has x channels cached. } else { Trace.WriteLine(string.Format("Channel '{0}' retrieved from {1} cache" , channel.ChannelName , _player.PlayerType.ToString()), TraceCategory.PlayerLoading.ToString()); } }
//Receives all the data send by a client private void ListenClient(Player player) { string initialData = GetInitialData(player.ID); player.Send(initialData); player.Send(map.Seed); PlayerType type = (PlayerType)int.Parse(player.Receive()); player.Create(type); //Once we send all the data and receive the player type //Add the player to the list and send the data to the others lock (lockGameState) { gameState += players.Add(player.ID, player); } while (IsOpen && player.IsConnected) { string data = player.Receive(); if (data != "") { lock (lockMessageQueue) { messageQueue.Enqueue(data); } } } }
/* * Fetch all players from the database and store them in the playerList object * passed in by reference */ public PlayerCollection getPlayers() { XmlDocument doc = GetFile(fullPath); PlayerCollection list = new PlayerCollection(); foreach (XmlElement elem in doc.DocumentElement.ChildNodes) { list.Add(FromElement(elem)); } return list; }
public PlayerCollection<Player> CreatePlayerCollection() { var players = new PlayerCollection<Player>(); for (int i = 0; i < 15; i++) { players.Add(new Player(i, "PlayerKey_" + i, "Player " + i, "Status_" + i, null, null)); } return players; }
public Table(int playerCount, AppSettings settings) { TotalRounds = 0; ButtonPlayerPrev = -999; _random = new Random(); ShortButton1 = settings.ShortButtonRect1; ShortButton2 = settings.ShortButtonRect2; ShortButton3 = settings.ShortButtonRect3; ShortButton4 = settings.ShortButtonRect4; CardSuitRect = settings.CardSuitRect; CardRankRect = settings.CardRankRect; CardMinSize = (int)settings.MinCardSize; BetCounterPreFlop = 1; BetCounterFlop = 1; BetCounterTurn = 1; BetCounterRiver = 1; RaiseCounter = 0; PlayerActionCounter = 0; PlayerRects = new List<Rectangle>(); PlayerFolds = new List<Rectangle>(); ButtonRects = new List<Rectangle>(); BetRects = new List<Rectangle>(); Players = new PlayerCollection(); DealerButtons = new List<bool>(); PlayerBets = new List<PlayerBet>(); MyBalance = new Player(); Bank = new Bank(); for (int i = 0; i < playerCount; i++) { Players.Add(new Player {Action = PlayerAction.Init}); } for (int i = 0; i < playerCount; i++) { DealerButtons.Add(false); } for (int i = 0; i < playerCount; i++) { PlayerBets.Add(new PlayerBet()); } _cardRecognizer = new CardRecognizer(); }
public Game(int numHumanPlayers, IEnumerable <String> playerNames, IEnumerable <Type> aiTypes, GameSettings settings) { this.State = GameState.Setup; this.Settings = settings; _Players = new PlayerCollection(); // Add human players for (int i = 0; i < numHumanPlayers; i++) { _Players.Add(new Players.Human(this, playerNames.ElementAt(i))); } // Add AI players for (int i = numHumanPlayers; i < playerNames.Count(); i++) { try { _Players.Add((Player)aiTypes.ElementAt(i).GetConstructor(new Type[] { typeof(Game), typeof(String) }).Invoke(new Object[] { this, playerNames.ElementAt(i) })); } catch (TargetInvocationException tie) { if (tie.InnerException != null) { throw tie.InnerException; } } } _Players.Setup(this); Utilities.Shuffler.Shuffle <Player>(_Players); if (playerNames.Count() > 4) { _EndgameSupplies = 4; } this.State = GameState.CardSelection; }
public IPlayerCollection Create() { this.textInterface.Write($"Enter the number of players, between {this.playerSettings.MinimumPlayerCount} and {this.playerSettings.MaximumPlayerCount}: "); var playerCount = this.textInterface.ReadIntegerInRange( this.playerSettings.MinimumPlayerCount, this.playerSettings.MaximumPlayerCount); this.textInterface.WriteLine(); var nameEachPlayer = this.textInterface.GetYesOrNoResponse("Enter player names?"); var playerCollection = new PlayerCollection() { Capacity = playerCount }; if (nameEachPlayer) { this.textInterface.WriteLine(); this.textInterface.WriteLine(); this.textInterface.WriteLine($"Enter a unique name for each player, between {this.playerSettings.MinimumNameLength} and {this.playerSettings.MaximumNameLength} characters."); for (int i = 0; i < playerCount; i++) { this.textInterface.Write($"Player {i + 1}: "); while (true) { var line = this.textInterface.ReadLine(this.playerSettings.MaximumNameLength, this.playerSettings.MinimumNameLength); if (String.IsNullOrWhiteSpace(line) || playerCollection.FirstOrDefault(player => String.Equals(player.Name, line)) != null) { this.textInterface.WriteLine("Error: Player name must be unique and contain at least one character."); this.textInterface.Write($"Enter a unique name for Player {i + 1}: "); } else { playerCollection.Add(this.playerFactory.Create(line)); break; } } } } else { var players = Enumerable.Range(1, playerCount) .Select(index => playerFactory.Create("Player " + index)); playerCollection.AddRange(players); } return(playerCollection); }
/// <summary> /// Updates the list of client names in the window /// </summary> /// <param name="players">The list of players to add</param> public void UpdateClientList(List <Player> players) { if (this.InvokeRequired) { PlayerListCallback d = UpdateClientList; Invoke(d, new List <Player>[] { players }); } else { if (dgvPlayers.DataSource == null) { dgvPlayers.DataSource = pc; } // Try to keep the same selection on update string selected = null; if (pc.Count > 0 && dgvPlayers.SelectedRows.Count > 0) { selected = (from DataGridViewRow row in dgvPlayers.Rows where row.Selected select pc[row.Index]).First().name; } // Update the data source and control //dgvPlayers.SuspendLayout(); pc = new PlayerCollection(new PlayerListView()); Player.players.ForEach(p => pc.Add(p)); //dgvPlayers.Invalidate(); dgvPlayers.DataSource = pc; // Reselect player if (selected != null) { for (int i = 0; i < Player.players.Count; i++) { for (int j = 0; j < dgvPlayers.Rows.Count; j++) { if (String.Equals(dgvPlayers.Rows[j].Cells[0].Value, selected)) { dgvPlayers.Rows[j].Selected = true; } } } } dgvPlayers.Refresh(); //dgvPlayers.ResumeLayout(); } }
private void 处理_能否进入(int playerid) { if (_currentStateHander.CanIJoinIt(_players.Count)) { var tempPlayer = new DDZCharacter(); tempPlayer.超时_进入超时 = GameLooper.Counter + 10; tempPlayer.PlayerID = playerid; tempPlayer.clientState = DDZClientStates.等待进入; _players.Add(playerid, tempPlayer); 发出_能进入(playerid); } else { 发出_不能进入(playerid); } }
/* * Fetch all players from the database and store them in the playerList object * passed in by reference */ public PlayerCollection getPlayers() { PlayerCollection playerList = new PlayerCollection(); if (File.Exists(this.fullPath)) { byte[] fileContents = File.ReadAllBytes(this.fullPath); Player currPlayer = null; int currIndex = 0; while ((currPlayer = Player.FromBytes(fileContents, ref currIndex)) != null) playerList.Add(currPlayer); } return playerList; }
void playersFile_Loaded(object sender, EventArgs e) { var args = (PlayersLoadedEventArgs)e; if (args.Collection == null) { // TODO write some code here // error occured return; } PlayerCollection players = Resources["PlayersList"] as PlayerCollection; foreach (var player in args.Collection) { players.Add(player); } playerSelect.ItemsSource = players; }
public void UpdateClientList(List <Player> players) { if (InvokeRequired) { Invoke(new PlayerListCallback(UpdateClientList), players); } else { if (dgvPlayers.DataSource == null) { dgvPlayers.DataSource = pc; } // Try to keep the same selection on update string selected = null; if (pc.Count > 0 && dgvPlayers.SelectedRows.Count > 0) { selected = (from DataGridViewRow row in dgvPlayers.Rows where row.Selected select pc[row.Index]).First().name; } pc = new PlayerCollection(new PlayerListView()); Player.players.ForEach(p => pc.Add(p)); dgvPlayers.DataSource = pc; if (selected != null) { foreach (Player t in Player.players) { for (int j = 0; j < dgvPlayers.Rows.Count; j++) { if (Equals(dgvPlayers.Rows[j].Cells[0].Value, selected)) { dgvPlayers.Rows[j].Selected = true; } } } } dgvPlayers.Refresh(); } }
protected override GamePlayerBase TryJoinGameCore(IPlayerHost playerHost) { lock ( SyncRoot ) { if (PlayerCollection.Count == players) { return(null); } var player = new SimpleGamePlayer(GameHost, playerHost); PlayerCollection.Add(player); if (PlayerCollection.Count == players) { GameHost.Run(); } return(player); } }
//Translate all the data send by the server private void TranslateData(string[] allCommands) { foreach (string command in allCommands) { string[] commandParts = command.Split(); switch ((ServerMessage)int.Parse(commandParts[0])) { //Sets the angle of the other players. case ServerMessage.SetPlayerAngle: { int id = int.Parse(commandParts[1]); if (id != localPlayer.ID) { players.SetAngle(id, commandParts); } } break; //Sets the position of the players case ServerMessage.SetPlayerPosition: { int id = int.Parse(commandParts[1]); if (id != localPlayer.ID) { players.SetPosition(id, commandParts); } else { localPlayer.SetPos(commandParts); localPlayer.Reconcile(); } } break; //Set the last command processed by the server case ServerMessage.LastCommandProcessed: { localPlayer.LastCommandProccesed = uint.Parse(commandParts[1]); break; } //Adds a new bullet case ServerMessage.NewBullet: { bullets.Add(commandParts); } break; //Removes a bullet case ServerMessage.RemoveBullet: { bullets.Remove(commandParts); } break; //Damages the local player case ServerMessage.DamagePlayer: { localPlayer.TakeDamage(commandParts); } break; //Respawns a player case ServerMessage.Respawn: { int id = int.Parse(commandParts[1]); if (id != localPlayer.ID) { players.Respawn(id, commandParts); } else { localPlayer.Respawn(commandParts); CurrentUpdateGameFunction = UpdateGameStateAlive; CurrentRenderGameFunction = RenderGameAlive; } } break; //Kills the player case ServerMessage.KillPlayer: { int id = int.Parse(commandParts[1]); if (id != localPlayer.ID) { players.Kill(id); } else { localPlayer.Kill(); CurrentUpdateGameFunction = UpdateGameStateDead; CurrentRenderGameFunction = RenderGameDead; } } break; case ServerMessage.NewRound: { winnerTeam = (PlayerTeam) int.Parse(commandParts[1]); if (winnerTeam != PlayerTeam.Spectator) { isNewRound = true; winnerTextTimer = SDL.SDL_GetTicks(); } break; } //Changes the team of a player case ServerMessage.SetPlayerTeam: { int id = int.Parse(commandParts[1]); if (id != localPlayer.ID) { players.SetTeam(id, commandParts); } else { localPlayer.SetTeam(commandParts); if ((PlayerTeam)int.Parse(commandParts[2]) == PlayerTeam.Spectator) { CurrentUpdateGameFunction = UpdateGameStateSpectator; } else { CurrentUpdateGameFunction = UpdateGameStateDead; } } } break; //Creates a new player case ServerMessage.NewPlayer: { int id = int.Parse(commandParts[1]); if (id != localPlayer.ID) { players.Add(id, commandParts); } break; } //Removes a player case ServerMessage.RemovePlayer: { int id = int.Parse(commandParts[1]); players.Remove(id); } break; //Disconnects a player case ServerMessage.Disconnect: NextScreen = ScreenType.End; Game.EndMessage = Game.LanguageTranslation [Game.GameLanguage + commandParts[1]]; Game.GameSocket.Disconnect(); break; //Sets the id of the local player. case ServerMessage.SetID: localPlayer.ID = int.Parse(commandParts[1]); break; } } }
public override PlayerCollection DisplayGetPlayers() { PlayerCollection p = new PlayerCollection(); p.Add( new Player( "Tyler", "" ) ); return p; }
public Game(int numHumanPlayers, IEnumerable<String> playerNames, IEnumerable<Type> aiTypes, GameSettings settings) { this.State = GameState.Setup; this.Settings = settings; _Players = new PlayerCollection(); // Add human players for (int i = 0; i < numHumanPlayers; i++) _Players.Add(new Players.Human(this, playerNames.ElementAt(i))); // Add AI players for (int i = numHumanPlayers; i < playerNames.Count(); i++) try { _Players.Add((Player)aiTypes.ElementAt(i).GetConstructor(new Type[] { typeof(Game), typeof(String) }).Invoke(new Object[] { this, playerNames.ElementAt(i) })); } catch (TargetInvocationException tie) { if (tie.InnerException != null) throw tie.InnerException; } _Players.Setup(this); Utilities.Shuffler.Shuffle<Player>(_Players); if (playerNames.Count() > 4) _EndgameSupplies = 4; this.State = GameState.CardSelection; }
public void AddPlayer(PlayerModel player) { PlayerCollection.Add(player); }
private void OnEnable() { _playerCollection.Add(this); _animations = GetComponentInChildren <HandAnimations>(); }
public override PlayerCollection DisplayGetPlayers() { PlayerCollection toReturn = new PlayerCollection(); switch( this.Mode ) { case graphicsMode.CLI: bool dbg = true; string data = String.Empty; string cancelChar = "d"; Console.WriteLine( "Enter the names of the players. Press <ENTER> after every player. Type '{0}' when done.", cancelChar ); do { data = Console.ReadLine(); if( ( data.Equals( cancelChar, StringComparison.OrdinalIgnoreCase ) || data.Equals( String.Empty ) ) && toReturn.Count == 0 ) { Console.WriteLine( "You must enter at least 1 valid player name." ); data = cancelChar + "crap"; } else if( !data.Equals( cancelChar, StringComparison.OrdinalIgnoreCase ) && !data.Equals( String.Empty ) ) { toReturn.Add( new Player( data, "" ) ); Console.WriteLine( "{0} has joined the game!", data ); Console.WriteLine(); } //bool a = !data.Equals( String.Empty ); bool b = !data.Equals( cancelChar, StringComparison.OrdinalIgnoreCase ); bool c = toReturn.Count <= 5; dbg = b & c; } while( dbg ); break; } return toReturn; }
void initAddPlayerWindow(PlayerCollection playerList) { this.Players = playerList; Players.Clear(); Player one = new Player("Frank", "Furters", "Necrons",false,0); Players.Add(one); Player two = new Player("Joe (AI:4)", "Shmoes", "Orks",true,4); Players.Add(two); InitializeComponent(); initIconSets(); lbxPlayerList.ItemsSource = Players; lbxPlayerList.UpdateLayout(); }
public void AddPlayerToGame(PlayerData playerData) { logService.Log($"Adding player to game state: {playerData.PlayerName}"); PlayerCollection.Add(playerData); }
public virtual void AddPlayer(Player player) { Players.Add(player); base.AddPlayer(player); }
public PlayerCollection<PlayerWithStats> CreatePlayerWithStatsCollection() { var players = this.CreatePlayerCollection(); var playersWithStats = new PlayerCollection<PlayerWithStats>(); foreach (var player in players) { playersWithStats.Add(new PlayerWithStats( player, new PlayerStats(), new PlayerPoints(2013, 200))); } return playersWithStats; }
public PlayerCollection PlayersWithLowestGoodsCount( PlayerCollection PlayersToCheck ) { PlayerCollection toReturn = new PlayerCollection(); toReturn.Add( PlayersToCheck[0] ); for( int i = 1; /* skipping the first player in the list */ i < PlayersToCheck.Count; i++ ) { if( PlayersToCheck[i].GoodsCount < toReturn[0].GoodsCount ) { toReturn.Clear(); toReturn.Add( PlayersToCheck[i] ); } else if( PlayersToCheck[i].GoodsCount == toReturn[0].GoodsCount ) { toReturn.Add( PlayersToCheck[i] ); } else // do nothing { } } return toReturn; }
public PlayerCollection PlayersWithHighestStrength( PlayerCollection PlayersToCheck ) { PlayerCollection toReturn = new PlayerCollection(); toReturn.Add( PlayersToCheck[0] ); for( int i = 1; i < PlayersToCheck.Count; i++ ) { if( PlayersToCheck[i].TotalStrength > toReturn[0].TotalStrength ) { toReturn.Clear(); toReturn.Add( PlayersToCheck[i] ); } else if( PlayersToCheck[i].NumBuildings == toReturn[0].NumBuildings ) { toReturn.Add( PlayersToCheck[i] ); } else { } // do nothing } return toReturn; }
/// <summary> /// Updates the list of client names in the window /// </summary> /// <param name="players">The list of players to add</param> public void UpdateClientList(List<Player> players) { if (InvokeRequired) { Invoke(new PlayerListCallback(UpdateClientList), players); } else { if (dgvPlayers.DataSource == null) dgvPlayers.DataSource = pc; string selected = null; if (pc.Count > 0 && dgvPlayers.SelectedRows.Count > 0) { selected = (from DataGridViewRow row in dgvPlayers.Rows where row.Selected select pc[row.Index]).First().name; } dgvPlayers.SuspendLayout(); pc = new PlayerCollection(new PlayerListView()); Player.players.ForEach(p => pc.Add(p)); dgvPlayers.Invalidate(); dgvPlayers.DataSource = pc; if (selected != null) { foreach (Player t in Player.players) for (int j = 0; j < dgvPlayers.Rows.Count; j++) if (Equals(dgvPlayers.Rows[j].Cells[0].Value, selected)) dgvPlayers.Rows[j].Selected = true; } dgvPlayers.Refresh(); dgvPlayers.ResumeLayout(); } }
/// <summary> /// Updates the list of client names in the window /// </summary> /// <param name="players">The list of players to add</param> public void UpdateClientList(List<Player> players) { if (this.InvokeRequired) { PlayerListCallback d = UpdateClientList; Invoke(d, new List<Player>[] { players }); } else { if (dgvPlayers.DataSource == null) dgvPlayers.DataSource = pc; // Try to keep the same selection on update string selected = null; if (pc.Count > 0 && dgvPlayers.SelectedRows.Count > 0) { selected = (from DataGridViewRow row in dgvPlayers.Rows where row.Selected select pc[row.Index]).First().name; } // Update the data source and control //dgvPlayers.SuspendLayout(); pc = new PlayerCollection(new PlayerListView()); Player.players.ForEach(p => pc.Add(p)); //dgvPlayers.Invalidate(); dgvPlayers.DataSource = pc; // Reselect player if (selected != null) { for (int i = 0; i < Player.players.Count; i++) for (int j = 0; j < dgvPlayers.Rows.Count; j++) if (String.Equals(dgvPlayers.Rows[j].Cells[0].Value, selected)) dgvPlayers.Rows[j].Selected = true; } dgvPlayers.Refresh(); //dgvPlayers.ResumeLayout(); } }
public PlayerCollection PlayersWithLowestBuildingCount( PlayerCollection PlayersToCheck ) { PlayerCollection toReturn = new PlayerCollection(); toReturn.Add( PlayersToCheck[0] ); for( int i = 1; /* skipping the first player in the list */ i < PlayersToCheck.Count; i++ ) { if( PlayersToCheck[i].NumBuildings < toReturn[0].NumBuildings ) { toReturn.Clear(); toReturn.Add( PlayersToCheck[i] ); } else if( PlayersToCheck[i].NumBuildings == toReturn[0].NumBuildings ) { toReturn.Add( PlayersToCheck[i] ); } else { } // do nothing } return toReturn; }