Lions And Coyotes do not welcome you

hey guys,

Today we added two more villains, they will chase you and give you big damage.

p13

Shoot them with shotgun and Rifle.

Lion will get you in single attack.

Here is how Lions and Coyote find and chase Cowboy

 

public void MoveLion()

    {

        _direction.x = 1;

        _direction.y = 1;

        // move towards player, check on right, above

        Debug.DrawRay (transform.position, _direction, Color.red);

        var rayCast = Physics2D.Raycast(transform.position, _direction, Random.Range(_startHorRayLength, _finalHorRayLength), 1 << LayerMask.NameToLayer (“Player”));

        if (rayCast)

        {

            SetSpeed(MaxSpeed + LevelManager.DifficultyLevel);

            if(!IsFacingRight)

                FlipLion();

            if (_canChangeLanes)

            {

                ChangeLanes();

            }

            _playerspotted = true;

            return;

        }

        // move towards player, check on left, above

        _direction.x = –1;

        _direction.y = 1;

        Debug.DrawRay (transform.position, _direction, Color.red);

        rayCast = Physics2D.Raycast(transform.position, _direction, Random.Range(_startHorRayLength, _finalHorRayLength), 1 << LayerMask.NameToLayer (“Player”));

        if (rayCast)

        {

            SetSpeed(MaxSpeed + LevelManager.DifficultyLevel);

            if(IsFacingRight)

                FlipLion();

            if (_canChangeLanes)

            {

                ChangeLanes();

            }

            _playerspotted = true;

            return;

        }

        _direction.x = 1;

        _direction.y = –1;

        // move towards player, check on right, below

        Debug.DrawRay (transform.position, _direction, Color.red);

        rayCast = Physics2D.Raycast(transform.position, _direction, Random.Range(_startHorRayLength, _finalHorRayLength), 1 << LayerMask.NameToLayer (“Player”));

        if (rayCast)

        {

            SetSpeed(MaxSpeed + LevelManager.DifficultyLevel);

            if(!IsFacingRight)

                FlipLion();

            if (_canChangeLanes)

            {

                ChangeLanes();

            }

            _playerspotted = true;

            return;

        }

        // move towards player, check on left, below

        _direction.x = –1;

        _direction.y = –1;

        Debug.DrawRay (transform.position, _direction, Color.red);

        rayCast = Physics2D.Raycast(transform.position, _direction, Random.Range(_startHorRayLength, _finalHorRayLength), 1 << LayerMask.NameToLayer (“Player”));

        if (rayCast)

        {

            SetSpeed(MaxSpeed + LevelManager.DifficultyLevel);

            if(IsFacingRight)

                FlipLion();

            if (_canChangeLanes)

            {

                ChangeLanes();

            }

            _playerspotted = true;

            return;

        }

        _direction.x = 1;

        _direction.y = 0;

        // move towards player, check on right

        Debug.DrawRay (transform.position, _direction, Color.red);

        rayCast = Physics2D.Raycast(transform.position, _direction, Random.Range(_startHorRayLength, _finalHorRayLength), 1 << LayerMask.NameToLayer (“Player”));

        if (rayCast)

        {

            SetSpeed(MaxSpeed + LevelManager.DifficultyLevel);

            if(!IsFacingRight)

                FlipLion();

            if (_canChangeLanes)

            {

                ChangeLanes();

            }

            _playerspotted = true;

            return;

        }

        // move towards player, check on left

        _direction.x = –1;

        _direction.y = 0;

        Debug.DrawRay (transform.position, _direction, Color.red);

        rayCast = Physics2D.Raycast(transform.position, _direction, Random.Range(_startHorRayLength, _finalHorRayLength), 1 << LayerMask.NameToLayer (“Player”));

        if (rayCast)

        {

            SetSpeed(MaxSpeed + LevelManager.DifficultyLevel);

            if(IsFacingRight)

                FlipLion();

            if (_canChangeLanes)

            {

                ChangeLanes();

            }

            _playerspotted = true;

            return;

        }

        // check if player is below

        _direction.x = 0;

        _direction.y = –1;

        Debug.DrawRay (transform.position, _direction, Color.red);

        rayCast = Physics2D.Raycast(transform.position, _direction, Random.Range(_startVertRayLength, _finalVertRayLength), 1 << LayerMask.NameToLayer (“Player”));

        if (rayCast)

        {

            SetSpeed(MaxSpeed + LevelManager.DifficultyLevel);

            ChangeLanes();

            _playerspotted = true;

            return;

        }

        // check if player is above

        _direction.x = 0;

        _direction.y = 1;

        Debug.DrawRay (transform.position, _direction, Color.red);

        rayCast = Physics2D.Raycast(transform.position, _direction, Random.Range(_startVertRayLength, _finalVertRayLength), 1 << LayerMask.NameToLayer (“Player”));

        if (rayCast)

        {

            SetSpeed(MaxSpeed + LevelManager.DifficultyLevel);

            ChangeLanes();

            _playerspotted = true;

            return;

        }

    }

Thanks for reading.

if you want to check out some of our projects please subscribe to our YouTube channel:

You can check up our work in progress games here:

If you are looking for solutions to game development issues see our blogs here:

If you like our projects please sign up for our newsletter at the bottom of this Page.

Leave a Reply