Ejemplo n.º 1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Spell_Interactable")
     {
         SpellInteractable si = other.GetComponent <SpellInteractable>();
         if (si != null)
         {
             si.Trigger("windslash");
         }
         SpawnHit();
         Destroy(gameObject);
     }
     else if (other.tag == "Enemy")
     {
         EnemyAI  enemy  = other.GetComponent <EnemyAI>();
         CasterAI caster = other.GetComponent <CasterAI>();
         if (enemy != null)
         {
             enemy.TakeDamage(damageType, damage);
         }
         if (caster != null)
         {
             caster.TakeDamage(damageType, damage);
         }
     }
 }
Ejemplo n.º 2
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Enemy")
     {
         EnemyAI  enemy  = collision.gameObject.GetComponent <EnemyAI>();
         CasterAI caster = collision.gameObject.GetComponent <CasterAI>();
         if (enemy != null)
         {
             enemy.TakeDamage("ice", damage);
         }
         if (caster != null)
         {
             caster.TakeDamage("ice", damage);
         }
         Break();
     }
     else if (collision.gameObject.tag == "Spell" || collision.gameObject.tag == "Missile")
     {
         SpellData sd = collision.gameObject.GetComponent <SpellData>();
         Debug.Log("Hit by spell with type: " + sd.damageType);
         if (sd != null && sd.damageType == "fire")
         {
             Break();
         }
     }
     else if (collision.gameObject.tag == "Player")
     {
         Player p = collision.gameObject.GetComponent <Player>();
         if (p != null)
         {
             p.WeaponHit(damage);
         }
         Break();
     }
 }
Ejemplo n.º 3
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Spell_Interactable")
        {
            SpellInteractable si = collision.gameObject.GetComponent <SpellInteractable>();
            Breakable         b  = collision.gameObject.GetComponent <Breakable>();
            if (si != null)
            {
                si.Trigger("magnosphere");
            }
            if (b != null)
            {
                b.Break();
            }
            Break();
        }
        else if (collision.gameObject.tag == "Shield")
        {
            Shield s = collision.gameObject.GetComponent <Shield>();
            if (s != null)
            {
                s.Break();
            }
            Break();
        }
        else if (collision.gameObject.tag == "Enemy")
        {
            EnemyAI  enemy  = collision.gameObject.GetComponent <EnemyAI>();
            CasterAI caster = collision.gameObject.GetComponent <CasterAI>();
            if (enemy != null)
            {
                enemy.TakeDamage(damageType, damage);
            }
            if (caster != null)
            {
                caster.TakeDamage(damageType, damage);
            }
            Break();
        }
        else if (collision.gameObject.tag == "Player" && canHitPlayer)
        {
            Player player = collision.gameObject.GetComponent <Player>();
            if (player != null)
            {
                player.WeaponHit(damage);
            }
            Break();
        }

        Rigidbody r = collision.gameObject.GetComponent <Rigidbody>();

        if (r != null)
        {
            r.AddExplosionForce(1500f, transform.position, 1f);
        }
    }
Ejemplo n.º 4
0
    void OnCollisionEnter(Collision collision)
    {
        if (!onHitTimeout)
        {
            bool hit = false;
            //print("hitsomething");
            if (collision.gameObject.tag == "Spell_Interactable")
            {
                SpellInteractable si = collision.gameObject.GetComponent <SpellInteractable>();
                if (HitSound)
                {
                    HitSound.Play();
                }
                if (si != null)
                {
                    si.Trigger("sword");
                }
                hit = true;
            }
            else if (collision.gameObject.tag == "Enemy" || (collision.gameObject.tag == "Ghost" && (damageType == "planar" || damageType == "arcane")))
            {
                EnemyAI  enemy  = collision.gameObject.GetComponent <EnemyAI>();
                CasterAI caster = collision.gameObject.GetComponent <CasterAI>();
                if (enemy != null)
                {
                    enemy.TakeDamage(damageType, damage);
                }
                if (caster != null)
                {
                    caster.TakeDamage(damageType, damage);
                }
                if (HitSound)
                {
                    HitSound.Play();
                }
                hit = true;
            }
            else if (collision.gameObject.name.Contains("Hammer") && damageType != "mortal")
            {
                grabInteractable.colliders.Clear();
                Destroy(gameObject);
                Instantiate(MortalSword, transform.position, transform.rotation);
            }

            if (hit)
            {
                onHitTimeout   = true;
                currentTimeout = hitTimeout;
                DeactivateGlow();
                hit = false;
            }
        }
    }
Ejemplo n.º 5
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag != "Player" || canHitPlayer)
        {
            //print("MagicMissile hit: " + other.ToString());
            Destroy(GetComponent <SphereCollider>());
            Destroy(gameObject, 1.1f);
            hitSomething = true;

            explosionParticles.Play();
            hitSound.Play();
            mesh.SetActive(false);

            if (other.tag == "Spell_Interactable")
            {
                SpellInteractable si = other.GetComponent <SpellInteractable>();
                if (si != null)
                {
                    si.Trigger("magicmissile");
                }
            }
            else if (other.tag == "Shield")
            {
                Shield s = other.GetComponent <Shield>();
                if (s != null)
                {
                    s.Break();
                }
            }
            else if (other.tag == "Player")
            {
                if (player != null)
                {
                    player.GetComponent <Player>().WeaponHit(damage);
                }
            }
            else if (other.tag == "Enemy" || other.tag == "Ghost")
            {
                EnemyAI  enemy = other.GetComponent <EnemyAI>();
                CasterAI ci    = other.GetComponent <CasterAI>();
                if (enemy != null)
                {
                    enemy.TakeDamage(damageType, damage);
                }
                if (ci != null)
                {
                    ci.TakeDamage(damageType, damage);
                }
            }
        }
    }
Ejemplo n.º 6
0
    //Server call only, no call on client.
    //ServerCallback is similar to Server but doesn't generate a warning when called on client.
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Shield")
        {
            other.GetComponent <Shield>().Break();
            Destroy(GetComponent <SphereCollider>(), 0);
        }
        else if (other.tag == "Spell_Interactable")
        {
            SpellInteractable si = other.GetComponent <SpellInteractable>();
            Burnable          b  = other.GetComponent <Burnable>();
            if (si != null)
            {
                si.Trigger("fireball");
            }
            if (b != null)
            {
                b.Burn();
            }
            Destroy(GetComponent <SphereCollider>(), 0);
        }
        else if (other.tag == "Enemy")
        {
            EnemyAI  enemy = other.GetComponent <EnemyAI>();
            CasterAI ci    = other.GetComponent <CasterAI>();
            if (enemy != null)
            {
                enemy.TakeDamage("fire", damage);
            }
            if (ci != null)
            {
                ci.TakeDamage("fire", damage);
            }
        }
        else if (other.tag == "Player")
        {
            Player player = other.GetComponent <Player>();
            if (player != null)
            {
                player.WeaponHit(damage);
            }
        }

        Rigidbody r = other.GetComponent <Rigidbody>();

        if (r != null)
        {
            r.AddExplosionForce(explosionForce, transform.position, 2f);
        }
    }
Ejemplo n.º 7
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "Enemy" || other.tag == "Ghost")
     {
         if (hitSound != null && !hitSound.isPlaying)
         {
             hitSound.Play();
         }
         EnemyAI  enemy  = other.GetComponent <EnemyAI>();
         CasterAI caster = other.GetComponent <CasterAI>();
         if (enemy != null)
         {
             enemy.TakeDamage(damageType, damagePerTick);
         }
         if (caster != null)
         {
             caster.TakeDamage(damageType, damagePerTick);
         }
     }
     else if (other.tag == "Player" && hitPlayer)
     {
         if (hitSound != null && !hitSound.isPlaying)
         {
             hitSound.Play();
         }
         Player player = other.gameObject.GetComponent <Player>();
         if (player != null)
         {
             player.WeaponHit(damagePerTick);
         }
     }
     else if (other.tag == "Spell_Interactable")
     {
         SpellInteractable si = other.GetComponent <SpellInteractable>();
         if (si != null)
         {
             si.Trigger("holyfire");
         }
     }
 }
Ejemplo n.º 8
0
 //Server call only, no call on client.
 //ServerCallback is similar to Server but doesn't generate a warning when called on client.
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Spell_Interactable")
     {
         SpellInteractable si = other.GetComponent <SpellInteractable>();
         if (si != null)
         {
             si.Trigger("lightning");
         }
     }
     else if (other.tag == "Enemy")
     {
         EnemyAI  enemy  = other.GetComponent <EnemyAI>();
         CasterAI caster = other.GetComponent <CasterAI>();
         if (enemy != null)
         {
             enemy.TakeDamage(damageType, damage);
         }
         if (caster != null)
         {
             caster.TakeDamage(damageType, damage);
         }
     }
     else if (other.tag == "Player")
     {
         Player player = other.GetComponent <Player>();
         if (player != null)
         {
             player.GetComponent <Player>().WeaponHit(damage);
         }
     }
     else if (other.tag == "Shield")
     {
         Shield s = other.GetComponent <Shield>();
         if (s != null)
         {
             s.Break();
         }
     }
 }
Ejemplo n.º 9
0
 void OnTriggerEnter(Collider other)
 {
     //Debug.Log("Ice Spray hit "+other.gameObject);
     if (other.tag == "Spell_Interactable")
     {
         SpellInteractable si = other.GetComponent <SpellInteractable>();
         Freezable         b  = other.GetComponent <Freezable>();
         if (si != null)
         {
             si.Trigger("icespray");
         }
         if (b != null)
         {
             b.Freeze();
         }
         Debug.Log("Freeze: " + other.gameObject);
     }
     else if (other.tag == "Enemy")
     {
         EnemyAI  enemy  = other.GetComponent <EnemyAI>();
         CasterAI caster = other.GetComponent <CasterAI>();
         if (enemy != null)
         {
             enemy.Slow(15f);
             enemy.TakeDamage("ice", damagePerTick);
         }
         if (caster != null)
         {
             caster.TakeDamage("ice", damagePerTick);
         }
     }
     else if (other.tag == "Missile")
     {
         Destroy(other.gameObject);
     }
 }
Ejemplo n.º 10
0
    void OnTriggerEnter(Collider other)
    {
        if ((other.tag != "Player" || canHitPlayer) && other.gameObject != owner && (other.tag != "Ghost" || canHitGhosts))
        {
            Destroy(GetComponent <Collider>());
            Destroy(gameObject, 1f);
            if (loopSound != null && loopSound.isPlaying)
            {
                loopSound.Stop();
            }
            hitSomething = true;

            foreach (GameObject go in destroyOnCollision)
            {
                Destroy(go);
            }

            if (other.tag == "Spell_Interactable")
            {
                SpellInteractable si = other.GetComponent <SpellInteractable>();
                if (si != null)
                {
                    si.Trigger(spellInteractorTriggerKey);
                }
            }
            else if (other.tag == "Shield")
            {
                Shield s = other.GetComponent <Shield>();
                if (s != null)
                {
                    s.Break();
                }
            }
            else if (other.tag == "Player")
            {
                if (player != null)
                {
                    player.GetComponent <Player>().WeaponHit(damage);
                }
            }
            else if (other.tag == "Enemy" || other.tag == "Ghost")
            {
                EnemyAI  enemy  = other.GetComponent <EnemyAI>();
                CasterAI caster = other.GetComponent <CasterAI>();
                if (enemy != null)
                {
                    enemy.TakeDamage(damageType, damage);
                }
                if (caster != null)
                {
                    caster.TakeDamage(damageType, damage);
                }
            }

            if (other.tag != "NullZone")
            {
                if (hitFX != null)
                {
                    Instantiate(hitFX, transform.position, transform.rotation * Quaternion.Euler(-90, 0, 0));
                }
                if (hitSound != null)
                {
                    hitSound.Play();
                }
            }
        }
    }
Ejemplo n.º 11
0
    void OnCollisionEnter(Collision collision)
    {
        if (!onHitTimeout)
        {
            bool hit = false;
            if (collision.gameObject.tag == "Spell_Interactable")
            {
                SpellInteractable si = collision.gameObject.GetComponent <SpellInteractable>();
                Breakable         b  = collision.gameObject.GetComponent <Breakable>();
                EarthWall         ew = collision.gameObject.GetComponent <EarthWall>();
                if (HitSound)
                {
                    HitSound.Play();
                }
                if (si != null)
                {
                    si.Trigger("hammer");
                }
                if (ew != null)
                {
                    ew.Shatter(collision.GetContact(0));
                }
                if (b != null)
                {
                    b.Break();
                }
                hit = true;
            }
            else if (collision.gameObject.tag == "Shield")
            {
                Shield s = collision.gameObject.GetComponent <Shield>();
                if (s != null)
                {
                    s.Break();
                }
                hit = true;
            }
            else if (collision.gameObject.tag == "Enemy")
            {
                EnemyAI  enemy  = collision.gameObject.GetComponent <EnemyAI>();
                CasterAI caster = collision.gameObject.GetComponent <CasterAI>();
                if (enemy != null)
                {
                    enemy.TakeDamage(damageType, damage);
                }
                if (caster != null)
                {
                    caster.TakeDamage(damageType, damage);
                }
                if (HitSound)
                {
                    HitSound.Play();
                }
                hit = true;
            }
            else if (collision.gameObject.tag == "Player" && canHitPlayer)
            {
                Player player = collision.gameObject.GetComponent <Player>();
                if (player != null)
                {
                    player.WeaponHit(damage);
                }
                if (HitSound)
                {
                    HitSound.Play();
                }
                hit = true;
            }

            Rigidbody r = collision.gameObject.GetComponent <Rigidbody>();
            if (r != null)
            {
                r.AddExplosionForce(1500f, transform.position, 1f);
            }

            if (hit)
            {
                onHitTimeout   = true;
                currentTimeout = hitTimeout;
                DeactivateGlow();
            }
        }
    }