Ejemplo n.º 1
0
    // Apply damage, destroy if appropriate
    public void applyDamage(float damage)
    {
        health -= damage;

        if (health <= 0)
        {
            Destroy(this.gameObject);
            ExplosionHandler.createAndDestroyExplosion(this.gameObject.transform.position, explosion);
            spawnLoot();                                        // Looot
            EnemyManager.decrementEnemyCount(1);                // Decrement the count of enemies in the manager
        }
    }
Ejemplo n.º 2
0
    public void applyDamage(float damage)
    {
        health -= damage;

        if (health <= 0)
        {
            ExplosionHandler.createAndDestroyExplosion(this.gameObject.transform.position, explosion);
            health = 100;
        }

        healthBar.setHealth(health);
    }
Ejemplo n.º 3
0
//	public virtual void OnCollisionEnter2D(Collision2D collision)
//	{
//		// Explosion location where player is
//		explosion.transform.position = this.gameObject.transform.position;
//
//		// Pass to ExplosionHandler to create explosion
//		ExplosionHandler.createAndDestroyExplosion (this.gameObject.transform.position, explosion);
//
//		// Apply the projectile damage to the object
//		if (collision.gameObject.tag == "Enemy" || collision.gameObject.tag == "Player") {
//			collision.gameObject.BroadcastMessage ("applyDamage", damage);
//		}
//
//		Destroy (this.gameObject);	// Destroy projectile after collision
//	}

    public virtual void OnTriggerEnter2D(Collider2D collider)
    {
        // Explosion location where player is
        explosion.transform.position = this.gameObject.transform.position;

        // Pass to ExplosionHandler to create explosion
        ExplosionHandler.createAndDestroyExplosion(this.gameObject.transform.position, explosion);

        // Apply the projectile damage to the object
        if (collider.gameObject.tag == "Enemy" || collider.gameObject.tag == "Player")
        {
            collider.gameObject.BroadcastMessage("applyDamage", damage);
        }

        Destroy(this.gameObject);               // Destroy projectile after collision
    }
Ejemplo n.º 4
0
//	public override void OnCollisionEnter2D(Collision2D collision) {
//		// Explosion location where player is
//		explosion.transform.position = this.gameObject.transform.position;
//
//		// Pass to ExplosionHandler to create explosion
//		ExplosionHandler.createAndDestroyExplosion (this.gameObject.transform.position, explosion);
//
//		// Apply the projectile damage to the object
//		if (collision.gameObject.tag == "Enemy" || collision.gameObject.tag == "Player") {
//			collision.gameObject.BroadcastMessage ("applyDamage", damage);
//			if(maxPassThroughs-- > 0) {
//				damage += damageBoost;
//				projectileSpeed -= speedReduction;
//			} else {
//				Destroy (this.gameObject);	// Destroy projectile after collision
//			}
//		}
//
//
//	}

    public override void OnTriggerEnter2D(Collider2D collider)
    {
        // Explosion location where player is
        explosion.transform.position = this.gameObject.transform.position;

        // Pass to ExplosionHandler to create explosion
        ExplosionHandler.createAndDestroyExplosion(this.gameObject.transform.position, explosion);

        // Apply the projectile damage to the object
        if (collider.gameObject.tag == "Enemy" || collider.gameObject.tag == "Player")
        {
            collider.gameObject.BroadcastMessage("applyDamage", damage);
            if (maxPassThroughs-- > 0)
            {
                damage          += damageBoost;
                projectileSpeed -= speedReduction;
            }
            else
            {
                Destroy(this.gameObject);                       // Destroy projectile after collision
            }
        }
    }