Esempio n. 1
0
    void Death()
    {
        Destroy(gameObject);
        if (destroyEffect != null)
        {
            Instantiate(destroyEffect, transform.position, transform.rotation);
        }

        if (Type == TypeOfContact.Player)
        {
            gameController.die();
        }
        else
        {
            //If the other tag is Player Generated, then grant points.

            if (transform.localScale.x > 1)
            {
                PointsToAdd = (int)transform.localScale.x * PointsToAdd;
            }
            if (HitBy.ContactType() == TypeOfContact.PlayerProjectile)
            {
                if (PointsToAdd > 0)
                {
                    gameController.AddScore(PointsToAdd);
                }
                else
                {
                    gameController.SubtractScore(PointsToAdd);
                }
            }
        }
    }
Esempio n. 2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }
        if (other.tag == transform.tag)
        {
            return;
        }

        HitBy = other.GetComponent <OnContact> ();

        //What am i and what will i do!
        switch (Type)
        {
        case TypeOfContact.PlayerProjectile:
            TakeDamage(HitBy.DealDamage());
            break;

        case TypeOfContact.Player:
            if ((HitBy.ContactType() == TypeOfContact.EnemyProjectile) ||
                (HitBy.ContactType() == TypeOfContact.Enemy))
            {
                TakeDamage(HitBy.DealDamage());
            }

            break;

        case TypeOfContact.Enemy:
        case TypeOfContact.EnemyProjectile:
            if ((HitBy.ContactType() == TypeOfContact.PlayerProjectile) ||
                (HitBy.ContactType() == TypeOfContact.Player))
            {
                TakeDamage(HitBy.DealDamage());
            }
            break;

        case TypeOfContact.PowerUp:
            if (HitBy.ContactType() == TypeOfContact.Player)
            {
                switch (DestroyBonus)
                {
                case OnDestroyed.ExtraLife:
                    gameController.AddLife(1);
                    Death();
                    break;
                }
            }
            else if (HitBy.ContactType() == TypeOfContact.PlayerProjectile)
            {
                TakeDamage(HitBy.DealDamage());
            }
            break;
        }
    }