void HitPlayer()
    {
        RaycastHit rayHit;


        float elapseAlive = Time.time - aliveTime;

        if (elapseAlive < 1.2f)
        {
            damageModifier = 1.4f;
        }
        else if (elapseAlive < 5)
        {
            damageModifier = 1;
        }
        else
        {
            damageModifier = 0.2f;
        }


        if (PlayerProjectile.HitRayDirection(transform.position, velocity.normalized, 0.3f, 1 << 9, out rayHit))
        {
            FpsControllerCore.instance.HitParticle(rayHit.point + rayHit.normal * 0.05f, rayHit.normal);
            alive = false;
            FpsControllerCore.instance.TakeDamage(Mathf.FloorToInt(baseDamage * damageModifier));
        }
    }
Exemplo n.º 2
0
    public static void HitPlayer(Vector3 position, Vector3 direction, float damage = 2, float length = 1)
    {
        RaycastHit rayHit;

        if (PlayerProjectile.HitRayDirection(position, direction, length, 1 << 9, out rayHit))
        {
            FpsControllerCore.instance.HitParticle(rayHit.point + rayHit.normal * 0.05f, rayHit.normal);
            Debug.Log("hit player");
            FpsControllerCore.instance.TakeDamage((int)damage);
        }
    }
    void HitTerrain()
    {
        RaycastHit rayHit;

        if (PlayerProjectile.HitRayDirection(transform.position, velocity.normalized, 2, 1 << 0, out rayHit))
        {
            FpsControllerCore.instance.HitParticle(rayHit.point + rayHit.normal * 0.05f, rayHit.normal);
            GameObject.Destroy(gameObject);
        }
        else if (transform.position.y < -16)
        {
            GameObject.Destroy(gameObject);
        }
    }
    void HitEnemy()
    {
        if (alive)
        {
            RaycastHit rayHit;

            if (PlayerProjectile.HitRayDirection(transform.position, velocity.normalized, speedModifier, 1 << 10, out rayHit))
            {
                EnemyWeakPoint ewp = rayHit.collider.GetComponent <EnemyWeakPoint>();
                if (ewp != null)
                {
                    fpsControllerCore.HitParticle(rayHit.point + rayHit.normal * 0.05f, rayHit.normal, true);
                    alive = false;
                    //  fpsControllerCore.EmitExplosion(rayHit.collider.transform.position);
                    ewp.CallPoint();
                }
            }
        }
    }