Beispiel #1
0
        protected virtual void UpdateCameraStates()
        {
            // CAMERA STATE - you can change the CameraState here, the bool means if you want lerp of not, make sure to use the same CameraState String that you named on TPCameraListData

            if (tpCamera == null)
            {
                tpCamera = FindObjectOfType <vThirdPersonCamera>();
                if (tpCamera == null)
                {
                    return;
                }
                if (tpCamera)
                {
                    tpCamera.SetMainTarget(this.transform);
                    tpCamera.Init();
                }
            }

            if (changeCameraState && !cc.isStrafing)
            {
                tpCamera.ChangeState(customCameraState, customlookAtPoint, smoothCameraState);
            }
            else if (cc.isCrouching)
            {
                tpCamera.ChangeState("Crouch", true);
            }
            else if (cc.isStrafing)
            {
                tpCamera.ChangeState("Strafing", true);
            }
            else
            {
                tpCamera.ChangeState("Default", true);
            }
        }
Beispiel #2
0
    void Start()
    {
        animator = GetComponent <Animator>();
        if (applyRecoilToCamera)
        {
            tpCamera = FindObjectOfType <vThirdPersonCamera>();
        }
        ammoManager = GetComponent <vAmmoManager>();
        usingThirdPersonController = GetComponent <vThirdPersonController>() != null;
        if (useAmmoDisplay)
        {
            ammoDisplay = FindObjectOfType <vAmmoDisplay>();
        }

        if (animator)
        {
            var _rightHand = animator.GetBoneTransform(HumanBodyBones.RightHand);
            var weapon     = _rightHand.GetComponentInChildren <vShooterWeapon>();
            if (weapon != null)
            {
                SetRightWeapon(weapon.gameObject);
            }
        }

        if (!ignoreTags.Contains(gameObject.tag))
        {
            ignoreTags.Add(gameObject.tag);
        }

        if (useAmmoDisplay && ammoDisplay)
        {
            ammoDisplay.UpdateDisplay("");
        }
    }
 void Start()
 {
     instance         = this;
     cc               = FindObjectOfType <vThirdPersonController>();
     tpCamera         = FindObjectOfType <vThirdPersonCamera>();
     currentAimCanvas = aimCanvasCollection[0];
 }
Beispiel #4
0
    /*
     * private void Awake() {
     *  SpawnPlayer(SpawnPoints.UITestRoomA);
     * }
     * //*/

    public void SpawnPlayer(SpawnPoints point)
    {
        SpawnPoint pointToSpawnPlayer = spawnPoints[0];
        bool       foundSpawnPoint    = false;

        foreach (var spawnPoint in spawnPoints)
        {
            if (spawnPoint.pointID == point)
            {
                pointToSpawnPlayer = spawnPoint;
                foundSpawnPoint    = true;
                break;
            }
        }
        if (foundSpawnPoint)
        {
            dSystem = Instantiate(prefabDialogueSystem, Vector3.zero, Quaternion.identity);
            //Spawn the player
            player = Instantiate(prefabPlayer, pointToSpawnPlayer.transform.position, pointToSpawnPlayer.transform.localRotation);
            GameObject         newGO    = Instantiate(prefabCinemachine, pointToSpawnPlayer.transform.position, Quaternion.identity);
            vThirdPersonCamera tpCamera = newGO.GetComponent <vThirdPersonCamera>();
            tpCamera.SetTarget(player.transform);
            //Set the camera on the UI
            UI.Instance.cBrain = newGO.GetComponent <CinemachineBrain>();
            //UI.Instance.thirdPersonCamera = tpCamera;
        }
        else
        {
            Debug.Log("Failed to fing SpawnPoint: " + point);
        }
    }
 void Start()
 {
     cctl     = gameObject.GetComponent <CharacterController>();
     animator = gameObject.GetComponent <Animator>();
     cam      = Camera.main;
     t_cam    = cam.gameObject.GetComponent <vThirdPersonCamera>();
 }
 void Start()
 {
     mat = new Material(shader);
     if (null == cameraController)
     {
         cameraController = GetComponent <vThirdPersonCamera>();
     }
 }
Beispiel #7
0
 /// <summary>
 /// Find the camera that you use to look around with your player.
 /// </summary>
 protected virtual void FindPlayerCam()
 {
     playerCam = FindObjectOfType <vThirdPersonCamera>();
     if (playerCam)
     {
         orgLockCam = playerCam.lockCamera;
     }
 }
 void Awake()
 {
     keep_camera_look_at = false;
     moving_allowed      = true;
     cctl      = GetComponent <CharacterController>();
     animator  = GetComponent <Animator>();
     cam       = Camera.main.gameObject.GetComponent <vThirdPersonCamera>();
     character = GetComponent <Character>();
 }
Beispiel #9
0
        protected vThirdPersonController cc;                // access the ThirdPersonController component

        #endregion

        protected virtual void Start()
        {
            //Move Player  get animator script
            cc = GetComponent <vThirdPersonController>();
            //Move Camera  get Camera script
            tpCamera = FindObjectOfType <vThirdPersonCamera>();

            //Cursor
            cursorControl();
        }
Beispiel #10
0
    void OnSceneGUI()
    {
        if (Application.isPlaying)
        {
            return;
        }
        tpCamera = (vThirdPersonCamera)target;

        if (tpCamera.gameObject == Selection.activeGameObject)
        {
            if (tpCamera.CameraStateList != null && tpCamera.CameraStateList.tpCameraStates != null && tpCamera.CameraStateList.tpCameraStates.Count > 0)
            {
                if (tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].cameraMode != TPCameraMode.FixedPoint)
                {
                    return;
                }
                try
                {
                    for (int i = 0; i < tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints.Count; i++)
                    {
                        if (indexSelected == i)
                        {
                            Handles.color = Color.blue;
                            tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint = tpCamera.transform.position;
                            tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle    = tpCamera.transform.eulerAngles;
                            if (tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[indexSelected].freeRotation)
                            {
                                Handles.SphereCap(0, tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle, Quaternion.identity, 0.5f);
                            }
                            else
                            {
                                Handles.DrawLine(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint,
                                                 tpCamera.target.position);
                            }
                        }
                        else if (Handles.Button(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint, Quaternion.identity, 0.5f, 0.3f, Handles.SphereCap))
                        {
                            indexSelected               = i;
                            tpCamera.indexLookPoint     = i;
                            tpCamera.transform.position = tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint;
                            tpCamera.transform.rotation = Quaternion.Euler(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle);
                        }
                        Handles.color = Color.white;
                        Handles.Label(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint, tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].pointName);
                    }
                }
                catch { if (tpCamera.indexList > tpCamera.CameraStateList.tpCameraStates.Count - 1)
                        {
                            tpCamera.indexList = tpCamera.CameraStateList.tpCameraStates.Count - 1;
                        }
                }
            }
        }
    }
Beispiel #11
0
 // Use this for initialization
 void Start()
 {
     Camera    = FindObjectOfType <vThirdPersonCamera>();
     BuildType = BuildType.Nothing;
     Square    = Instantiate(Square);
     Square.GetComponent <BoxCollider>().enabled     = false;
     Square.GetComponent <Renderer>().sharedMaterial = MaterialTransparent;
     Square.transform.localScale = new Vector3(GridSize, 0.05f, GridSize);
     Square.SetActive(false);
     BuildModeActive = false;
 }
Beispiel #12
0
    private void Start()
    {
        PlayerSpawnPoint[] allSpawnPoints = GetAllSpawnPoints();

        SetupAllPlayers(allSpawnPoints);

        if (ThirdPersonCamera == null)
        {
            Debug.Log("GC| Forgot to set the reference to ThirdPersonCamera. Don't sweat it, we'll do some expensive shit to make up for your mistake");
            ThirdPersonCamera = FindObjectOfType <vThirdPersonCamera>();
        }
    }
Beispiel #13
0
    private void InitVariables()
    {
        _cameraRaycaster = Camera.main.GetComponent <CameraRaycaster>();
        Assert.IsNotNull(_cameraRaycaster);

        _thirdPersonController = GetComponent <vThirdPersonController>();
        Assert.IsNotNull(_thirdPersonController);

        _tpCamera = FindObjectOfType <vThirdPersonCamera>();
        Assert.IsNotNull(_tpCamera);

        _currentClickPoint = transform.position;
    }
Beispiel #14
0
        protected virtual void CharacterInit()
        {
            cc = GetComponent <vThirdPersonController>();
            if (cc != null)
            {
                cc.Init();
            }

            tpCamera = FindObjectOfType <vThirdPersonCamera>();
            if (tpCamera)
            {
                tpCamera.SetMainTarget(this.transform);
            }
        }
Beispiel #15
0
        protected virtual void CharacterInit()
        {
            cc = GetComponent <vThirdPersonController>();
            if (cc != null)
            {
                cc.Init();
            }

            tpCamera = FindObjectOfType <vThirdPersonCamera>();
            //if (tpCamera) tpCamera.SetMainTarget(this.transform);

            //Cursor.visible = false;
            //Cursor.lockState = CursorLockMode.Locked;
        }
Beispiel #16
0
    void Start()
    {
        animator = GetComponent <Animator>();
        if (applyRecoilToCamera)
        {
            tpCamera = FindObjectOfType <vThirdPersonCamera>();
        }
        ammoManager = GetComponent <vAmmoManager>();
        ammoManager.updateTotalAmmo = new vAmmoManager.OnUpdateTotalAmmo(UpdateTotalAmmo);
        usingThirdPersonController  = GetComponent <vThirdPersonController>() != null;
        if (useAmmoDisplay)
        {
            GetAmmoDisplays();
        }

        if (animator)
        {
            var _rightHand = animator.GetBoneTransform(HumanBodyBones.RightHand);
            var _lefttHand = animator.GetBoneTransform(HumanBodyBones.LeftHand);
            var weaponR    = _rightHand.GetComponentInChildren <vShooterWeapon>();
            var weaponL    = _lefttHand.GetComponentInChildren <vShooterWeapon>();
            if (weaponR != null)
            {
                SetRightWeapon(weaponR.gameObject);
            }
            if (weaponL != null)
            {
                SetLeftWeapon(weaponL.gameObject);
            }
        }

        if (!ignoreTags.Contains(gameObject.tag))
        {
            ignoreTags.Add(gameObject.tag);
        }

        if (useAmmoDisplay)
        {
            if (ammoDisplayR)
            {
                ammoDisplayR.UpdateDisplay("");
            }
            if (ammoDisplayL)
            {
                ammoDisplayL.UpdateDisplay("");
            }
        }
        UpdateTotalAmmo();
    }
Beispiel #17
0
 protected virtual void InitializeTpCamera()
 {
     if (tpCamera == null)
     {
         tpCamera = FindObjectOfType <vThirdPersonCamera>();
         if (tpCamera == null)
         {
             return;
         }
         if (tpCamera)
         {
             tpCamera.SetMainTarget(PlayerController.LocalPlayerInstance.transform);
         }
     }
 }
Beispiel #18
0
 protected virtual void InitializeTpCamera()
 {
     if (tpCamera == null)
     {
         tpCamera = FindObjectOfType <vThirdPersonCamera>();
         if (tpCamera == null)
         {
             return;
         }
         if (tpCamera)
         {
             tpCamera.SetMainTarget(this.transform);
             tpCamera.Init();
         }
     }
 }
Beispiel #19
0
 void OnEnable()
 {
     m_Logo                  = (Texture2D)Resources.Load("tp_camera", typeof(Texture2D));
     indexSelected           = 0;
     tpCamera                = (vThirdPersonCamera)target;
     tpCamera.indexLookPoint = 0;
     if (tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].cameraMode != TPCameraMode.FixedPoint)
     {
         return;
     }
     if (tpCamera.CameraStateList != null && (tpCamera.indexList < tpCamera.CameraStateList.tpCameraStates.Count) && tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints.Count > 0)
     {
         tpCamera.transform.position = tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[0].positionPoint;
         tpCamera.transform.rotation = Quaternion.Euler(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[0].eulerAngle);
     }
 }
 protected virtual void UpdateCameraStates()
 {
     // CAMERA STATE - you can change the CameraState here, the bool means if you want lerp of not, make sure to use the same CameraState String that you named on TPCameraListData
     if (tpCamera == null)
     {
         tpCamera = FindObjectOfType <vThirdPersonCamera>();
         if (tpCamera == null)
         {
             return;
         }
         if (tpCamera)
         {
             tpCamera.SetMainTarget(this.transform);
             tpCamera.Init();
         }
     }
 }
        protected virtual void CharacterInit()
        {
            cc = GetComponent <vThirdPersonController>();
            if (cc != null)
            {
                cc.Init();
            }

            tpCamera = transform.parent.gameObject.GetComponentInChildren <vThirdPersonCamera>();
            if (tpCamera)
            {
                tpCamera.SetMainTarget(transform);
            }

            Cursor.visible   = false;
            Cursor.lockState = CursorLockMode.Locked;
        }
        protected virtual IEnumerator CharacterInit()
        {
            yield return(new WaitForEndOfFrame());

            if (tpCamera == null)
            {
                tpCamera = FindObjectOfType <vThirdPersonCamera>();
                if (tpCamera && tpCamera.target != transform)
                {
                    tpCamera.SetMainTarget(this.transform);
                }
            }
            if (hud == null && vHUDController.instance != null)
            {
                hud = vHUDController.instance;
                hud.Init(cc);
            }
        }
Beispiel #23
0
    public static void lockMouse()
    {
        Cursor.lockState = CursorLockMode.Locked;
        GameObject         v   = GameObject.Find("vThirdPersonCamera");
        vThirdPersonCamera cam = v.GetComponent <vThirdPersonCamera>();

        cam.lockCamera = false;

        Invector.CharacterController.vThirdPersonAnimator   a = v.GetComponent <Invector.CharacterController.vThirdPersonAnimator>();
        Invector.CharacterController.vThirdPersonInput      i = v.GetComponent <Invector.CharacterController.vThirdPersonInput>();
        Invector.CharacterController.vThirdPersonController c = v.GetComponent <Invector.CharacterController.vThirdPersonController>();

        //     i.enabled = true;
        //   c.lockMovement = false;
        //   c.enabled = true;
        //   a.enabled = true;

        //i.enabled = true;
        Cursor.lockState = CursorLockMode.Locked;
    }
Beispiel #24
0
        protected virtual void CharacterInit()
        {
            if (cc != null)
            {
                cc.Init();
            }

            tpCamera = FindObjectOfType <vThirdPersonCamera>();
            if (tpCamera)
            {
                tpCamera.SetMainTarget(this.transform);
            }

            cursorPoint = transform.position;

            hud = vHUDController.instance;
            if (hud != null)
            {
                hud.Init(cc);
            }
        }
Beispiel #25
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.layer == 10)
     {
         GameObject         player            = collision.gameObject;
         PinballMotion      pinball_player    = player.GetComponent <PinballMotion>();
         vThirdPersonCamera camera_controller = Camera.main.GetComponent <vThirdPersonCamera>();
         Rigidbody          rb = player.GetComponent <Rigidbody>();
         Vector3            directionTarget = target.transform.position - player.transform.position;
         directionTarget.y = 0;
         directionTarget   = directionTarget.normalized;
         float angle = Mathf.Atan2(directionTarget.x, directionTarget.z) * 180 / Mathf.PI;
         pinball_player.direction = directionTarget;
         rb.transform.forward     = directionTarget;
         camera_controller.SetMouseX(angle);
         camera_controller.SetMouseY(0.0f);
         molla.GetComponent <EstensioneMolla>().state = 0;
         Vector3 scale = molla.transform.localScale;
         scale.z = 0.1f;
         molla.transform.localScale = scale;
         this.GetComponent <PinballSounds>().PlaySound();
     }
 }
Beispiel #26
0
    public static void unlockMouse()
    {
        GameObject         v   = GameObject.Find("vThirdPersonController");
        vThirdPersonCamera cam = v.GetComponent <vThirdPersonCamera>();

        cam.lockCamera = true;

        /*Invector.CharacterController.vThirdPersonInput i = v.GetComponent<Invector.CharacterController.vThirdPersonInput>();
         * Invector.CharacterController.vThirdPersonController c = v.GetComponent<Invector.CharacterController.vThirdPersonController>();
         * c.enabled = false;
         * i.enabled = false;*/

        Invector.CharacterController.vThirdPersonAnimator   a = v.GetComponent <Invector.CharacterController.vThirdPersonAnimator>();
        Invector.CharacterController.vThirdPersonInput      i = v.GetComponent <Invector.CharacterController.vThirdPersonInput>();
        Invector.CharacterController.vThirdPersonController c = v.GetComponent <Invector.CharacterController.vThirdPersonController>();
        //     c.lockMovement = true;
        //c.enabled = false;
        //    a.enabled = false;
        // i.enabled = false;
        //i.enabled = false;
        Cursor.lockState = CursorLockMode.None;
        c.keepDirection  = false;
    }
Beispiel #27
0
    public void InitGame()
    {
        gameTimeScale = 1f;
        metaTimeScale = 1f;

        playerMenu = GameObject.FindGameObjectWithTag("PlayerMenu").GetComponent <PlayerMenu>();
        mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
        hud        = GameObject.FindGameObjectWithTag("HUD").GetComponent <HUD>();

        if (mainCamera == null)
        {
            Debug.LogError("Error: MainCamera not found.");
            return;
        }

        if (hud == null)
        {
            Debug.LogError("Error: HUD not found.");
            return;
        }

        if (playerMenu == null)
        {
            Debug.LogError("Error: PlayerMenu not found.");
            return;
        }
        vtpcScript = mainCamera.GetComponent <vThirdPersonCamera>();

        playerMenu.gameObject.SetActive(false);
        hints = true;

        UnpauseGame();

        HintsOn();

        hud.scoreText.text = score.ToString();
    }
Beispiel #28
0
 void Awake()
 {
     vCam = GetComponent <vThirdPersonCamera>();
 }
Beispiel #29
0
    public override void OnInspectorGUI()
    {
        if (!skin)
        {
            skin = Resources.Load("skin") as GUISkin;
        }
        GUI.skin = skin;

        tpCamera = (vThirdPersonCamera)target;

        EditorGUILayout.Space();
        GUILayout.BeginVertical("Third Person Camera by Invector", "window");
        GUILayout.Label(m_Logo, GUILayout.MaxHeight(25));
        GUILayout.Space(5);

        if (tpCamera.cullingLayer == 0)
        {
            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("Please assign the Culling Layer to 'Default' ", MessageType.Warning);
            EditorGUILayout.Space();
        }

        EditorGUILayout.HelpBox("The target will be assign automatically to the current Character when start, check the InitialSetup method on the Motor.", MessageType.Info);

        base.OnInspectorGUI();
        GUILayout.EndVertical();

        GUILayout.BeginVertical("Camera States", "window");

        GUILayout.Label(m_Logo, GUILayout.MaxHeight(25));
        GUILayout.Space(5);

        EditorGUILayout.HelpBox("This settings will always load in this List, you can create more List's with different settings for another characters or scenes", MessageType.Info);

        tpCamera.CameraStateList = (vThirdPersonCameraListData)EditorGUILayout.ObjectField("CameraState List", tpCamera.CameraStateList, typeof(vThirdPersonCameraListData), false);
        if (tpCamera.CameraStateList == null)
        {
            GUILayout.EndVertical();
            return;
        }
        GUILayout.BeginHorizontal();
        if (GUILayout.Button(new GUIContent("New CameraState")))
        {
            if (tpCamera.CameraStateList.tpCameraStates == null)
            {
                tpCamera.CameraStateList.tpCameraStates = new List <vThirdPersonCameraState>();
            }

            tpCamera.CameraStateList.tpCameraStates.Add(new vThirdPersonCameraState("New State" + tpCamera.CameraStateList.tpCameraStates.Count));
            tpCamera.indexList = tpCamera.CameraStateList.tpCameraStates.Count - 1;
        }

        if (GUILayout.Button(new GUIContent("Delete State")) && tpCamera.CameraStateList.tpCameraStates.Count > 1 && tpCamera.indexList != 0)
        {
            tpCamera.CameraStateList.tpCameraStates.RemoveAt(tpCamera.indexList);
            if (tpCamera.indexList - 1 >= 0)
            {
                tpCamera.indexList--;
            }
        }

        GUILayout.EndHorizontal();

        if (tpCamera.CameraStateList.tpCameraStates.Count > 0)
        {
            if (tpCamera.indexList > tpCamera.CameraStateList.tpCameraStates.Count - 1)
            {
                tpCamera.indexList = 0;
            }
            tpCamera.indexList = EditorGUILayout.Popup("State", tpCamera.indexList, getListName(tpCamera.CameraStateList.tpCameraStates));
            StateData(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList]);
        }

        GUILayout.EndVertical();
        EditorGUILayout.Space();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(tpCamera);
            EditorUtility.SetDirty(tpCamera.CameraStateList);
        }
    }
 void Start()
 {
     tpCamera = FindObjectOfType <vThirdPersonCamera>();
 }