Exemplo n.º 1
0
    /* SetInactive: este método frenará al jugador una vez haya completado todas las vueltas,
     * paramos sus tiempos totales y por vuelta y lo transportamos a la zona de podio
     */
    public void SetInactive()
    {
        totalTime.Stop();
        if (isLocalPlayer)
        {
            Stopwatch aux = LapTime[0];
            for (int i = 0; i < numVueltas; i++)
            {
                if (LapTime[i].Elapsed.TotalMilliseconds < aux.Elapsed.TotalMilliseconds)
                {
                    aux = LapTime[i];
                }
            }
            m_PlayerInfo.FinalTime   = (TimeToString(totalTime));
            m_PlayerInfo.BestLapTime = (TimeToString(aux));
            mutexTimes.WaitOne();
            CmdUpdateTime(m_PlayerInfo.FinalTime, m_PlayerInfo.BestLapTime);
            mutexTimes.ReleaseMutex();
        }

        WheelFrictionCurve friction = axleInfos[0].leftWheel.forwardFriction;

        m_Rigidbody.velocity        = Vector3.zero;
        m_Rigidbody.angularVelocity = Vector3.zero;
        m_PolePositionManager.SetPosInRanking();
        transform.LookAt(m_PolePositionManager.target.transform.position);
        transform.position = posRanking;
        foreach (var axleInfo in axleInfos)
        {
            friction.extremumSlip                = 100;
            axleInfo.leftWheel.motorTorque       = 0;
            axleInfo.rightWheel.motorTorque      = 0;
            axleInfo.leftWheel.brakeTorque       = 1e+30f;
            axleInfo.rightWheel.brakeTorque      = 1e+30f;
            axleInfo.leftWheel.forwardFriction   = friction;
            axleInfo.rightWheel.forwardFriction  = friction;
            friction.extremumSlip                = 0.3f;
            axleInfo.rightWheel.sidewaysFriction = friction;
            axleInfo.leftWheel.sidewaysFriction  = friction;
        }
        isReady = false;
    }