Example #1
0
    public override void AddPlayer(string name, PlayerColor color)
    {
        GameObject playerGo = Instantiate(playerPrefab);

        playerGo.GetComponent <RectTransform>().SetParent(transform, false);
        JoPlayer player = playerGo.GetComponent <JoPlayer>();

        player.Setup(name, color, PopPosition());
        player.Show(0);
        players.Add(player);
    }
Example #2
0
    public void WordSubmitted(JsonNode message)
    {
        JOPlayers allPlayers = players as JOPlayers;
        JoPlayer  player     = allPlayers.GetPlayer(message["name"]) as JoPlayer;

        player.guessedWord = message["word"].ToString().ToUpper();
        player.OffScreen(0, () => {
            int submittedCount = allPlayers.PlayersSubmittedCount();
            int totalPlayers   = allPlayers.PlayerCount();
            if (allPlayers.PlayersSubmittedCount() == allPlayers.PlayerCount())
            {
                // compare all words
                List <JoPlayer> uniques = allPlayers.GetUniques();

                // show off the answers
                if (uniques.Count > 0)
                {
                    float delay = 0;
                    for (int i = 0; i < uniques.Count; i++)
                    {
                        JoPlayer uniquePlayer = uniques[i];
                        uniquePlayer.SetWord(uniquePlayer.guessedWord);
                        uniquePlayer.Show(delay);
                        delay += 0.3f;
                    }
                }

                // tell guessing player we are ready for a guess
                JsonObject rtgMessage = new JsonObject();
                rtgMessage.Add("gameType", "JO");
                rtgMessage.Add("messageType", "READY_TO_GUESS");
                rtgMessage.Add("player", guessingPlayer.name);
                server.SendMessage(rtgMessage);
            }
        });
    }