Esempio n. 1
0
 public void OnCollisionEnter2D(Collision2D collision)
 {
     // We have collider with the player
     if (collision.gameObject.GetComponent <TopDownEnemy>() != null)
     {
         // Let the spawn manager know that this enemy has dies
         SpawnableManager.informSpawnableDestroyed(collision.gameObject, true);
     }
 }
Esempio n. 2
0
        private void Cmd_takeHit(int objectID)
        {
            foreach (NetworkIdentity identity in Component.FindObjectsOfType <NetworkIdentity>())
            {
                if (identity.netId.Value == objectID)
                {
                    // Try to get the ai script
                    TargetAI ai = identity.GetComponentInChildren <TargetAI>();

                    // Check for the target AI component
                    if (ai != null)
                    {
                        // Inform the enemy manager that an enemy has died
                        SpawnableManager.informSpawnableDestroyed(identity.gameObject, true);
                    }

                    break;
                }
            }
        }
Esempio n. 3
0
        private void takeHit(RaycastHit hit)
        {
            // Get the game object
            GameObject hitObject = hit.collider.gameObject;

            // Find the highest level transform
            Transform hitRoot = hitObject.transform.root;

#if ULTIMATE_SPAWNER_NETWORKED == true
            NetworkIdentity id = hitRoot.GetComponent <NetworkIdentity>();

            // We have hit a static scene object
            if (id == null)
            {
                return;
            }

            // We have hit a non-enemy object (Another player)
            if (id.GetComponent <TargetAI>() == null)
            {
                return;
            }

            // Kill the enemy
            Cmd_takeHit((int)id.netId.Value);
#else
            // Try to get the ai script
            TargetAI ai = hitRoot.GetComponentInChildren <TargetAI>();


            // Check for the target AI component
            if (ai != null)
            {
                // Inform the enemy manager that an enemy has died
                SpawnableManager.informSpawnableDestroyed(hitRoot.gameObject, true);
            }
#endif
        }