Example #1
0
 public void GetIn(BCG_EnterExitVehicle vehicle)
 {
     if (OnBCGPlayerEnteredAVehicle != null)
     {
         OnBCGPlayerEnteredAVehicle(this, vehicle);
     }
 }
Example #2
0
    void Awake()
    {
        if (!playerStartsAsInVehicle)
        {
            inVehicle = null;
        }

        if (!isTPSController)
        {
            characterCamera = GetComponentInChildren <Camera> ();
        }
    }
Example #3
0
    void BCG_Player_OnBCGVehicleSpawned(BCG_EnterExitVehicle player)
    {
        if (!cachedVehicles.Contains(player))
        {
            cachedVehicles.Add(player);
        }

        if (!cachedMainCameras.Contains(player.correspondingCamera))
        {
            cachedMainCameras.Add(player.correspondingCamera);
            player.correspondingCamera.SendMessage("ToggleCamera", false, SendMessageOptions.DontRequireReceiver);
        }
    }
Example #4
0
    void BCG_Player_OnBCGPlayerExitedFromAVehicle(BCG_EnterExitPlayer player, BCG_EnterExitVehicle vehicle)
    {
        if (waitTime < 1)
        {
            return;
        }

        print("Player Named " + player.name + " has exited from a vehicle named " + vehicle.name);
        player.inVehicle = null;
        player.transform.SetParent(null);
        player.transform.rotation = Quaternion.Euler(0f, vehicle.transform.rotation.y, 0f);
        BCGCharacterPlayer.currentlyInThisVehicle = null;

        if (cachedCanvas)
        {
            cachedCanvas.displayType = BCG_EnterExitCharacterUICanvas.DisplayType.OnFoot;
        }

        if (vehicle.getOutPosition)
        {
            player.transform.position = vehicle.getOutPosition.position;
        }
        else
        {
            player.transform.position  = vehicle.transform.position;
            player.transform.position += vehicle.transform.right * -1.5f;
        }

        player.gameObject.SetActive(true);

        for (int i = 0; i < cachedMainCameras.Count; i++)
        {
            cachedMainCameras [i].SendMessage("ToggleCamera", false, SendMessageOptions.DontRequireReceiver);
        }

        vehicle.gameObject.SendMessage("SetCanControl", false, SendMessageOptions.DontRequireReceiver);
        vehicle.gameObject.SendMessage("SetEngine", BCG_EnterExitSettings.Instance.keepEnginesAlive, SendMessageOptions.DontRequireReceiver);
        vehicle.driver = null;

//		if(RCC_CustomizerExample.Instance)
//			RCC_CustomizerExample.Instance.vehicle = null;

        RCC_SceneManager.Instance.activePlayerVehicle = null;

        waitTime = 0f;
    }
Example #5
0
    public void BCG_Player_OnBCGPlayerEnteredAVehicle(BCG_EnterExitPlayer player, BCG_EnterExitVehicle vehicle)
    {
        if (waitTime < 1)
        {
            return;
        }

        print("Player Named " + player.name + " has entered a vehicle named " + vehicle.name);

        player.inVehicle = vehicle;
        player.gameObject.SetActive(false);
        player.transform.SetParent(vehicle.transform, true);
        player.transform.localPosition            = Vector3.zero;
        player.transform.localRotation            = Quaternion.identity;
        player.transform.position                 = vehicle.transform.position;
        player.transform.localRotation            = Quaternion.identity;
        BCGCharacterPlayer.currentlyInThisVehicle = vehicle;

        if (cachedCanvas)
        {
            cachedCanvas.displayType = BCG_EnterExitCharacterUICanvas.DisplayType.InVehicle;
        }

        for (int i = 0; i < cachedMainCameras.Count; i++)
        {
            if (cachedMainCameras [i] != vehicle.correspondingCamera)
            {
                cachedMainCameras [i].SendMessage("ToggleCamera", false, SendMessageOptions.DontRequireReceiver);
            }
            else
            {
                cachedMainCameras [i].SendMessage("ToggleCamera", true, SendMessageOptions.DontRequireReceiver);
                cachedMainCameras [i].SendMessage("SetTarget", vehicle.gameObject, SendMessageOptions.DontRequireReceiver);
            }
        }

        vehicle.gameObject.SendMessage("SetCanControl", true, SendMessageOptions.DontRequireReceiver);
        vehicle.gameObject.SendMessage("SetEngine", true, SendMessageOptions.DontRequireReceiver);
        vehicle.driver = player;

        RCC_SceneManager.Instance.activePlayerVehicle = vehicle.GetComponent <RCC_CarControllerV3> ();

        waitTime = 0f;
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        prop = (BCG_EnterExitVehicle)target;

        EditorGUILayout.HelpBox("Script must be attached to root of your vehicle.", MessageType.Info);
        EditorGUILayout.HelpBox("Select proper camera for each vehicle. Selecting RCC Camera for RCC vehicles, selecting RTC Camera for RTC vehicles, etc...", MessageType.Info);
        EditorGUILayout.Space();

        if (!GameObject.FindObjectOfType <BCG_EnterExitManager> ())
        {
            EditorGUILayout.HelpBox("Your scene doesn't have BCG_EnterExitManager. In order to use enter-exit system, your scene must have _BCGEnterExitManager.", MessageType.Error);

            if (GUILayout.Button("Create BCG_EnterExitManager"))
            {
                GameObject newBCG_EnterExitManager = new GameObject();
                newBCG_EnterExitManager.transform.name     = "BCG_EnterExitManager";
                newBCG_EnterExitManager.transform.position = Vector3.zero;
                newBCG_EnterExitManager.transform.rotation = Quaternion.identity;
                newBCG_EnterExitManager.AddComponent <BCG_EnterExitManager> ();
            }
        }
        else
        {
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("driver"), new GUIContent("Current Driver"), false);
            EditorGUI.EndDisabledGroup();

            prop.correspondingCamera = (GameObject)EditorGUILayout.ObjectField("Corresponding Camera", prop.correspondingCamera, typeof(GameObject), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("getOutPosition"), new GUIContent("Get Out Position"), false);
        }

        serializedObject.ApplyModifiedProperties();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(prop);
        }
    }
Example #7
0
    void Inputs()
    {
        if (!BCGCharacterPlayer.characterPlayer)
        {
            return;
        }

        if (!BCGCharacterPlayer.characterPlayer.inVehicle)
        {
            Vector3    rayPosition;
            Quaternion rayRotation = new Quaternion();

            if (BCGCharacterPlayer.characterPlayer.characterCamera)
            {
                rayPosition = BCGCharacterPlayer.characterPlayer.characterCamera.transform.position;
                rayRotation = BCGCharacterPlayer.characterPlayer.characterCamera.transform.rotation;
            }
            else
            {
                rayPosition = BCGCharacterPlayer.characterPlayer.transform.position + (Vector3.up * BCGCharacterPlayer.characterPlayer.rayHeight);
                rayRotation = BCGCharacterPlayer.characterPlayer.transform.rotation;
            }

            Vector3 rayDirection = rayRotation * Vector3.forward;

            RaycastHit hit;

            Debug.DrawRay(rayPosition, rayDirection * 1.5f, Color.blue);

            if (Physics.Raycast(rayPosition, rayDirection, out hit, 1.5f))
            {
                if (!targetVehicle)
                {
                    targetVehicle = hit.collider.transform.GetComponentInParent <BCG_EnterExitVehicle> ();
                }
                else
                {
                    showGui = true;

                    if (Input.GetKeyDown(BCG_EnterExitSettings.Instance.enterExitVehicleKB))
                    {
                        BCGCharacterPlayer.characterPlayer.GetIn(targetVehicle);
                    }
                }
            }
            else
            {
                showGui       = false;
                targetVehicle = null;
            }
        }
        else
        {
            showGui       = false;
            targetVehicle = null;

            if (Input.GetKeyDown(BCG_EnterExitSettings.Instance.enterExitVehicleKB))
            {
                BCGCharacterPlayer.characterPlayer.GetOut();
            }
        }
    }