Exemplo n.º 1
0
    public override void ActionUpdate(float timekey)
    {
        timer += timekey;

        if (timer > spawnDelay && !projectileSpawned)
        {
            // apply damage
            Vector3 spawnPoint = character.transform.position + character.transform.TransformDirection(projectileSpawn);

            projectileInstance = GameObject.Instantiate(projectile);
            projectileInstance.transform.position = spawnPoint;
            projectileInstance.character          = character;
            projectileInstance.velocity           = velocity;

            projectileSpawned = true;
        }

        if (timer > spawnDelay + timeOfFlight)
        {
            projectileInstance.Destroy();

            Destructible destructible = target.GetComponent <Destructible>();

            if (destructible != null)
            {
                destructible.Damage(CombatUtils.GetDamageToDestructible(destructible, baseDamage * damageModifer));
            }

            Done();
        }
    }
Exemplo n.º 2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Destructible destructible = collision.gameObject.GetComponent <Destructible>();

        if (destructible)
        {
            destructible.Damage(damageAmount);
        }
    }
Exemplo n.º 3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Destructible destructible = collision.GetComponent <Destructible>();

        if (destructible)
        {
            destructible.Damage(damageAmount);
        }
    }
Exemplo n.º 4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (controller?.owner != collision.gameObject && !collision.isTrigger)
     {
         Destructible destructible = collision.GetComponent <Destructible>();
         if (destructible)
         {
             destructible.Damage(damageAmount);
         }
     }
 }
Exemplo n.º 5
0
    private void applyEffects()
    {
        if (effect != null)
        {
            GameObject instance = GameObject.Instantiate(effect);
            instance.transform.position = targetSelf ? character.position : target.position;
        }

        destructible.Damage(CombatUtils.GetDamageToDestructible(destructible, weapon.baseDamage * damageModifier));
        target.AddBuffs(buffs);
    }
Exemplo n.º 6
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject != bulletController.owner)
     {
         Destructible destructible = collision.GetComponent <Destructible>();
         if (destructible)
         {
             destructible.Damage(damage);
         }
     }
 }
Exemplo n.º 7
0
    void OnTriggerEnter(Collider collision)
    {
        Destructible dest = collision.attachedRigidbody.GetComponent <Destructible>();

        if (dest != null && WouldDamage(dest.gameObject))
        {
            float damage = Random.Range(Damage.x, Damage.y);
            dest.Damage(OriginObject.GetComponent <Actor>(), damage, transform.position, GetComponent <Actor>().Velocity.normalized, ImpactStrength);

            if (DestroyOnImpact)
            {
                if (ImpactEffect.Length > 0)
                {
                    Instantiate(RandomUtils.Pick(ImpactEffect), transform.position, transform.rotation);
                }
                Destroy(gameObject);
            }
        }
    }
Exemplo n.º 8
0
    private void Damage()
    {
        Collider2D[] collidersInRange = Physics2D.OverlapCircleAll(transform.position, damageRadius);
        foreach (Collider2D collider in collidersInRange)
        {
            // Test if object can be damaged
            Destructible dest = collider.GetComponent <Destructible>();
            if (dest)
            {
                dest.Damage(damageAmount);
            }
        }

        strikesElapsed++;
        if (strikesElapsed < strikeCount)
        {
            Invoke("Damage", strikeInterval);
        }
    }
Exemplo n.º 9
0
    IEnumerator Destroy()
    {
        yield return(new WaitForSeconds(0.25f));

        des.Damage(100f);
    }