Exemplo n.º 1
0
    // called when we have been hit by a melee attack
    override public bool OnMeleeAttackHit(APCharacterController character, APHitZone hitZone)
    {
        // Do nothing if player is currently blinking
        APSamplePlayer samplePlayer = character.GetComponent <APSamplePlayer>();

        if (samplePlayer && samplePlayer.IsGodModeEnabled())
        {
            return(false);
        }

        return(AddHitDamage(hitZone.m_damage));
    }
Exemplo n.º 2
0
    // called when character is entering this collectable
    public void OnTriggerEnter2D(Collider2D otherCollider)
    {
        APSamplePlayer character = otherCollider.GetComponent <APSamplePlayer>();

        if (character && !character.IsGodModeEnabled())
        {
            // prevent checking hits too often
            if (Time.time < m_lastHitTime + m_minTimeBetweenTwoReceivedHits)
            {
                return;
            }

            // save current hit time
            m_lastHitTime = Time.time;

            // add hit to character
            character.OnHit(m_touchDamage, transform.position);
        }
    }
Exemplo n.º 3
0
    // called when character motor ray is touching us
    override public bool OnCharacterTouch(APCharacterController character, APCharacterMotor.RayType rayType, RaycastHit2D hit, float penetration,
                                          APMaterial hitMaterial)
    {
        // Do nothing if dead
        if (IsDead())
        {
            return(false);
        }

        // Do nothing in godmode
        APSamplePlayer samplePlayer = character.GetComponent <APSamplePlayer>();

        if (samplePlayer && samplePlayer.IsGodModeEnabled())
        {
            return(false);
        }

        // check if jumping on us
        bool bHit = false;

        if ((rayType == APCharacterMotor.RayType.Ground) && (penetration <= m_jumpHitPenetrationTolerance))
        {
            // make character jump
            float fRatio = m_jumpRatioInputReleased;
            if (character.m_jump.m_button.IsSpecified() && character.m_jump.m_button.GetButton())
            {
                fRatio = m_jumpRatioInputPushed;
            }

            if (fRatio > 0f)
            {
                character.Jump(character.m_jump.m_minHeight * fRatio, character.m_jump.m_maxHeight * fRatio);
            }

            // add hit to NPC
            if (samplePlayer)
            {
                AddHitDamage(samplePlayer.m_jumpDamage);
            }

            bHit = true;
        }
        else if (penetration <= m_hitPenetrationTolerance)
        {
            // add hit to character
            if (samplePlayer)
            {
                samplePlayer.OnHit(m_touchDamage, transform.position);
            }

            bHit = true;
        }

        // prevent checking hits too often
        if (bHit)
        {
            if (Time.time < m_lastHitTime + m_minTimeBetweenTwoReceivedHits)
            {
                return(false);
            }

            // save current hit time
            m_lastHitTime = Time.time;
        }

        // always ignore contact
        return(false);
    }