Exemple #1
0
        /// INITIAL SETUP - prepare the initial information like camera, capsule collider, physics materials, etc...
        public void InitialSetup()
        {
            animator = GetComponent <Animator>();

            tpCamera     = TPCamera.instance;
            hud          = HUDController.instance;
            meleeManager = GetComponent <MeleeEquipmentManager>();
            // create a offset pivot to the character, to align camera position when transition to ragdoll
            var hips = animator.GetBoneTransform(HumanBodyBones.Hips);

            offSetPivot = Vector3.Distance(transform.position, hips.position);

            if (tpCamera != null)
            {
                tpCamera.offSetPlayerPivot = offSetPivot;
                tpCamera.target            = transform;
            }

            if (hud == null)
            {
                Debug.LogWarning("Invector : Missing HUDController, please assign on ThirdPersonController");
            }

            // prevents the collider from slipping on ramps
            frictionPhysics                 = new PhysicMaterial();
            frictionPhysics.name            = "frictionPhysics";
            frictionPhysics.staticFriction  = 1f;
            frictionPhysics.dynamicFriction = 1f;

            // default physics
            slippyPhysics                 = new PhysicMaterial();
            slippyPhysics.name            = "slippyPhysics";
            slippyPhysics.staticFriction  = 0f;
            slippyPhysics.dynamicFriction = 0f;

            _rigidbody       = GetComponent <Rigidbody>();       // rigidbody info
            _capsuleCollider = GetComponent <CapsuleCollider>(); // capsule collider

            // save your collider preferences
            colliderCenter = GetComponent <CapsuleCollider>().center;
            colliderRadius = GetComponent <CapsuleCollider>().radius;
            colliderHeight = GetComponent <CapsuleCollider>().height;

            currentHealth = startingHealth;
            currentHealthRecoveryDelay = healthRecoveryDelay;
            currentStamina             = startingStamina;

            if (hud == null)
            {
                return;
            }

            //hud.damageImage.color = new Color(0f, 0f, 0f, 0f);

            cameraTransform.SendMessage("Init", SendMessageOptions.DontRequireReceiver);
            UpdateHUD();
        }
Exemple #2
0
 void OnEnable()
 {
     meleeEquip = (MeleeEquipmentManager)target;
     animator   = meleeEquip.gameObject.GetComponent <Animator>();
     if (animator)
     {
         rightHand = animator.GetBoneTransform(HumanBodyBones.RightHand);
         rightArm  = animator.GetBoneTransform(HumanBodyBones.RightLowerArm);
         leftHand  = animator.GetBoneTransform(HumanBodyBones.LeftHand);
         leftArm   = animator.GetBoneTransform(HumanBodyBones.LeftLowerArm);
     }
 }
Exemple #3
0
        public void Init()
        {
            if (randomWaypoint == null)
            {
                randomWaypoint = new FisherYatesRandom();
            }
            if (randomPatrolPoint == null)
            {
                randomPatrolPoint = new FisherYatesRandom();
            }
            currentWaypoint    = -1;
            currentPatrolPoint = -1;

            agent = GetComponent <NavMeshAgent>();
            agent.updateRotation = false;
            agentPath            = new NavMeshPath();

            animator     = GetComponent <Animator>();
            meleeManager = GetComponent <MeleeEquipmentManager>();
            canAttack    = true;
            sideMovement = GetRandonSide();
            destination  = transform.position;

            _rigidbody             = GetComponent <Rigidbody>();
            _rigidbody.useGravity  = false;
            _rigidbody.isKinematic = false;
            _rigidbody.constraints = RigidbodyConstraints.None | RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ;
            _capsuleCollider       = GetComponent <CapsuleCollider>();

            healthSlider  = GetComponentInChildren <SpriteHealth>();
            head          = animator.GetBoneTransform(HumanBodyBones.Head);
            oldPosition   = transform.position;
            currentHealth = startingHealth;

            method = OffMeshLinkMoveMethod.Grounded;

            if (vGameController.instance != null && vGameController.instance.currentPlayer != null)
            {
                target = vGameController.instance.currentPlayer.transform;
            }
        }
Exemple #4
0
    public override void OnInspectorGUI()
    {
        if (!skin)
        {
            skin = Resources.Load("skin") as GUISkin;
        }
        GUI.skin = skin;

        MeleeEquipmentManager meleeEquip = (MeleeEquipmentManager)target;

        GUILayout.BeginVertical("Melee Manager", "window");

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (meleeEquip.hitProperts != null && meleeEquip.hitProperts.useRecoil && meleeEquip.hitProperts.hitRecoilLayer == 0)
        {
            EditorGUILayout.HelpBox("Please assign the HitRecoilLayer to Default", MessageType.Warning);
        }

        EditorGUILayout.BeginVertical();
        if (!animator)
        {
            EditorGUILayout.HelpBox("This just work with Animator Component", MessageType.Info);
            GUILayout.EndVertical();
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            return;
        }

        if (meleeEquip.hitProperts != null && meleeEquip.hitProperts.hitDamageTags != null)
        {
            if (meleeEquip.hitProperts.hitDamageTags.Contains(meleeEquip.gameObject.tag))
            {
                EditorGUILayout.HelpBox("Please change your HitDamageTags inside the HitProperties, they cannot have the same tag as this gameObject.", MessageType.Error);
            }
        }

        base.OnInspectorGUI();

        if (animator != null)
        {
            EditorGUILayout.BeginHorizontal("box");
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("+"))
            {
                AddHandler(rightArm);
            }

            if (GUILayout.Button("Right Arm"))
            {
                Selection.activeTransform = rightArm;
            }
            if (GUILayout.Button("Left Arm"))
            {
                Selection.activeTransform = leftArm;
            }

            if (GUILayout.Button("+"))
            {
                AddHandler(leftArm);
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal("box");
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("+"))
            {
                AddHandler(rightHand);
            }

            if (GUILayout.Button("Right Hand"))
            {
                Selection.activeTransform = rightHand;
            }
            if (GUILayout.Button("Left Hand"))
            {
                Selection.activeTransform = leftHand;
            }

            if (GUILayout.Button("+"))
            {
                AddHandler(leftHand);
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.HelpBox("You can create weapon handler (empty gameobject) for each weapon, them assign the handler to the corresponding weapon.", MessageType.Info);
        GUILayout.EndVertical();
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(meleeEquip);
        }
    }