Example #1
0
        public virtual void Initialize(Inventory inventory)
        {
            m_controller = inventory.GetComponent <RigidbodyCharacterController>();
            m_character  = inventory.gameObject;
            m_inventory  = inventory;

            m_gameObject = gameObject;
            m_transform  = transform;



            if (m_character != null)
            {
                //EventHandler.RegisterEvent(m_character, EventIDs.OnAnimatorEquipItem, ItemActivated);
                //EventHandler.RegisterEvent(m_character, EventIDs.OnAnimatorUnequipItem, ItemDeactivated);
                //EventHandler.RegisterEvent(m_character, EventIDs.OnAnimatorDropItem, ItemDeactivated);
                //EventHandler.RegisterEvent(m_character, EventIDs.OnAnimatorPickupItem, ItemActivated);
                //Debug.LogFormat("Registering event equip event for {0}", m_itemType.name);
            }


            if (m_nonDominantHandIKTarget == null)
            {
                m_nonDominantHandIKTarget                  = new GameObject("NonDominantHandIKTarget").transform;
                m_nonDominantHandIKTarget.parent           = m_transform;
                m_nonDominantHandIKTarget.localPosition    = Vector3.zero;
                m_nonDominantHandIKTarget.localEulerAngles = new Vector3(3, 50, 180);
            }


            //OnEquipEvent.AddListener(m_inventory.EquipItem);
            //OnUnequipEvent.AddListener(m_inventory.UnequipCurrentItem);
        }
Example #2
0
        private void Awake()
        {
            if (m_animator == null)
            {
                m_animator = GetComponent <Animator>();
            }
            m_controller = GetComponent <RigidbodyCharacterController>();
            m_transform  = transform;
            m_gameObject = gameObject;

            //Initialize();
        }
Example #3
0
        private void Awake()
        {
            m_Animator     = GetComponent <Animator>();
            m_controller   = GetComponent <RigidbodyCharacterController>();
            m_LayerManager = GetComponent <LayerManager>();
            m_Transform    = transform;
            m_GameObject   = gameObject;
            m_DeltaTime    = Time.deltaTime;


            m_RightHand     = m_Animator.GetBoneTransform(HumanBodyBones.RightHand).transform;
            m_LeftHand      = m_Animator.GetBoneTransform(HumanBodyBones.LeftHand).transform;
            m_UpperChest    = m_Animator.GetBoneTransform(HumanBodyBones.UpperChest).transform;
            m_RightShoulder = m_Animator.GetBoneTransform(HumanBodyBones.RightShoulder).transform;
            m_Head          = m_Animator.GetBoneTransform(HumanBodyBones.Head).transform;

            m_AimPivot = new GameObject("Aim Pivot").transform;
            m_AimPivot.transform.parent = gameObject.transform;
            m_AimPivot.position         = m_RightShoulder.position;

            if (m_RightHandTarget == null)
            {
                m_RightHandTarget = new GameObject("Right Hand Target").transform;
                m_RightHandTarget.localPosition    = Vector3.zero;
                m_RightHandTarget.transform.parent = m_AimPivot;
            }
            else
            {
                var rightHandTargetPos = m_RightHandTarget.localPosition;
                var rightHandTargetRot = m_RightHandTarget.localRotation;
                m_RightHandTarget.transform.parent = m_AimPivot;
                m_RightHandTarget.localPosition    = rightHandTargetPos;
                m_RightHandTarget.localRotation    = rightHandTargetRot;
            }


            m_LeftHandTarget = new GameObject("Left Hand Target").transform;
            m_LeftHandTarget.transform.parent = m_AimPivot;
            m_LeftHandTarget.localPosition    = Vector3.zero;
        }
        //
        // Properties
        //



        //
        // Methods
        //
        private void Awake()
        {
            m_stateNameHash = new Dictionary <string, int>();
            m_stateHashName = new Dictionary <int, string>();

            m_stateBeginCallbackMap = new Dictionary <int, Delegate>();
            m_stateEndCallbackMap   = new Dictionary <int, Delegate>();

            m_animator   = GetComponent <Animator>();
            m_controller = GetComponent <RigidbodyCharacterController>();
            m_inventory  = GetComponent <Inventory>();
            //  Set m_deltaTime.
            m_deltaTime = m_animator.updateMode == AnimatorUpdateMode.AnimatePhysics ? Time.fixedDeltaTime : Time.deltaTime;

            //  Initialize statebehaviors.
            InitializeStateBehaviors();



            EventHandler.RegisterEvent <CharacterAction, bool>(gameObject, EventIDs.OnCharacterActionActive, OnActionActive);
            EventHandler.RegisterEvent <ItemAction, bool>(gameObject, EventIDs.OnItemActionActive, OnItemActionActive);
        }