//-----------------------------------------------------------------------------
    // Purpose: Game state has changed
    //-----------------------------------------------------------------------------
    public void OnGameStateChange(EClientGameState eNewState)
    {
        if (!m_bStatsValid)
        {
            return;
        }

        if (eNewState == EClientGameState.k_EClientGameActive)
        {
            // Reset per-game stats
            m_flGameFeetTraveled   = 0;
            m_ulTickCountGameStart = Time.time;
        }
        else if (eNewState == EClientGameState.k_EClientGameWinner || eNewState == EClientGameState.k_EClientGameLoser)
        {
            if (eNewState == EClientGameState.k_EClientGameWinner)
            {
                m_nTotalNumWins++;
            }
            else
            {
                m_nTotalNumLosses++;
            }

            // Tally games
            m_nTotalGamesPlayed++;

            // Accumulate distances
            m_flTotalFeetTraveled += m_flGameFeetTraveled;

            // New max?
            if (m_flGameFeetTraveled > m_flMaxFeetTraveled)
            {
                m_flMaxFeetTraveled = m_flGameFeetTraveled;
            }

            // Calc game duration
            m_flGameDurationSeconds = Time.time - m_ulTickCountGameStart;

            // We want to update stats the next frame.
            m_bStoreStats = true;
        }
    }
コード例 #2
0
	//-----------------------------------------------------------------------------
	// Purpose: Game state has changed
	//-----------------------------------------------------------------------------
	public void OnGameStateChange(EClientGameState eNewState) {
		if (!m_bStatsValid)
			return;

		if (eNewState == EClientGameState.k_EClientGameActive) {
			// Reset per-game stats
			m_flGameFeetTraveled = 0;
			m_ulTickCountGameStart = Time.time;
		}
		else if (eNewState == EClientGameState.k_EClientGameWinner || eNewState == EClientGameState.k_EClientGameLoser) {
			if (eNewState == EClientGameState.k_EClientGameWinner) {
				m_nTotalNumWins++;
			}
			else {
				m_nTotalNumLosses++;
			}

			// Tally games
			m_nTotalGamesPlayed++;

			// Accumulate distances
			m_flTotalFeetTraveled += m_flGameFeetTraveled;

			// New max?
			if (m_flGameFeetTraveled > m_flMaxFeetTraveled)
				m_flMaxFeetTraveled = m_flGameFeetTraveled;

			// Calc game duration
			m_flGameDurationSeconds = Time.time - m_ulTickCountGameStart;

			// We want to update stats the next frame.
			m_bStoreStats = true;
		}
	}