Exemplo n.º 1
0
 void SelfDestructAndDoDamage(GameObject collidingObject)
 {
     if (CanCollideWith(collidingObject))
     {
         EnemyIntroStageVile introVile = collidingObject.gameObject.GetComponent <EnemyIntroStageVile>();
         Hitpoints           collidingObjectHitpoints = collidingObject.GetComponent <Hitpoints> ();
         if (hitMultipleEnemies && introVile != null)
         {
             if (collidingObjectHitpoints != null)
             {
                 collidingObjectHitpoints.Damage(damage, gameObject, damageSourceOwner);
                 if (damage <= collidingObjectHitpoints.hitpoints)
                 {
                     Destroy(gameObject);
                 }
             }
         }
         else
         {
             if (collidingObjectHitpoints != null)
             {
                 collidingObjectHitpoints.Damage(damage, gameObject, damageSourceOwner);
             }
             Destroy(gameObject);
         }
     }
 }
Exemplo n.º 2
0
 void OnTriggerEnter2D(Collider2D localCollider2D)
 {
     if (!damageLock)
     {
         if (CanCollideWith(localCollider2D.gameObject))
         {
             Hitpoints hitpoints = megamanController.gameObject.GetComponent <Hitpoints>();
             hitpoints.Damage(damage, gameObject, gameObject);
             damageLock = true;
         }
     }
 }
Exemplo n.º 3
0
    protected Hitpoints Damage(GameObject localGameObject, float damage)
    {
        Hitpoints hitpoints = null;

        if (CanCollideWith(localGameObject))
        {
            hitpoints = localGameObject.GetComponent <Hitpoints>();
            if (hitpoints != null)
            {
                hitpoints.Damage(damage, gameObject, gameObject);
            }
        }

        return(hitpoints);
    }
Exemplo n.º 4
0
 void OnTriggerEnter2D(Collider2D localCollider2D)
 {
     if (!localCollider2D.gameObject.Equals(gameObject))
     {
         Hitpoints hitpoints = localCollider2D.gameObject.GetComponent <Hitpoints> ();
         if (hitpoints != null)
         {
             hitpoints.Damage(1000000f, gameObject, gameObject);
         }
         else
         {
             Destroy(localCollider2D.gameObject);
         }
     }
 }
Exemplo n.º 5
0
        protected virtual void ApplyHealthModification()
        {
            var modifiedHealth = GetModifiedHealth();

            if (modifiedHealth < _hitpoints.health)
            {
                var damageAmount = _hitpoints.health - modifiedHealth;
                _hitpoints.Damage(new Damage(damageAmount));
            }
            else if (modifiedHealth > _hitpoints.health)
            {
                var healAmount = modifiedHealth - _hitpoints.health;
                _hitpoints.Heal(new Heal(healAmount));
            }
        }
Exemplo n.º 6
0
 void Explode()
 {
     Collider2D[] allColliders = Physics2D.OverlapCircleAll(transform.position, explosionRadius);
     foreach (Collider2D collider2D in allColliders)
     {
         MegamanController megamanController = collider2D.gameObject.GetComponent <MegamanController>();
         if (megamanController != null)
         {
             Hitpoints hitpoints = megamanController.GetComponent <Hitpoints>();
             if (hitpoints != null)
             {
                 hitpoints.Damage(damage, gameObject, null);
             }
         }
     }
     Destroy(gameObject);
 }
Exemplo n.º 7
0
    IEnumerator AttackRoutine()
    {
        MegamanController megamanController = null;

        while (true)
        {
            RaycastHit2D[] allHits = Physics2D.RaycastAll(transform.position, targetPosition.localPosition, 5f, megamanLayer.value);
            foreach (RaycastHit2D localHit2D in allHits)
            {
                megamanController = localHit2D.collider.gameObject.GetComponent <MegamanController>();
                if (megamanController != null)
                {
                    Hitpoints hitpoints = megamanController.gameObject.GetComponent <Hitpoints>();
                    hitpoints.Damage(damage, gameObject, gameObject);
                    break;
                }
            }
            yield return(new WaitForSeconds(0.5f));
        }
    }
Exemplo n.º 8
0
    void OnTriggerEnter2D(Collider2D localCollider2D)
    {
        MegamanController megamanController = localCollider2D.gameObject.GetComponent <MegamanController> ();

        if (megamanController != null)
        {
            Hitpoints hitpoints = megamanController.gameObject.GetComponent <Hitpoints>();
            hitpoints.Damage(damage, gameObject, gameObject);
            if (currentForm == 1)
            {
                if (!IsInvoking("RotateMeOnX"))
                {
                    Invoke("RotateMeOnX", 1.5f);
                }
                if (!IsInvoking("Fire"))
                {
                    Invoke("Fire", 2.0f);
                }
            }
        }
    }