Exemplo n.º 1
0
 void OnSetDeck(NetMessage msg)
 {
     // Wait a frame to ensure that DeckManager sets the deck before referencing it
     Co.WaitForFixedUpdate(() => {
         Game.Dispatcher.ScheduleMessage("StartGame");
         Co.YieldWhileTrue(() => { return(!Game.Controller.DataLoaded); }, () => {
             AllGotoView("roles");
         });
     });
 }
Exemplo n.º 2
0
 public void SetAsHighestValue()
 {
     Co.WaitForFixedUpdate(() => {
         crown.gameObject.SetActive(true);
     });
 }
Exemplo n.º 3
0
    void GotoView(string id)
    {
        // Skip ahead to the view with the given id
        // This must be called *before* any players have been added - it "fakes" a game playthrough
        // (only for testing purposes)

        bool beforeLobby  = id == "start" || id == "hostjoin";
        bool beforeDeck   = beforeLobby || id == "lobby" || id == "games";
        bool beforeBio    = beforeDeck || id == "roles" || id == "pot";
        bool beforeWinner = beforeBio || id == "agenda" || id == "question" || id == "think_instructions" || id == "think" || id == "pitch_instructions" || id == "pitch" || id == "extra_time" || id == "deliberate_instructions" || id == "deliberate" || id == "extra_time_deliberate" || id == "decide";
        bool deck         = id == "deck";

        // Create host
        AddPlayer();

        if (beforeLobby)
        {
            instances[0].Views.Goto(id);
            for (int i = 1; i < 3; i++)
            {
                AddPlayer();
                instances[i].Views.Goto(id);
            }
            return;
        }

        instances[0].StartGame();
        instances[0].Multiplayer.HostGame((ResponseType res) => {
            if (res != ResponseType.Success)
            {
                Debug.LogWarning("Failed to run test because the host name is already being used by another open room.");
                return;
            }

            // Move the host to the view
            if (deck)
            {
                instances[0].Views.Goto("deck");
            }
            else if (beforeDeck)
            {
                instances[0].Views.Goto(id);
            }

            string hostName = instances[0].Name;
            string roomId   = instances[0].Multiplayer.RoomId;

            // Create the other players
            for (int i = 1; i < 3; i++)
            {
                AddPlayer();
                GameInstance gi = instances[i];

                gi.Multiplayer.JoinGame(hostName, roomId, (ResponseType response) => {
                    gi.StartGame();
                });
            }
        });


        // WARNING: js-style callback hell approaching
        // Wait for clients to connect
        Co.YieldWhileTrue(() => { return(!ClientsConnected()); }, () => {
            if (deck)
            {
                instances[0].Views.AllGoto("deck");
            }
            else if (!beforeDeck)
            {
                instances[0].Dispatcher.AddListener("SetDeck", (NetMessage msg) => {
                    Co.WaitForFixedUpdate(() => {
                        // Once the deck has been set, start the game
                        instances[0].Dispatcher.ScheduleMessage("StartGame");

                        // Once the data has loaded, send all players to the supplied view
                        Co.YieldWhileTrue(() => { return(instances.Find(x => !x.Controller.DataLoaded) != null); }, () => {
                            // If the view happens at or after the winner screen, choose a winner
                            if (!beforeWinner)
                            {
                                string winner = System.Array.Find(instances[0].Controller.Roles, x => x.Title != "Decider").PlayerName;
                                for (int i = 0; i < instances.Count; i++)
                                {
                                    instances[i].Controller.SetWinner(winner);
                                }
                            }

                            instances[0].Views.AllGoto(id);

                            // If the view comes after the pot screen, set the scores
                            if (!beforeBio)
                            {
                                for (int i = 0; i < instances.Count; i++)
                                {
                                    instances[i].Score.FillPot();
                                    instances[i].Score.AddRoundStartScores();
                                }
                            }
                        });
                    });
                });

                // Set the default deck
                instances[0].Dispatcher.ScheduleMessage("SetDeck", "Civic");
            }
        });
    }
Exemplo n.º 4
0
 protected override void OnSetActive(bool active)
 {
     Co.WaitForFixedUpdate(() => {          // eh, not proud of this hack
         scoreText.ApplyStyle(Style);
     });
 }