Пример #1
0
    // main event
    void OnCollisionEnter(Collision collider)
    {
        // when something collides with our ship, we check its layer to see if it is on 11
        if (collider.gameObject.layer == 10 && !isRespawning && !isInvulnerable)
        {
            ArmedEnemy_Tank enemyManager = collider.gameObject.GetComponent <ArmedEnemy_Tank> ();
            if (enemyManager)
            {
                float reduceHels = myDataManager.GetProtection() * enemyManager.GetContactDamage();

                ReduceLife(reduceHels);
            }
        }
    }
Пример #2
0
    // main event
    public void OnCollisionEnter(Collision collider)
    {
        // when something collides with us, we check its layer to see if it is on 9
        if (collider.gameObject.layer == 9 && !isRespawning)
        {
            ProjectileController projManager = collider.gameObject.GetComponent <ProjectileController> ();
            if (projManager)
            {
                float reduceHels = myDataManager_New.GetProtection() * projManager.OverrideDamageValue;
                tempINT = int.Parse(collider.gameObject.name);

                ReduceLife(reduceHels);
            }
        }

        // we contact with player
        if (collider.gameObject.layer == 8 && !isRespawning)
        {
            // tell game controller to make an explosion at our position and to award the player points for hitting us
            TellGCEnemyDestroyed();

            // if this is a boss enemy, tell the game controller when we get destroyed so it can end the level
            if (isBoss)
            {
                TellGCBossDestroyed();
            }

            // destroy this
            Destroy(gameObject);
        }

        // we contact with player
        if (collider.gameObject.layer == 20)
        {
            // tell game controller to make an explosion at our position and to award the player points for hitting us
            TellGCEnemyDestroyed();

            // destroy this
            Destroy(gameObject);
        }
    }