private void InitPlayers() { players = new Players(); players.AddPlayer(Settings.Player1Name, Settings.Player1AvaImage); players.AddPlayer(Settings.Player2Name, Settings.Player2AvaImage); players.AddPlayer(Settings.Player3Name, Settings.Player3AvaImage); }
public static void Process(ClientInfo packet, int peerID) { Players players = InstanceKeeper.players; players.AddPlayer(packet.Name, peerID); InstanceKeeper.players = players; }
// called when a new player is added for a client public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) { base.OnServerAddPlayer(conn, playerControllerId); GameObject playerGO = null; for (int i = 0; i < conn.playerControllers.Count; i++) { PlayerController playerController = conn.playerControllers[i]; if (playerController.playerControllerId == playerControllerId) { playerGO = playerController.gameObject; } } if (playerGO) { _players.AddPlayer(playerGO); } //GameManager gm = GameManager.Instance; //if (gm && playerGO) //{ // Player player = playerGO.GetComponent<Player>(); // gm.AddPlayer(player); //} }
/// <summary> /// Adds user to the list of players, without signalR connection ID (added in JoinGameChat method) /// Async and overrideable so that games can allow hosts to permit/reject each player /// </summary> /// <param name="user"></param> /// <param name="joinGameData"></param> /// <returns></returns> public virtual async Task <bool> JoinGameWithoutChat(User user, string joinGameData) { var player = new Player(user, null); Players.AddPlayer(player); return(true); }
public async Task RegisterPlayer(string playerName, string lang, bool watchOnly) { try { // If lang is not supported - default it to en-US if (lang == "ml" || lang == "ml-IN") { lang = "ml-IN"; } else { lang = "en-US"; } Context.Items.Add("Lang", lang); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang); // Save the player's name to a list of players Player player = Players.AddPlayer(Context.ConnectionId, playerName, lang, watchOnly); // Return player and the list of tables await Clients.Caller.OnRegisterPlayerCompleted(player); } catch (System.Exception e) { await Clients.Caller.OnError((e is Card56Exception)?((Card56Exception)e).ErrorData.ErrorCode : 0, Cards56HubMethod.RegisterPlayer, e.Message, (e is Card56Exception)?((Card56Exception)e).ErrorData : null); } }
//public IEnumerator get_exercises(MatchClass currentMatch, int tokenPosition) // change //{ // Set ExerciseClass currentExercise = random exercise depending on the current token //position and currentMatch . currentStage // bool isSuccessful = false; // WWWForm wwwForm = new WWWForm(); // wwwForm.AddField("id", 0); // WWW www = new WWW(server + path + "get_exercises.php", wwwForm); // yield return www; //Debug.LogError(www.text.Trim()); // string difficulty = ""; // if (www.error == null) // { // isSuccessful = true; // exercise = exercise.DeserializeObject(www.text.Trim()); //if (tokenPosition < 8) //{ difficulty = "Easy"; } //else if (tokenPosition < 16) { difficulty = "Medium"; } //else difficulty = "Hard"; // List<ExerciseClass> matchedExercise; // foreach(ExerciseClass exercise in currentMatch) // { // if (exercise.Difficulty == "Hard") // matchedExercise.Add(exercise); //} // } //else // Debug.LogError(www.error); //return matchedExercise[0bo]; //callback(isSuccessful); public IEnumerator AddPlayer(PlayerClass player, System.Action <bool> callback) { bool isSuccessful = false; WWWForm wwwForm = new WWWForm(); wwwForm.AddField("username", player.Name); wwwForm.AddField("email", player.Email); WWW www = new WWW(server + path + "Add_player.php", wwwForm); yield return(www); if (www.error == null) { players.AddPlayer(player); if (!www.text.Contains("false")) { isSuccessful = true; } } else { Debug.LogError(www.error); } callback(isSuccessful); }
public async Task Register(string userName) { var connId = Context.ConnectionId; msg = Players.AddPlayer(userName, connId); await SendToAll(msg); }
public void CanAddAndRemovePlayer() { var playerName = "Test1"; Assert.IsFalse(Players.IsPlayer(playerName), $"{playerName} is already a player"); Assert.IsTrue(Players.AddPlayer(playerName), $"Did not successfully add {playerName}"); Assert.IsTrue(Players.IsPlayer(playerName), $"Could not find {playerName}"); Assert.IsTrue(Players.RemovePlayer(playerName), $"Could not remove {playerName}"); Assert.IsFalse(Players.IsPlayer(playerName), $"{playerName} was not removed"); }
internal void AddFakeClient(Player pl) { //Debug.LogError("AddFakeClient=" + m_FakeClient); if (pl == null || m_FakeClient != null) { return; } m_FakeClient = pl; pl.ID = GenericPlayerID(); m_Players.AddPlayer(pl); StartCoroutine(WaitFakeClient()); }
void Awake() { Debug.Log("Instantiating players"); Players.Refresh(); { for (int i = 0; i < 4; i++) { Player player = new Player((Player.ID)i); Players.AddPlayer(player); } } }
public async void HandleValidSubmit() { Console.WriteLine("PlayerForm::HandleValidSubmit"); if (Player.Id == null) { Player = await playerService.AddPlayer(Player); Players.AddPlayer(Player); } else { playerService.UpdatePlayer(Player); } }
protected void DoPlayerAdd(ServerPlayer player) { player.ActualTeam = TeamColors.ObserverTeam; PlayerPreAdd?.Invoke(this, player); // let someone set the team if (!Players.AddPlayer(player)) { SendReject(player, MsgReject.RejectionCodes.RejectTeamFull, Resources.TeamFullMessage.Replace("%T", player.DesiredTeam.ToString())); return; } player.NeedStartupInfo = false; UpdatePublicListServer?.Invoke(this, EventArgs.Empty); }
public void AddPlayer() { if (NumPlayers < 4) { GameObject tempGO = Instantiate(PIC, Holder); RectTransform rtTemp = tempGO.GetComponent <RectTransform>(); rtTemp.localPosition = new Vector2(((rtTemp.rect.width + spacing) * NumPlayers) + 10, -10); //Debug.Log("setting player number " + NumPlayers); tempGO.GetComponent <PlayerInfoContainer>().SetNumber(NumPlayers); tempGO.GetComponent <PlayerInfoContainer>().players = players; tempGO.GetComponent <PlayerInfoContainer>().AP = GetComponent <AddingPlayers>(); NumPlayers++; PlayerInfoContainers.Add(tempGO); players.AddPlayer(NumPlayers - 1); tempGO.GetComponent <PlayerInfoContainer>().SetAlliance(NumPlayers - 1); APforUnitPlacement.ClearOptions(); selectedowner.ClearOptions(); playernums.Clear(); for (int j = 0; j < NumPlayers; j++) { playernums.Add("Player " + (j + 1)); } Active = tempGO; N = true; for (int k = 0; k < NumPlayers; k++) { if (ColorsBeingUsed.Contains(k) == false) { SelectColor(k); break; } } APforUnitPlacement.AddOptions(playernums); selectedowner.AddOptions(playernums); //APforUnitPlacement.itemImage.color = Color.green; } else { Debug.Log("Maximum Players"); } }
private void buttonAdd_Click(object sender, EventArgs e) { try { Teams team = (Teams)comboBoxTeam.SelectedItem; Players p = new Players(int.Parse(textBoxPlayerId.Text), textBoxPlayerName.Text, textBoxPlayerEmail.Text, team); Players.AddPlayer(p); MessageBox.Show("Player has been Saved", "Information"); } catch (Exception ex) { MessageBox.Show("Player cannot be saved. Error Message: " + ex.Message, "Error"); } }
public MultiplayerGame(User host, IServiceProvider services, Action <string> gameEndCallBack, string gameName = null) { this.Host = host; this.Ticks = 0; this.Id = gameName ?? Guid.NewGuid().ToString().Substring(0, 6); this.TicksPerSecond = 60f; this.Services = services; this.GameEndCallBack = gameEndCallBack; this.GameOver = false; this.Players = new PlayerCache(); if (host != null) { Players.AddPlayer(new Player(host)); } }
public void GameWithSixPlayersContainsSix() { _players = new PokerPlayers(6); _players.AddPlayer(new DummyPlayer("Test1")); _players.AddPlayer(new DummyPlayer("Test2")); _players.AddPlayer(new DummyPlayer("Test3")); _players.AddPlayer(new DummyPlayer("Test4")); _players.AddPlayer(new DummyPlayer("Test5")); _players.AddPlayer(new DummyPlayer("Test6")); _players.Players().Should().HaveCount(6); }
public void PlayersAreAddedInOrder() { var player1Name = "Test1"; var player2Name = "Test2"; var player3Name = "Test3"; Assert.IsTrue(Players.AddPlayer(player1Name), $"Did not successfully add {player1Name}"); Assert.IsTrue(Players.AddPlayer(player2Name), $"Did not successfully add {player2Name}"); Assert.IsTrue(Players.AddPlayer(player3Name), $"Did not successfully add {player3Name}"); Assert.AreEqual(Players.PlayerCount(), 3, $"Expected a number of players but did not find them"); var players = Players.GetPlayers(); Assert.AreEqual(3, players.Count); Assert.AreEqual(player1Name, players[0].Controller); Assert.AreEqual(player2Name, players[1].Controller); Assert.AreEqual(player3Name, players[2].Controller); }
public void Start() { this.players = new Players(NumOfPlayers); TileInHand = stack.Pop(); players.AddPlayer(new HumanPlayer("PrvniHrac", PlayerColor.Y)); players.AddPlayer(new HumanPlayer("DruhyHrac", PlayerColor.B)); players.AddPlayer(new HumanPlayer("TretiHrac", PlayerColor.G)); players.AddPlayer(new HumanPlayer("CtvrtyHrac", PlayerColor.V)); players.AddPlayer(new HumanPlayer("PatyHrac", PlayerColor.O)); players.AddPlayer(new HumanPlayer("SestyHrac", PlayerColor.R)); TileController.Instance.DisplayTileInHand(TileInHand.Type, players.GetPlayerOnMove().Color); }
// Update is called once per frame void Update() { foreach (var controller in possibleControllers) { if (Input.GetButtonDown($"{controller} Select")) { if (Players.IsPlayer(controller)) { Debug.Log($"{controller} is already in game!"); } else { Players.AddPlayer(controller); Debug.Log($"{controller} added to the game!"); } } if (Input.GetButtonDown($"{controller} Submit")) { if (Players.IsPlayer(controller)) { Debug.Log($"{controller} is in game and wants to start!"); SceneManager.LoadScene("SampleScene", LoadSceneMode.Single); } else { Debug.Log($"{controller} is not in the game so can't start it."); } } if (Input.GetButtonDown($"{controller} Cancel")) { Players.RemovePlayer(controller); Debug.Log($"{controller} is in game and wants out!"); } } }
public void RemovingAPlayerLetsYouAddANewOneInTheirPlace() { var player1Name = "Test1"; var player2Name = "Test2"; var player3Name = "Test3"; var player4Name = "Test3"; Assert.IsTrue(Players.AddPlayer(player1Name), $"Did not successfully add {player1Name}"); Assert.IsTrue(Players.AddPlayer(player2Name), $"Did not successfully add {player2Name}"); Assert.IsTrue(Players.AddPlayer(player3Name), $"Did not successfully add {player3Name}"); Assert.IsTrue(Players.RemovePlayer(player2Name), $"Did not successfully remove {player2Name}"); Assert.AreEqual(Players.PlayerCount(), 2, $"Expected a number of players but did not find them"); Assert.IsTrue(Players.AddPlayer(player4Name), $"Did not successfully add {player4Name}"); var players = Players.GetPlayers(); Assert.AreEqual(3, players.Count); Assert.AreEqual(player1Name, players[0].Controller); Assert.AreEqual(player4Name, players[1].Controller); Assert.AreEqual(player3Name, players[2].Controller); }
public void AddPlayer(string playerName) { _players.AddPlayer(CreateNewPlayer(playerName)); }
public void AddPlayer(IPlayer player) { Players.AddPlayer(new TournPlayer(player)); }
public void PlayerJoinsGameWithNoPlayersGameHasTwoPlayers() { _players.AddPlayer(new DummyPlayer("Test")); _players.Players().Should().Contain(p => p.Name == "Test"); }
Player AddPlayer(Player player) { m_Players.AddPlayer(player); return(player); }
/// <summary> /// <summary> /// Async and overrideable so that games can allow hosts to permit/reject each player /// </summary> /// <param name="user"></param> /// <param name="signalRConnectonId"></param> /// <returns></returns> public virtual async Task <bool> JoinGameChat(User user, string signalRConnectonId) { Players.AddPlayer(new Player(user, signalRConnectonId)); return(true); }