Example #1
0
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            // IF we are dead.
            if (isDead)
            {
                // Leave.
                return;
            }
            // We are dead.
            isDead = true;

            // IF there is a Loot component attached to this GameObject.
            if (animator.GetComponentInChildren <Loot>() != null)
            {
                // Drop loot.
                animator.GetComponentInChildren <Loot> ().DeathDrop();
            }
            // IF there is a Experience_NPCDeath component attached to this GameObject.
            if (animator.GetComponentInChildren <Experience_NPCDeath>() != null)
            {
                // Give the player experience points.
                animator.GetComponentInChildren <Experience_NPCDeath> ().GivePlayerExperience();
            }

            // Get the Character_Manager.
            Character_Manager charManager = animator.GetComponentInParent <Character_Manager> ();

            // Make sure to stop this GameObject from moving.
            charManager.canMove = false;
            // Get all Collider2D's associated with this GameObject.
            Collider2D[] allColliders = charManager.GetComponentsInChildren <Collider2D> ();
            // Loop and set all the Collider2D's INACTIVE.
            for (int i = 0; i < allColliders.Length; i++)
            {
                // Set the Collider2D's INACTIVE.
                allColliders [i].enabled = false;
            }
            // Send off the kill of this GameObject to our Quest System.
            //Grid_Helper.questManager.QuestMobKill (animator.GetComponentInParent <Character_Manager>().characterEntity.name);
            // Destroy this gameobject.
            Destroy(charManager.gameObject);
//			Destroy(charManager.gameObject, timeTillDestroy);
        }