Ejemplo n.º 1
0
    // -------------------------------------------------------------------------------------------------------------------
    // Called on all clients+server when NetworkManager has determined that the game is ready to go
    //
    // Initialises the class and tells all others that we are ready to start
    void OnGameSetup()
    {
        logger.Debug("Game setup, my Player ID: " + PhotonNetwork.player.ID);

        m_lockStepTurnId  = 0;
        m_simulationCount = 0;
        m_numberOfPlayers = NetworkManager.instance.playerCount;

        InitGameStartLists();

        m_pendingCommands   = new PendingCommands(m_numberOfPlayers);
        m_confirmedCommands = new ConfirmedCommands(m_numberOfPlayers);


        m_nv.RPC("ReadyToStart", PhotonTargets.OthersBuffered, PhotonNetwork.player.ID);
    }
    // -------------------------------------------------------------------------------------------------------------------

    public void AddCommand(PhotonPlayer player, int lockStepTurn, int commandsLockStepTurn)
    {
        if (commandsLockStepTurn == lockStepTurn)
        {
            m_playersConfirmedCurrentCommand.Add(player);
        }
        else if (commandsLockStepTurn == lockStepTurn - 1)
        {
            m_playersConfirmedPriorCommand.Add(player);
        }
        else
        {
            //TODO: Error Handling
            logger.Debug("WARNING!!!! Unexpected lockstepID Confirmed : " + lockStepTurn + " from player: " + player.ToString());
        }
    }
Ejemplo n.º 3
0
    public void AddCommand(Command command, int playerID, int lockStepTurn, int commandsLockStepTurn)
    {
        logger.Debug("Player " + playerID + " added pending command for turn " + commandsLockStepTurn);

        int index = commandsLockStepTurn - lockStepTurn + 2;

        if ((index <= 0) || (index > (m_nofTurns - 1)))
        {
            logger.Error("WARNING!!!! Unexpected lockstepID " + commandsLockStepTurn + " received"); //TODO: Error Handling
            return;
        }

        // if command is for next turn, add for processing 3 turns away
        if (m_commands[index][playerID - 1] != null)
        {
            logger.Error("WARNING!!!! Recieved multiple commands from player " + playerID + " for turn " + commandsLockStepTurn); //TODO: Error Handling
        }
        m_commands[index][playerID - 1] = command;
        m_commandCounts[index]++;

        return;
    }
    // -------------------------------------------------------------------------------------------------------------------

    private void OnDisconnectedFromPhoton()
    {
        logger.Debug("Disconnected from photon");
    }