Example #1
0
    public void OnShot(Entity e)
    {
        if (IsDying()) return;

        int damage = (e.WieldsWeapon) ? e.WeaponDamage : e.MeleeDamage;
        Vector2 direction = e.Orientation;

        bool died = m_lifeData.UpdateHP(-damage);
        Debug.LogFormat("Entity {0} hit! Current Hp: {1}", name, m_lifeData.HP);

        transform.Translate(direction * e.WeaponRecoil * 1.6f);
        if (died)
        {
            e.HitLanded();
            m_audioSource.PlayOneShot(m_deathSound);
            StartCoroutine(DieInSeconds(1.0f));
        }
        else
        {
            m_audioSource.PlayOneShot(m_hitSound);
            if (HitReaction(e))
            {
                m_hitTime = Time.time;

            }
        }
    }
Example #2
0
    protected override bool HitReaction(Entity attacker)
    {
        m_state = NPCState.Hit;

        attacker.HitLanded();
        Color c = m_renderer.color;
        c.a = 0.5f;
        m_renderer.color = c;
        return true;
    }
Example #3
0
    public void OnBumped(Entity e)
    {
        if (IsEthereal()) return;
        if (!e.CanBumpEntity(this))
        {
            return;
        }

        bool dead = m_lifeData.UpdateHP(-1);
        Debug.LogFormat("Entity {0} hit! Current Hp: {1}", name, m_lifeData.HP);
        if (dead)
        {
            e.HitLanded();
            StartCoroutine(DieInSeconds(1.0f));
        }
        else
        {
            HitReaction(e);
            m_hitTime = Time.time;
        }
    }
Example #4
0
    protected override bool HitReaction(Entity attacker)
    {
        if (m_state == PlayerState.Hit)
        {
            Debug.LogFormat("Already hit!!");
            return false;
        }
        else
        {
            m_state = PlayerState.Hit;
            attacker.HitLanded();
            m_oldState = m_state;

            Color c = m_renderer.color;
            c.a = 0.5f;
            m_renderer.color = c;
            return true;
        }
    }