コード例 #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);
         }
     }
 }
コード例 #2
0
    void OnTriggerEnter(Collider other)
    {
        print("Midas touch: " + other.gameObject);
        if (other.tag == "Arena")
        {
            return;
        }
        Renderer rend = other.gameObject.GetComponent <Renderer>();

        // Change all materials to gold, not just the first material
        var mats = new Material[rend.materials.Length];

        for (var j = 0; j < rend.materials.Length; j++)
        {
            mats[j] = goldMaterial;
        }
        rend.materials = mats;

        //if (rend != null) rend.material = goldMaterial;

        if (other.tag == "Spell_Interactable")
        {
            SpellInteractable si = other.gameObject.GetComponent <SpellInteractable>();
            if (hitSound)
            {
                hitSound.Play();
            }
            if (si != null)
            {
                si.Trigger("midastouch");
            }
        }
    }
コード例 #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);
        }
    }
コード例 #4
0
ファイル: Sword.cs プロジェクト: ElliotHume/LabyrinthianVR
    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;
            }
        }
    }
コード例 #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);
                }
            }
        }
    }
コード例 #6
0
ファイル: Sword.cs プロジェクト: ElliotHume/LabyrinthianVR
    void OnTriggerEnter(Collider other)
    {
        if (!onHitTimeout)
        {
            //print("hitsomething");
            if (other.tag == "Spell_Interactable")
            {
                SpellInteractable si = other.gameObject.GetComponent <SpellInteractable>();
                if (HitSound)
                {
                    HitSound.Play();
                }
                if (si != null)
                {
                    si.Trigger("sword");
                }

                onHitTimeout   = true;
                currentTimeout = hitTimeout;
                DeactivateGlow();
            }
            else if (other.gameObject.layer == 12 || other.gameObject.layer == 11)
            {
                GameObject prefab = null;

                if ((other.gameObject.name.Contains("FireballExplosion") || other.gameObject.name.Contains("Fireball")) && damageType != "fire")
                {
                    prefab = FireSword;
                }
                else if (other.gameObject.name.Contains("IceSpray") && damageType != "ice")
                {
                    prefab = IceSword;
                }
                else if (other.gameObject.name.Contains("DrainSphere") && damageType != "planar")
                {
                    prefab = PlanarSword;
                }
                else if (other.gameObject.name.Contains("MagicMissile") && damageType != "arcane")
                {
                    prefab = ArcaneSword;
                }

                if (prefab != null)
                {
                    grabInteractable.colliders.Clear();
                    Instantiate(prefab, transform.position, transform.rotation);
                    Destroy(gameObject);
                }
            }
        }
    }
コード例 #7
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);
        }
    }
コード例 #8
0
ファイル: Marker.cs プロジェクト: ElliotHume/LabyrinthianVR
    void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.tag != "Player")
        {
            active = false;
            GetComponent <Rigidbody>().detectCollisions = false;
            GetComponent <Rigidbody>().velocity         = Vector3.zero;

            SpellInteractable s = other.gameObject.GetComponent <SpellInteractable>();
            if (s != null)
            {
                s.Trigger("marker");
            }
        }
    }
コード例 #9
0
ファイル: Missile.cs プロジェクト: ElliotHume/LabyrinthianVR
    public virtual void OnTriggerEnter(Collider other)
    {
        if (active && (other.tag != "Player" || canHitPlayer))
        {
            Destroy(GetComponent <Collider>());
            Destroy(gameObject, decayTime);
            active = false;

            if (explosionParticles != null)
            {
                explosionParticles.Play();
            }
            if (hitSound != null)
            {
                hitSound.Play();
            }
            if (mesh != null)
            {
                mesh.SetActive(false);
            }

            if (other.tag == "Spell_Interactable")
            {
                SpellInteractable si = other.GetComponent <SpellInteractable>();
                if (si != null)
                {
                    si.Trigger(gameObject.name);
                }
            }
            else if (other.tag == "Player")
            {
                if (player != null)
                {
                    player.GetComponent <Player>().WeaponHit(damage);
                }
            }
            else if (other.tag == "Enemy")
            {
                EnemyAI enemy = other.GetComponent <EnemyAI>();
                if (enemy != null)
                {
                    enemy.TakeDamage("mortal", damage);
                }
            }
        }
    }
コード例 #10
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");
         }
     }
 }
コード例 #11
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();
         }
     }
 }
コード例 #12
0
ファイル: IceSpray.cs プロジェクト: ElliotHume/LabyrinthianVR
 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);
     }
 }
コード例 #13
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();
                }
            }
        }
    }
コード例 #14
0
ファイル: Hammer.cs プロジェクト: ElliotHume/LabyrinthianVR
    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();
            }
        }
    }