コード例 #1
0
    void Awake()
    {
        transform.tag = "Player";
        cameraFPS     = GetComponentInChildren(typeof(Camera)).transform.gameObject;
        cameraFPS.transform.localPosition = new Vector3(0, 1.55f, 0);
        cameraFPS.transform.localRotation = Quaternion.identity;
        cameraFPS.tag = "MainCamera";
        //
        ms_Rigidbody = GetComponent <Rigidbody>();
        ms_Rigidbody.freezeRotation         = true;
        ms_Rigidbody.useGravity             = false;
        ms_Rigidbody.mass                   = 15.0f;
        ms_Rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
        ms_Rigidbody.interpolation          = RigidbodyInterpolation.Extrapolate;
        //
        CapsuleCollider capsule = GetComponent <CapsuleCollider>();

        capsule.height    = 1.6f;
        capsule.radius    = 0.35f;
        capsule.direction = 1;
        capsule.center    = new Vector3(0.0f, 0.8f, 0.0f);
        //
        joystickMoveFPS   = transform.Find("Camera/Canvas/JoystickMFPS").GetComponent <Joystick>();
        joystickRotateFPS = transform.Find("Camera/Canvas/JoystickRFPS").GetComponent <Joystick>();
        sceneControllerMS = FindObjectOfType(typeof(MSSceneController)) as MSSceneController;
        if (sceneControllerMS)
        {
            foundTheSceneController = true;
        }
        else
        {
            foundTheSceneController = false;
        }
    }
コード例 #2
0
    void Start()
    {
        controls = GameObject.FindObjectOfType(typeof(MSSceneController)) as MSSceneController;
        if (!controls)
        {
            Debug.LogError("There must be an object with the 'MSSceneController' component so that vehicles can be managed.");
            error = true;
            this.transform.gameObject.SetActive(false);
            return;
        }
        if (controls.error)
        {
            error = true;
            this.transform.gameObject.SetActive(false);
            return;
        }

        // UI.Find interactive
        nextVehicle     = transform.Find("Canvas/Default/nextVehicle").GetComponent <Button> ();
        previousVehicle = transform.Find("Canvas/Default/previousVehicle").GetComponent <Button> ();

        if (nextVehicle)
        {
            nextVehicle.onClick = new Button.ButtonClickedEvent();
            nextVehicle.onClick.AddListener(() => NextVehicle());
        }
        if (previousVehicle)
        {
            previousVehicle.onClick = new Button.ButtonClickedEvent();
            previousVehicle.onClick.AddListener(() => PreviousVehicle());
        }

        canCheckUI = false;
        StartCoroutine("YieldToCheckUI");

        CheckIfPlayerIsNull();
        EnableUI(true);
    }
コード例 #3
0
 void OnEnable()
 {
     sceneControllerMS = FindObjectOfType(typeof(MSSceneController)) as MSSceneController;
     if (sceneControllerMS)
     {
         foundTheSceneController = true;
         if (!sceneControllerMS.player)
         {
             sceneControllerMS.player = this.gameObject;
         }
         if (sceneControllerMS.vehicleCode)
         {
             if (sceneControllerMS.vehicleCode._vehicleState == MSVehicleController.ControlState.isPlayer)
             {
                 this.gameObject.SetActive(false);
             }
         }
     }
     else
     {
         foundTheSceneController = false;
     }
     EnableControls();
 }
コード例 #4
0
    void Awake()
    {
        controllsIsNull = false;
        controls        = GameObject.FindObjectOfType(typeof(MSSceneController)) as MSSceneController;
        //
        canvasScene = transform.Find("Canvas").gameObject;
        //
        backGround            = transform.Find("Canvas/Background").GetComponent <Image> ();
        controlsText          = transform.Find("Canvas/Background/ControlText").GetComponent <Text> ();
        increaseText          = transform.Find("Canvas/Background/IncreasedGear").GetComponent <Text> ();
        decreaseText          = transform.Find("Canvas/Background/DecreasedGear").GetComponent <Text> ();
        enterAndExitText      = transform.Find("Canvas/Background/Enter_ExitVehicle").GetComponent <Text> ();
        startVehicleText      = transform.Find("Canvas/Background/StartTheVehicle").GetComponent <Text> ();
        lightsText            = transform.Find("Canvas/Background/Lights").GetComponent <Text> ();
        reloadText            = transform.Find("Canvas/Background/ReloadScene").GetComponent <Text> ();
        hornText              = transform.Find("Canvas/Background/Horn").GetComponent <Text> ();
        handBrakeText         = transform.Find("Canvas/Background/HandBrake").GetComponent <Text> ();
        switchCamerasText     = transform.Find("Canvas/Background/SwitchCameras").GetComponent <Text> ();
        pauseText             = transform.Find("Canvas/Background/Pause").GetComponent <Text> ();
        manualOrAutoGearsText = transform.Find("Canvas/Background/ManualOrAutoGears").GetComponent <Text> ();
        heightText            = transform.Find("Canvas/Background/HeightText").GetComponent <Text> ();
        dayNightButton        = transform.Find("Canvas/DayNightButton").GetComponent <Button> ();
        if (dayNightButton)
        {
            dayNightButton.onClick = new Button.ButtonClickedEvent();
            dayNightButton.onClick.AddListener(() => DayNightButton());
        }

        //streetLights
        lightsObject  = transform.Find("Lights").gameObject;
        meshLightsOn  = lightsObject.transform.Find("Meshes/lightsOn").gameObject;
        meshLightsOff = lightsObject.transform.Find("Meshes/lightsOff").gameObject;
        streetLamps   = lightsObject.transform.GetComponentsInChildren <Light> ();
        //

        if (!controls)
        {
            UIVisualizer    = false;
            controllsIsNull = true;
            EnableUI(false);
            canvasScene.SetActive(false);
            return;
        }
        canvasScene.SetActive(true);
        if (!UIVisualizer)
        {
            EnableUI(false);
        }
        else
        {
            EnableUI(true);
        }
        playerIsNull = false;
        player       = controls.player;
        if (!player)
        {
            playerIsNull = true;
        }
        //
        increaseText.text          = "Increased Gear: " + controls.controls.increasedGear.ToString();
        decreaseText.text          = "Decreased Gear: " + controls.controls.decreasedGear.ToString();
        enterAndExitText.text      = "Enter/Exit Vehicle: " + controls.controls.enterEndExit.ToString();
        startVehicleText.text      = "Start the vehicle: " + controls.controls.startTheVehicle.ToString();
        reloadText.text            = "Reload Scene: " + controls.controls.reloadScene.ToString();
        hornText.text              = "Horn: " + controls.controls.hornInput.ToString();
        handBrakeText.text         = "Hand Brake: " + controls.controls.handBrakeInput.ToString();
        switchCamerasText.text     = "Switch Cameras: " + controls.controls.switchingCameras.ToString();
        pauseText.text             = "Pause: " + controls.controls.pause.ToString();
        manualOrAutoGearsText.text = "ManualOrAutoGears: " + controls.controls.manualOrAutoGears.ToString();
        heightText.text            = "Height: " + controls.controls.changeSuspensionHeight.ToString();
        lightsText.text            = "Lights = '" + controls.controls.mainLightsInput.ToString() + "', '" + controls.controls.warningLightsInput.ToString() + "', '"
                                     + controls.controls.headlightsInput.ToString() + "', '" + controls.controls.extraLightsInput.ToString() + "', '"
                                     + controls.controls.flashesLeftAlert.ToString() + "', '" + controls.controls.flashesRightAlert.ToString();
    }