コード例 #1
0
 private bool SearchForPropRoot()
 {
     // search all PropRoot scripts and put in to array
     PropRoot[] _propRoots = GetComponentsInChildren <PropRoot>();
     if (_propRoots != null)
     {
         foreach (var item in _propRoots)
         {
             // search array for right hand prop and left hand prop
             if (item.gameObject.name == "LeftHandSlot")
             {
                 leftHandPropRoot = item;
             }
             else if (item.gameObject.name == "RightHandSlot")
             {
                 rightHandPropRoot = item;
             }
             else
             {
                 Debug.LogError("There is no correct named slot, please check proproot obj's name");
             }
         }
         return(true);
     }
     else
     {
         // if there are no proproot scrip to put weapon then get error
         Debug.LogError("There is no proproot in this obj or child objs");
     }
     return(false);
 }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            if (!Application.isPlaying)
            {
                GUI.color = EditorGUIUtility.isProSkin? pro: free;
                EditorGUILayout.BeginHorizontal();

                replace = (GameObject)EditorGUILayout.ObjectField("Replace Character Model", replace, typeof(GameObject), true);

                if (replace != null)
                {
                    if (GUILayout.Button("Replace"))
                    {
                        PropRoot   propRoot      = script.propRoot;
                        Vector3    localPosition = propRoot.transform.localPosition;
                        Quaternion localRotation = propRoot.transform.localRotation;
                        propRoot.transform.parent = null;

                        CharacterPuppetInspector.ReplacePuppetModel(script as CharacterThirdPerson, replace);

                        Animator     animator     = script.characterAnimation.GetComponent <Animator>();
                        PuppetMaster puppetMaster = script.transform.parent.GetComponentInChildren <PuppetMaster>();

                        propRoot.transform.parent        = animator.GetBoneTransform(HumanBodyBones.RightHand);
                        propRoot.transform.localPosition = localPosition;
                        propRoot.transform.localRotation = localRotation;
                        propRoot.puppetMaster            = puppetMaster;
                        propRoot.connectTo = GetRigidbody(puppetMaster, animator.GetBoneTransform(HumanBodyBones.RightLowerArm));

                        Debug.Log("You probably need to adjust the localPosition and localRotation of the Prop Root to match this character's hand.");

                        UserControlAI[] userControls = (UserControlAI[])GameObject.FindObjectsOfType <UserControlAI>();
                        foreach (UserControlAI ai in userControls)
                        {
                            if (ai.moveTarget == null)
                            {
                                ai.moveTarget = script.transform.parent.GetComponentInChildren <PuppetMaster>().muscles[0].joint.transform;
                            }
                        }
                    }
                }

                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;
            }

            DrawDefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(script);
            }
        }
コード例 #3
0
        protected override void OnPickUp(PropRoot propRoot)
        {
            // Called when the prop has been picked up and connected to a PropRoot.
            capsuleCollider.radius = defaultColliderRadius;
            r.mass = defaultMass;

            capsuleCollider.enabled = true;
            boxCollider.enabled     = false;

            StopAllCoroutines();
        }
コード例 #4
0
        private bool CheckPropEmptyAndWeapon(PropRoot _pr)
        {
            if (_pr == null)
            {
                return(false);
            }
            Prop _p = _pr.currentProp;

            if (_p != null && _p.gameObject.tag == "Weapon")
            {
                // enable the script
                BS_animeEvent.enabled = true;
                // put weapon slot 1 for right hand manager
                BS_animeEvent.Weapon1MarkerManger = rightHandPropRoot.currentProp.GetComponentInChildren <BS_Marker_Manager>();
                // set right hand weapon as default weapon
                BS_animeEvent.MarkerManager = BS_animeEvent.Weapon1MarkerManger;
                return(true);
            }
            return(false);
        }
コード例 #5
0
        private void DropItem()
        {
            PropRoot _dorpProp = new PropRoot();
            // By setting the prop root's currentProp to null, the prop connected to it will be dropped.
            if (rightHandPropRoot != null)  //  if right hand has occupied then drop right hand first
            {
                _dorpProp = rightHandPropRoot;
            }
            else if (leftHandPropRoot != null)    //  if right hand is empty but left hand has occupied then dorp left hand obj
            {
                _dorpProp = leftHandPropRoot;
            }

            if (_dorpProp.currentProp != null)
            {
                // turn on tigger collider
                _dorpProp.currentProp.gameObject.GetComponent<SphereCollider>().enabled = true;
                _dorpProp.currentProp.gameObject.GetComponentInChildren<BS_Marker_Manager>()._markersAreEnabled = true;
                // drop item on hand
                _dorpProp.currentProp = null;
            }
        }
コード例 #6
0
 // Use this for initialization
 void Start()
 {
     propLeft  = GetComponent <Player_Attack_Behavior>().PropRootLeft;
     propRight = GetComponent <Player_Attack_Behavior>().PropRootRight;
 }