Ejemplo n.º 1
0
        private void OnDestroy()
        {
            HostileNpcs.Remove(this);
            Npcs.Remove(this);
            if (Item != null)
            {
                Item.Dispose();
            }

            Destroy(gameObject);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Make the NPC fall down and die
        /// </summary>
        /// <param name="hitMessage"></param>
        private void Die(HitMessage hitMessage)
        {
            IsAlive = false;

            //Activate LoseLimb Function of DetachableLimb.cs if Script is on hitObjects root. for Dummies
            if (hitMessage.HitObject.transform.root.GetComponent <DetachableLimbs>() != null)
            {
                hitMessage.HitObject.transform.root.SendMessage("LoseLimb", hitMessage,
                                                                SendMessageOptions.DontRequireReceiver);
            }
            //Ragdoll on Full
            Ragdoll.ragFull = true;
            Ragdoll.RagOn(hitMessage);
            Ragdoll.blend = false;

            //set item apart from owner
            if (Item != null && Item.Instance != null && Item.Instance.GetComponent <Rigidbody>() != null)
            {
                StartCoroutine(DropWeapon(hitMessage));
            }

            NavMeshAgent.enabled    = false;
            NavMeshObstacle.enabled = true;

            if (IsHostile)
            {
                Statistics.DeadHostilesByPlayer++;
                HostileNpcs.Remove(this);
            }
            else
            {
                Statistics.DeadFriendliesByPlayer++;
            }


            OnNPCDeathEvent(this, hitMessage);
        }