Exemplo n.º 1
0
 private void InitPlayers()
 {
     players = new Players();
     players.AddPlayer(Settings.Player1Name, Settings.Player1AvaImage);
     players.AddPlayer(Settings.Player2Name, Settings.Player2AvaImage);
     players.AddPlayer(Settings.Player3Name, Settings.Player3AvaImage);
 }
Exemplo n.º 2
0
        public static void Process(ClientInfo packet, int peerID)
        {
            Players players = InstanceKeeper.players;

            players.AddPlayer(packet.Name, peerID);
            InstanceKeeper.players = players;
        }
Exemplo n.º 3
0
    // 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);
        //}
    }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
    //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);
    }
Exemplo n.º 7
0
        public async Task Register(string userName)
        {
            var connId = Context.ConnectionId;

            msg = Players.AddPlayer(userName, connId);

            await SendToAll(msg);
        }
Exemplo n.º 8
0
        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);
         }
     }
 }
Exemplo n.º 11
0
        public async void HandleValidSubmit()
        {
            Console.WriteLine("PlayerForm::HandleValidSubmit");
            if (Player.Id == null)
            {
                Player = await playerService.AddPlayer(Player);

                Players.AddPlayer(Player);
            }
            else
            {
                playerService.UpdatePlayer(Player);
            }
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
    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");
        }
    }
Exemplo n.º 14
0
 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");
     }
 }
Exemplo n.º 15
0
 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));
     }
 }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
    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);
    }
Exemplo n.º 19
0
    // 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!");
            }
        }
    }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
 public void AddPlayer(string playerName)
 {
     _players.AddPlayer(CreateNewPlayer(playerName));
 }
Exemplo n.º 22
0
 public void AddPlayer(IPlayer player)
 {
     Players.AddPlayer(new TournPlayer(player));
 }
Exemplo n.º 23
0
 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);
 }
Exemplo n.º 25
0
 /// <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);
 }