예제 #1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Projectile")
     {
         MeleeWeapon.DeflectProjectile(other.gameObject, parentWeapon.caster);
     }
 }
예제 #2
0
    // Collision
    public void OnCollisionEnter(Collision collision)
    {
        // We prevent the weapon from hitting the same target twice
        if (!hitList.ContainsKey(collision.gameObject))
        {
            hitList.Add(collision.gameObject, true);

            var collidingObject = collision.gameObject;

            if (collidingObject.tag == "Projectile")
            {
                MeleeWeapon.DeflectProjectile(collidingObject, caster);
            }
            else if (collidingObject.GetComponent <MeleeWeaponCollider>() != null)
            {
                if (GameManager.isClient)
                {
                    audio.PlayOneShot(swordHitSwordSound);
                    Instantiate(sparksPrefab, collision.contacts[0].point, Cache.quaternionIdentity);
                }

                /*if(uLink.Network.isServer) {
                 *      Vector3 diff = otherWeapon.transform.position - transform.position;
                 *      caster.networkView.RPC("SwordClash", uLink.RPCMode.All, diff);
                 * } else {
                 *      audio.PlayOneShot(swordHitSwordSound);
                 * }
                 *
                 * var casterAsPlayer = (Player)caster;
                 * casterAsPlayer.EndSkill();
                 * casterAsPlayer.StopMeleeAttack();*/
            }
            else
            {
                if (GameManager.isClient)
                {
                    if (collision.gameObject.GetComponent <Entity>() != null)
                    {
                        audio.PlayOneShot(swordHitHumanSound);
                    }
                    else
                    {
                        audio.PlayOneShot(swordHitObjectSound);
                    }
                }

                // TODO: We changed caster.currentSkill to this due to code changes, check if this is still valid
                caster.SpawnExplosion(impactExplosion, collision, this);                 // caster.currentSkill
            }
        }
    }