コード例 #1
0
    public void StartNextRound(NetworkedGameState gameState)
    {
        RoundInfo info = new RoundInfo();

        info.floorName = SceneManager.GetActiveScene().name;
        //Debug.Log("Adding floor info for scene: \"" + info.floorName + "\"");

        info.floorStartTime = (float)(DateTime.Now - sessionStart).TotalSeconds;
        //Debug.Log("Floor started at: " + info.floorStartTime.ToString("0.000") + " seconds");

        info.startingScores = new Dictionary <int, int>();

        foreach (KeyValuePair <int, int> score in gameState.GetAllScores())
        {
            info.startingScores[score.Key] = score.Value;
            //Debug.Log("Player" + score.Key + "'s starting score recorded as: " + score.Value);
        }

        info.tableyPlayerNum = SessionManager.Singleton.tabletPlayer;
        //Debug.Log("Mission Control player set to: " + info.tableyPlayerNum);

        info.interactions = new List <InteractionInfo>();

        currentRoundActions = info.interactions;
        rounds.Add(info);
    }
コード例 #2
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Public Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    //Set the networked game state
    //Expected to be called by the NetworkedGameState once added to the scene
    public void SetNetworkedGameState(NetworkedGameState gameState)
    {
        //if (networkedGameState != null) {
        //    Debug.LogWarning("Overriding networked game state. Is there two in the scene?");
        //}
        networkedGameState = gameState;
    }
コード例 #3
0
    public void StartSession(NetworkedGameState gameState)
    {
        sessionStart      = DateTime.Now;
        session.startTime = sessionStart.ToString("yyyy-MM-dd HH:mm:ss");
        Debug.Log("Session start time: " + session.startTime);

        Dictionary <int, PlayerInfo> players = gameState.GetAllPlayers();

        if (session.usersInSession == null)
        {
            session.usersInSession = new Dictionary <int, string>();
        }
        else
        {
            session.usersInSession.Clear();
        }

        foreach (KeyValuePair <int, PlayerInfo> player in players)
        {
            session.usersInSession[player.Key] = player.Value.username;
            Debug.Log("Player" + player.Key + "'s username recorded as \"" + session.usersInSession[player.Key] + "\"");
        }

        currentRoundActions = null;
    }
コード例 #4
0
    void Update()
    {
        //Listen for new players hitting "start" on their controllers
        CheckForControllerAssignment();

        //Spawn the networked game state if not already spawned
        if (networkedGameState == null && (NetworkingManager.Singleton.IsHost || NetworkingManager.Singleton.IsServer))  //&& ConnectionManager.Singleton.GetState() == ConnectionState.CONNECTED
        //Server running but networkedGameState not set, create a new one
        {
            GameObject newSpawn = Instantiate(networkedGameStatePrefab);

            networkedGameState = newSpawn.GetComponent <NetworkedGameState>();
            if (networkedGameState == null)
            {
                Debug.LogError("NetworkedGameStatePrafab does not have a NetworkedGameState component!");
            }
            else
            {
                //Spawn over the network
                newSpawn.GetComponent <NetworkedObject>().Spawn(destroyWithScene: false); //by default spawns with the server as the owner
            }
        }
    }