onHitPlayer() public method

Special code to fire when the projectile hits the player.
public onHitPlayer ( ) : void
return void
    void OnTriggerEnter(Collider other)
    {
        //Get the NPC that hit the ward
        NPC npc = other.gameObject.GetComponent <NPC>();

        if (npc != null)//Has the collision hit an npc
        {
            if (spellprop.BaseDamage != 0)
            {
                npc.ApplyAttack(spellprop.BaseDamage);
            }
            spellprop.onImpact(npc.transform);
            spellprop.onHit(npc.gameObject.GetComponent <ObjectInteraction>());
            objInt().consumeObject();
        }
        else
        {
            if (other.gameObject.GetComponent <UWCharacter>())
            {
                if (spellprop.BaseDamage != 0)
                {
                    UWCharacter.Instance.ApplyDamage(spellprop.BaseDamage);
                }
                spellprop.onHitPlayer();
                objInt().consumeObject();
            }
            else
            {
                if (_RES == GAME_UW2)
                {
                    objInt().consumeObject();
                }
            }
        }
    }
Beispiel #2
0
    void OnTriggerEnter(Collider other)
    {
        //Get the NPC that hit the ward
        NPC npc = other.gameObject.GetComponent <NPC>();

        if (npc != null)              //Has the collision hit an npc
        {
            //spellprop.init(SpellEffect.UW1_Spell_Effect_RuneofWarding,UWCharacter.Instance.gameObject);
            if (spellprop.BaseDamage != 0)
            {
                npc.ApplyAttack(spellprop.BaseDamage);
            }
            spellprop.onImpact(npc.transform);
            spellprop.onHit(npc.gameObject.GetComponent <ObjectInteraction>());
            //this.GetComponent<ObjectInteraction>().objectloaderinfo.InUseFlag=0;
            //Destroy (this.gameObject);
            objInt().consumeObject();
        }
        else
        {
            if (other.gameObject.GetComponent <UWCharacter>())
            {
                if (spellprop.BaseDamage != 0)
                {
                    UWCharacter.Instance.ApplyDamage(spellprop.BaseDamage);
                }
                spellprop.onHitPlayer();
                objInt().consumeObject();
            }
            else
            {
                if (_RES == GAME_UW2)
                {
                    objInt().consumeObject();
                }
            }
        }
    }
    protected virtual void Detonate(Collision collision)
    {
        HasHit = true;
        //Code to execute when a projectile hits a spot (for launching AOE effects)
        spellprop.onImpact(this.transform);
        ObjectInteraction objInt = collision.gameObject.GetComponent <ObjectInteraction> ();

        if (objInt != null)        //Has the projectile hit anything
        {
            //Special code for magic spell direct hits.
            spellprop.onHit(objInt);
            //Applies damage
            objInt.Attack(spellprop.BaseDamage, caster);
            //Create a impact animation to illustrate the collision
            if (objInt.GetHitFrameStart() >= 0)
            {
                Impact.SpawnHitImpact(Impact.ImpactMagic(), objInt.GetImpactPoint(), objInt.GetHitFrameStart(), objInt.GetHitFrameEnd());
            }
        }
        else
        {
            //Test if this is a player.
            if (collision.gameObject.GetComponent <UWCharacter> () != null)
            {
                int ratio = UWCharacter.Instance.getSpellResistance(spellprop);
                collision.gameObject.GetComponent <UWCharacter> ().ApplyDamage(spellprop.BaseDamage / ratio);
                spellprop.onHitPlayer();
            }
            else
            {
                //Do a miss impact
                Impact.SpawnHitImpact(Impact.ImpactDamage(), this.transform.position, spellprop.impactFrameStart, spellprop.impactFrameEnd);
            }
        }
        DestroyProjectile();
    }
    /// <summary>
    /// The Projectile hits something.
    /// </summary>
    /// <param name="collision">Collision.</param>
    /// Does not impact the caster
    /// Calls onImpact
    /// Calls onHit
    /// Applys Attack
    /// Generates an impact effect
    void OnCollisionEnter(Collision collision)
    {    //
        if (caster == null)
        {
            caster = this.gameObject;
        }
        if (collision.gameObject.name == caster.name)
        {        //Prevents the caster from hitting themselves
            return;
        }
        if (HasHit == true)
        {        //Only impact once.
            return;
        }
        else
        {
            HasHit = true;

            //Code to execute when a projectile hits a spot (for launching AOE effects)
            spellprop.onImpact(this.transform);

            ObjectInteraction objInt = collision.gameObject.GetComponent <ObjectInteraction>();

            if (objInt != null)          //Has the projectile hit anything
            {
                //Special code for magic spell direct hits.
                spellprop.onHit(objInt);

                //Applies damage
                objInt.Attack(spellprop.BaseDamage, caster);

                //Create a impact animation to illustrate the collision
                if (objInt.GetHitFrameStart() >= 0)
                {
                    Impact.SpawnHitImpact(Impact.ImpactMagic(), objInt.GetImpactPoint(), objInt.GetHitFrameStart(), objInt.GetHitFrameEnd());
                }
            }
            else
            {
                //Test if this is a player.
                if (collision.gameObject.GetComponent <UWCharacter>() != null)
                {
                    collision.gameObject.GetComponent <UWCharacter>().ApplyDamage(spellprop.BaseDamage);
                    spellprop.onHitPlayer();
                }
                else
                {
                    //Do a miss impact
                    Impact.SpawnHitImpact(Impact.ImpactDamage(), this.transform.position, spellprop.impactFrameStart, spellprop.impactFrameEnd);
                }
            }

            ObjectInteraction objIntThis = this.GetComponent <ObjectInteraction>();
            if (objIntThis != null)
            {
                objIntThis.objectloaderinfo.InUseFlag = 0;              //Free up object slot
            }

            DestroyObject(this.gameObject);
        }
    }