Esempio n. 1
0
    public override void OnTriggerEnter2D(Collider2D other)
    {
        //RETURN CONDITIONS
        if (other.tag == "Wall")
        {
            if (explodeOnHit)
            {
                Explode();
                return;
            }
            return;
        }

        Base_Health otherHealth = other.GetComponent <Base_Health> ();

        if (otherHealth == null || otherHealth.GetPlayerTag().Id == id || (otherHealth.GetPlayerTag().Team != 0 && otherHealth.GetPlayerTag().Team == team))
        {
            return;
        }

        if (canStun)
        {
            otherHealth.AddStun();
        }
        DamageTarget(otherHealth);
        // ELSE CASE??

        if (explodeOnHit)
        {
            Explode();
            return;
        }
    }
Esempio n. 2
0
    protected virtual void MeleeAttack(Component other)
    {
        Base_Health otherHealth = other.GetComponent <Base_Health> ();

        if (otherHealth == null)
        {
            return;
        }
        if (playerTag.Team != 0 && otherHealth.GetPlayerTag().Team == playerTag.Team)
        {
            return;
        }
        float multipliedDamage = damage;

        if (other.GetComponent <OLD_BaseMob> () != null)
        {
            multipliedDamage *= onMobMultiplier;
        }
        else if (other.GetComponent <Player_Health> () != null)
        {
            multipliedDamage *= onPlayerMultiplier;
        }

        if (otherHealth.GetPlayerTag().Id != playerTag.Id)
        {
            otherHealth.TakeDamage(multipliedDamage, playerTag.Id, playerTag.Team);
        }
        StartCoroutine(HitRoutine());
    }
Esempio n. 3
0
    void OnTriggerStay2D(Collider2D other)
    {
        if (!canAttack)
        {
            return;
        }
        Base_Health health = other.GetComponent <Base_Health> ();

        if (health != null)
        {
            if (health.GetPlayerTag().Id != playerTag.Id && (health.GetPlayerTag().Team == 0 || health.GetPlayerTag().Team != playerTag.Team))
            {
                if (health.Health - damage <= 0f)
                {
                    if (other.GetComponent <Player_Health> () != null)
                    {
                        for (int i = 0; i < skeelAmount; i++)
                        {
                            GameObject skeel = Instantiate(skeelPrefab, other.transform.position, Quaternion.identity);
                            skeel.GetComponent <Mob_Skeel> ().Ini(null, playerTag.Id, playerTag.Team, true);
                        }
                    }
                }
                health.TakeDamage(damage, playerTag.Id, playerTag.Team);
                StartCoroutine(AttackCooldown());
            }
        }
    }
Esempio n. 4
0
    public virtual void OnTriggerEnter2D(Collider2D other)
    {
        //RETURN CONDITIONS
        if (other.tag == "Wall")
        {
            if (deathParticlePrefab != null)
            {
                Instantiate(deathParticlePrefab, transform.position, transform.rotation);
            }
            if (destroyOnHit)
            {
                Destroy(gameObject);
                return;
            }
            return;
        }
        Base_Health otherHealth = other.GetComponent <Base_Health> ();

        if (otherHealth == null || otherHealth.GetPlayerTag().Id == id || (otherHealth.GetPlayerTag().Team != 0 && otherHealth.GetPlayerTag().Team == team))
        {
            return;
        }

        if (canStun)
        {
            otherHealth.AddStun();
        }

        DamageTarget(otherHealth);
        // ELSE CASE??
    }
Esempio n. 5
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (released)
     {
         Base_Health health = other.GetComponent <Base_Health> ();
         if (health != null)
         {
             if (health.GetPlayerTag().Id != playerTag.Id || (health.GetPlayerTag().Team != 0 && health.GetPlayerTag().Team != playerTag.Team))
             {
                 GameObject temp = Instantiate(splashDamagePrefab, transform.position, Quaternion.identity) as GameObject;
                 temp.GetComponent <Base_Bullet> ().SetInfo(playerTag.Id, playerTag.Team);
                 Destroy(gameObject);
             }
         }
     }
     else
     {
         Base_Bullet bullet = other.GetComponent <Base_Bullet> ();
         if (other.GetComponent <Bullet_Explosion> () != null)
         {
             return;
         }
         if (other.GetComponent <Katana_Bullet> () != null)
         {
             return;
         }
         if (bullet != null)
         {
             if (bullet.Id != playerTag.Id && (bullet.Team == 0 || bullet.Team != playerTag.Team))
             {
                 Destroy(other.gameObject);
             }
         }
         else if (other.GetComponent <Base_Mob> () != null)
         {
             if (!canAttack)
             {
                 return;
             }
             Base_Health health = other.GetComponent <Base_Health> ();
             if (health != null)
             {
                 if (health.GetPlayerTag().Id != playerTag.Id && (health.GetPlayerTag().Team == 0 || health.GetPlayerTag().Team != playerTag.Team))
                 {
                     StartCoroutine(AttackCooldown());
                     health.TakeDamage(damage, playerTag.Id, playerTag.Team);
                 }
             }
         }
     }
 }
Esempio n. 6
0
    public override void AddTarget(GameObject _gameObject)
    {
        Base_Health otherHealth = _gameObject.GetComponent <Base_Health> ();

        if (otherHealth != null)
        {
            if (otherHealth.GetPlayerTag().Id != playerTag.Id && (otherHealth.GetPlayerTag().Team == 0 || otherHealth.GetPlayerTag().Team != playerTag.Team))
            {
                if (!targets.Contains(_gameObject))
                {
                    targets.Add(_gameObject);
                }
            }
        }
    }
Esempio n. 7
0
    public override void OnTriggerEnter2D(Collider2D other)
    {
        Base_Health otherHealth = other.GetComponent <Base_Health> ();

        if (otherHealth == null || otherHealth.GetPlayerTag().Id == id || (otherHealth.GetPlayerTag().Team != 0 && otherHealth.GetPlayerTag().Team == team))
        {
            return;
        }

        if (swim)
        {
            Pirahna_Bullet[] bullets = FindObjectsOfType <Pirahna_Bullet> ();
            foreach (Pirahna_Bullet bullet in bullets)
            {
                bullet.ResetKillFlag(Base_Health.KILL_FLAGS.PIRAHNA);
                Rigidbody2D oBody = bullet.GetComponent <Rigidbody2D> ();
                oBody.velocity            = Vector3.Normalize(other.transform.position - bullet.transform.position) * move_speed * 5f;
                bullet.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, Mathf.Atan2(oBody.velocity.y, oBody.velocity.x)));
                bullet.swim = false;
            }
            killFlag = Base_Health.KILL_FLAGS.NONE;
        }


        if (canStun)
        {
            otherHealth.AddStun();
        }

        DamageTarget(otherHealth);



        //RETURN CONDITIONS

        /*
         * if (other.tag == "Wall") {
         *      if (deathParticlePrefab != null)
         *              Instantiate (deathParticlePrefab, transform.position, Quaternion.identity);
         *      if (destroyOnHit) {
         *              Destroy (gameObject);
         *              return;
         *      }
         *      return;
         * }
         */
        // ELSE CASE??
    }
Esempio n. 8
0
    protected override void DamageTarget(Base_Health otherHealth)
    {
        if (!canDamage)
        {
            return;
        }
        //DAMAGE
        float maxDist = collider.radius * transform.localScale.x;
        float dist    = Vector3.Distance(transform.position, otherHealth.transform.position);
        float value   = (maxDist - dist) / maxDist;

        if (value <= 0f)
        {
            return;
        }
        {
            Rigidbody2D otherBody = otherHealth.GetComponent <Rigidbody2D> ();

            Vector2 diff = (maxDist - dist / maxDist) * (damage * (otherBody.position - mBody.position).normalized) * .25f;
            otherBody.AddForce(diff, ForceMode2D.Impulse);
        }

        int _id = id;

        if (otherHealth.GetPlayerTag().Id == id)
        {
            _id = -1;
        }

        otherHealth.TakeDamage(damage * (value), _id, team);
        excludeObjects.Add(otherHealth.gameObject);
    }
Esempio n. 9
0
    public override void OnTriggerEnter2D(Collider2D other)
    {
        Base_Health otherHealth = other.GetComponent <Base_Health> ();

        if (otherHealth != null)
        {
            if (otherHealth.GetPlayerTag().Id != id)
            {
                if (otherHealth.GetPlayerTag().Team == 0 || otherHealth.GetPlayerTag().Team != team)
                {
                    if (canDamage)
                    {
                        CallSender();
                    }
                }
            }
        }
        base.OnTriggerEnter2D(other);
    }
Esempio n. 10
0
    public override void OnTriggerEnter2D(Collider2D other)
    {
        //RETURN CONDITIONS
        if (excludeObjects.Contains(other.gameObject))
        {
            return;
        }

        Base_Health otherHealth = other.GetComponent <Base_Health> ();

        if (otherHealth == null || (otherHealth.GetPlayerTag().Team != 0 && otherHealth.GetPlayerTag().Team == team))
        {
            return;
        }

        if (canStun)
        {
            otherHealth.AddStun();
        }

        DamageTarget(otherHealth);
        // ELSE CASE??
    }