Ejemplo n.º 1
0
    // Debug GUI. Disable when not needed.
    void OnGUI()
    {
        if (UIManager.C_USE_NEW_UI == false)
        {
            Drivetrain gear;
            gear = gameObject.GetComponent("Drivetrain") as Drivetrain;

            GUI.skin = mySkin;
            var style1 = mySkin.customStyles[0];
            var speed  = rigidbody.velocity.magnitude * 3.6f;
            GUI.Box(new Rect(0, Screen.height - 120, 140, 55), "", GUI.skin.FindStyle("Box"));
            GUI.Label(new Rect(100, Screen.height - 50, 100, 400), "" + speed.ToString("F0"), style1);
            GUI.Label(new Rect(40, Screen.height - 50, 100, 400), "KM/H : ");
            tractionControl = GUI.Toggle(new Rect(80, Screen.height - 70, 30, 20), tractionControl, "TC");
            gear.automatic  = GUI.Toggle(new Rect(120, Screen.height - 70, 30, 20), gear.automatic, "T/A");

            if (carCamCtrl == null)
            {
                GameObject go = GameObject.Find("Car Camera");
                if (go != null)
                {
                    carCamCtrl = go.GetComponent <CarCameraController>();
                }
            }
            if (carCamCtrl != null)
            {
                bool val = GUI.Toggle(new Rect(160, Screen.height - 70, 30, 20), carCamCtrl.useThirdCamera, "Cam");
                if (val != carCamCtrl.useThirdCamera)
                {
                    carCamCtrl.useThirdCamera = val;
                    carCamCtrl.ApplyCameraSetting();
                }
            }
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (carCamCtrl == null)
        {
            GameObject go = GameObject.Find("Car Camera");
            if (go != null)
            {
                carCamCtrl = go.GetComponent <CarCameraController>();
            }
        }

        if (UIManager.GetInst().MainPlayerCarCtrl != null)
        {
            int speed = (int)(UIManager.GetInst().MainPlayerCarCtrl.rigidbody.velocity.magnitude * 3.6f);
            speedText.text = speed.ToString() + " kmh";
            gearText.text  = "[" + UIManager.GetInst().MainPlayerCarCtrl.CurGear.ToString() + "]";
        }
        else
        {
            speedText.text = "0 kmh";
            gearText.text  = "[1]";
        }

        float maxWidth = (nitroTrans.parent as RectTransform).rect.width;

        if (UIManager.GetInst().MainPlayerCarCtrl != null)
        {
            Drivetrain dt = UIManager.GetInst().MainPlayerCarCtrl.GetComponent <Drivetrain>();
            nitroTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, dt.curNitroContainer / dt.NitroContainerMax * maxWidth);
        }
        else
        {
            nitroTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, maxWidth);
        }

        lapText.text         = "";
        rankingText.text     = "";
        bestLapTimeText.text = "";

        if (lapCollector != null)
        {
            float bestLapTime      = -1.0f;
            SinglePlayerLapInfo pi = lapCollector.GetLocalPlayerLapInfo(ref bestLapTime);
            if (pi != null)
            {
                if (lapCollector.maxLap <= 0)
                {
                    lapText.text = "Lap " + (pi.mLapIndex + 1).ToString();
                }
                else
                {
                    lapText.text = "Lap " + (pi.mLapIndex + 1).ToString() + " / " + lapCollector.maxLap.ToString();
                }

                float lapTime = Time.realtimeSinceStartup - pi.mStartTimeStamp;
                if (lapTime < 60.0f)
                {
                    rankingText.text = lapTime.ToString("#0.00");
                }
                else if (lapTime < 3600.0f)
                {
                    int   m = (int)lapTime / 60;
                    float s = lapTime - m * 60.0f;
                    rankingText.text = m.ToString() + ":" + s.ToString("#0.00");
                }

                if (bestLapTime > 0.0f)
                {
                    if (bestLapTime < 60.0f)
                    {
                        bestLapTimeText.text = bestLapTime.ToString("#0.00");
                    }
                    else if (bestLapTime < 3600.0f)
                    {
                        int   m = (int)bestLapTime / 60;
                        float s = bestLapTime - m * 60.0f;
                        bestLapTimeText.text = m.ToString() + ":" + s.ToString("#0.00");
                    }
                }
            }
        }
    }