コード例 #1
0
        // unity OnInspectorGUI method
        public override void OnInspectorGUI()
        {
            OrbitCameraController cam = (OrbitCameraController)target;

            //trig.item = (InventoryItem)EditorGUILayout.ObjectField("Item", trig.item, typeof(InventoryItem), true);
            cam.Xconstraint = (OrbitCameraController.CameraConstraint)EditorGUILayout.EnumPopup("X Constraint: ", cam.Xconstraint);
            if (cam.Xconstraint == OrbitCameraController.CameraConstraint.Limited)
            {
                cam.minXAngle = EditorGUILayout.FloatField("Min X Angle", cam.minXAngle);
                cam.maxXAngle = EditorGUILayout.FloatField("Max X Angle", cam.maxXAngle);
            }

            cam.Yconstraint = (OrbitCameraController.CameraConstraint)EditorGUILayout.EnumPopup("Y Constraint: ", cam.Yconstraint);
            if (cam.Yconstraint == OrbitCameraController.CameraConstraint.Limited)
            {
                cam.minYAngle = EditorGUILayout.FloatField("Min Y Angle", cam.minYAngle);
                cam.maxYAngle = EditorGUILayout.FloatField("Max Y Angle", cam.maxYAngle);
            }

            DrawDefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(cam);
                serializedObject.ApplyModifiedProperties();
            }
        }
コード例 #2
0
        /// <summary>
        /// start sheathing bow
        /// </summary>
        public override void sheatheBow()
        {
#if DEBUG_INFO
            if (!m_Initialized)
            {
                Debug.LogError("Component not initialized < " + this.ToString() + " >");
                return;
            }
#endif
            if (m_SwitchingItemState)
            {
                return;
            }
            if (!areArmsFree)
            {
                return;
            }

            _startSheathingBow();
            if (m_ThirdPersonPlayer.m_Camera is OrbitCameraController)
            {
                OrbitCameraController oCam = m_ThirdPersonPlayer.m_Camera as OrbitCameraController;
                oCam.Xconstraint = def_Xconstraint;
                oCam.minXAngle   = def_cameraMinXangle;
                oCam.maxXAngle   = def_cameraMaxXangle;
            }
        }
コード例 #3
0
        /// <summary>
        /// start taking bow
        /// </summary>
        public override void takeBow()
        {
#if DEBUG_INFO
            if (!m_Initialized)
            {
                Debug.LogError("Component not initialized < " + this.ToString() + " >");
                return;
            }
#endif
            if (m_SwitchingItemState)
            {
                return;
            }
            if (!areArmsFree)
            {
                return;
            }

            if (m_EquipmentScript.currentBow &&
                m_EquipmentScript.currentQuiver)
            {
                _startTakingBow();
                if (m_ThirdPersonPlayer.m_Camera is OrbitCameraController)
                {
                    OrbitCameraController oCam = m_ThirdPersonPlayer.m_Camera as OrbitCameraController;
                    def_Xconstraint = oCam.Xconstraint;
                    oCam.minXAngle  = -30;
                    oCam.maxXAngle  = 35;
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// end trigger animations
        /// </summary>
        /// <param name="character">character interacting with trigger</param>
        /// <param name="limbsIK">ik helper</param>
        public override void end(TPCharacter character, IKHelper limbsIK)
        {
            if (!character)
            {
#if DEBUG_INFO
                Debug.LogError("object cannot be null!" + " < " + this.ToString() + ">");
#endif
                return;
            }
            if (!Target)
            {
#if DEBUG_INFO
                Debug.LogWarning("trigger target not assigned!" + " < " + this.ToString() + ">");
#endif
                return;
            }


            character.triggerRootMotion = false;
            character.disableMove       = false;
            character.setMoveMode(TPCharacter.MovingMode.Ledge);

            OrbitCameraController oc = character.GetComponentInChildren <OrbitCameraController>();
            if (oc)
            {
                oc.additiveRotation = true;
            }

            character.disableCapsuleScale = true;
            character.animator.SetBool(/*"pGrabLedgeUp"*/ HashIDs.GrabLedgeUpBool, false);
            character.animator.SetBool(/*"pOnLedge"*/ HashIDs.OnLedgeBool, true);
            character.animatorDampTime       = 0.0f;
            character.ledgeMove              = true;
            character.disableLedgeConstraint = false;
            character.fullStop();
            character.jumpAllowed = true;

            if (limbsIK)
            {
                limbsIK.RHandIKEnabled = true;
                limbsIK.LFootIKEnabled = true;
                limbsIK.RFootIKEnabled = true;
                limbsIK.LHandIKEnabled = true;
                limbsIK.LFWeightTime   = 0.0f;
                limbsIK.RFWeightTime   = 0.0f;

                limbsIK.startLedgeAdjust(m_TriggerInfo.targetRotation);
                limbsIK.checkHang = true;
            }
            if (character.animator.GetBool(/*"pLedgeHang"*/ HashIDs.LedgeHangBool))
            {
                character.restoreCapsuleSize();
            }
            else
            {
                character.scaleCapsuleToHalf();
            }
        }
コード例 #5
0
        BaseCamera _createCamera()
        {
            if (CharacterType == CharacterTypes.TopDown)
            {
                Transform camDefTargetXform = Utils.FindChildTransformByName(character.transform, "CameraDefaultTarget");
                if (!camDefTargetXform)
                {
                    GameObject cameraDefaultTarget = new GameObject("CameraDefaultTarget");
                    cameraDefaultTarget.transform.SetParent(character.transform);
                    Vector3 pos = new Vector3(0.0f, 1.63f, 0.0f);
                    cameraDefaultTarget.transform.localPosition = pos;
                    camDefTargetXform = cameraDefaultTarget.transform;
                }
                // check if camera exists
                GameObject camGO = GameObject.FindGameObjectWithTag("MainCamera");
                if (!camGO)
                {
                    Debug.Log("Creating camera...");
                    camGO = new GameObject("TopDownCamera");
                }
#if DEBUG_INFO
                else
                {
                    Debug.Log("Found camera...");
                }
#endif
                camGO.transform.SetParent(character.transform, false);
                Quaternion currentRotation = character.transform.rotation;
                Vector3    cpos            = new Vector3(6.744616f, 11.20537f, -0.4592583f);
                cpos = currentRotation * cpos;

                camGO.transform.position = character.transform.position + cpos;
                camGO.transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f);
                camGO.tag  = "MainCamera";
                camGO.name = "TopDownCamera";
                camGO.SetActive(true);
                addCommonCameraComponents(camGO);

                TopDownCamera tdc = camGO.GetComponent <TopDownCamera>();
                if (!tdc)
                {
                    tdc = Undo.AddComponent <TopDownCamera>(camGO);
                }
                tdc.Target = camDefTargetXform;

                Camera cam = camGO.GetComponent <Camera>();
                cam.hdr = true;

                return(tdc);
            }
            else
            {
                Transform camDefTargetXform = Utils.FindChildTransformByName(character.transform, "CameraDefaultTarget");
                if (!camDefTargetXform)
                {
                    GameObject cameraDefaultTarget = new GameObject("CameraDefaultTarget");
                    cameraDefaultTarget.transform.SetParent(character.transform);
                    Vector3 pos = new Vector3(0.184f, 1.771f, 0.0f);
                    cameraDefaultTarget.transform.localPosition = pos;
                    camDefTargetXform = cameraDefaultTarget.transform;
                }

                // check if camera exists on character
                Transform  camXform = Utils.FindChildTransformByTag(character.transform, "MainCamera");
                GameObject camGO    = null;
                if (!camXform)
                {
                    Debug.Log("Creating camera...");
                    camGO = new GameObject("OrbitCamera");
                }
                else
                {
                    Debug.Log("Found existing camera on character");
                    camGO = camXform.gameObject;
                }


                camGO.transform.SetParent(character.transform, false);

                Quaternion currentRotation = character.transform.rotation;
                Vector3    cpos            = new Vector3(0.03f, 2.04f, -3.167f);
                cpos = currentRotation * cpos;

                camGO.transform.position = character.transform.position + cpos;
                camGO.transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f);
                camGO.tag  = "MainCamera";
                camGO.name = "OrbitCamera";
                camGO.SetActive(true);

                addCommonCameraComponents(camGO);

                OrbitCameraController occ = camGO.GetComponent <OrbitCameraController>();
                if (!occ)
                {
                    occ = Undo.AddComponent <OrbitCameraController>(camGO);
                }
                occ.Target       = camDefTargetXform;
                occ.angularSpeed = 64.0f;
                occ.minXAngle    = -60.0f;
                occ.maxXAngle    = 45.0f;
                occ.minYAngle    = -180.0f;
                occ.maxYAngle    = 180.0f;
                occ.minZ         = 0.2f;
                occ.maxZ         = 1.6f;
                occ.zStep        = 0.1f;

                ProtectFromWalls pfw = camGO.GetComponent <ProtectFromWalls>();
                if (!pfw)
                {
                    pfw = Undo.AddComponent <ProtectFromWalls>(camGO);
                }
                // for some reason unity ( 5.2.2 ) dont recognize 'Default' layer in ' GetMask' method so i must add it after
                pfw.mask  = LayerMask.GetMask("DefaultSlope");
                pfw.mask |= 1 << LayerMask.NameToLayer("Default");


                pfw.clipMoveTime      = 0.0f;
                pfw.returnTime        = 0.5f;
                pfw.sphereCastRadius  = 0.05f;
                pfw.visualiseInEditor = true;
                pfw.closestDistance   = 0.05f;
                pfw.dontClipTag       = "Player";
                pfw.m_Pivot           = camDefTargetXform;

                Camera cam = camGO.GetComponent <Camera>();
                cam.hdr = true;

                return(occ);
            }
        }