Exemplo n.º 1
0
    public void ChangeState(RaceState raceState)
    {
        m_raceState = raceState;

        switch (raceState)
        {
        case RaceState.Loading:
            break;

        case RaceState.BeforeStartAnimation:
            for (int i = 0; i < m_carCount; ++i)
            {
                m_carControllers[i].ChangeState(CarController.CarState.BeforeStart);
            }
            m_raceAnimationDirector.StartBeforeStartAnimation();
            break;

        case RaceState.StartTime:
            m_raceAnimationDirector.DisableCamera();
            m_startTime = m_timeBeforeStart;
            m_uiDisplayer.ChangeState(UIDisplayer.UIState.StartTime);
            break;

        case RaceState.Race:
            for (int i = 0; i < m_carCount; ++i)
            {
                m_carControllers[i].ChangeState(CarController.CarState.Race);
            }
            if (m_IACarController != null)
            {
                foreach (IAController iaController in m_IACarController)
                {
                    iaController.StartRace();
                }
            }
            m_uiDisplayer.ChangeState(UIDisplayer.UIState.Race);
            break;

        case RaceState.Finishing:
            m_finishTime = m_timeAfterFirstArrival;
            for (int i = 0; i < m_carCount; ++i)
            {
                m_carControllers[i].ChangeState(CarController.CarState.Race);
            }
            m_uiDisplayer.ChangeState(UIDisplayer.UIState.Finishing);
            break;

        case RaceState.RaceFinished:
            m_sceneMaster.LoadResultsScreenInRace();
            for (int i = 0; i < m_carCount; ++i)
            {
                if (!m_carControllers[i].HasFinished())
                {
                    m_carControllers[i].ChangeState(CarController.CarState.RaceFinished);
                }
            }
            if (m_IACarController != null)
            {
                foreach (IAController iaController in m_IACarController)
                {
                    iaController.EndRace();
                }
            }
            m_uiDisplayer.ChangeState(UIDisplayer.UIState.Finished);
            m_raceAnimationDirector.StartAfterEndAnimation();
            break;
        }
    }