Added More vicious Enemy

We added another enemy giving more damage to the player and its an elephant.

Warning: Placeholders are used.

We also added Layer sorting for animal’s sprite Renderers. So when Animal changes lanes their rendering sorting are re adjusted.

 

p3

Here is a code I was working on:

using UnityEngine;

using System.Collections;

public class SortAnimalLane : MonoBehaviour {

    public string TopLaneLayer = “TopLane”;

    public string MidLaneLayer = “MidLane”;

    public string BottomLaneLayer = “BottomLane”;

    public Animal.AnimalName AnimalName;

    private string _activeLayer;

    private Animal _animal;

    private SpriteRenderer _renderer;

    public void Start ()

    {

        _renderer = GetComponent<SpriteRenderer>();

        //

        if (AnimalName == Animal.AnimalName.Sheep)

        {

            _animal = (Animal)GetComponent<Sheep>();

        }

        else if (AnimalName == Animal.AnimalName.Wildebeest)

        {

            _animal = (Animal)GetComponent<Wildebeast>();

        }

        else if (AnimalName == Animal.AnimalName.Elephant)

        {

            _animal = (Animal)GetComponent<Elephant>();

        }

        SetSortingLayer();

        _renderer.sortingLayerName = _activeLayer;

    }

    public void SetSortingLayer()

    {

        if (_animal.CurrentLane == LevelManager.ThreeLane.TopLane)

            _activeLayer = TopLaneLayer;

        else if (_animal.CurrentLane == LevelManager.ThreeLane.MiddleLane)

            _activeLayer = MidLaneLayer;

        else if (_animal.CurrentLane == LevelManager.ThreeLane.BottomLane)

            _activeLayer = BottomLaneLayer;

    }

    public void Update()

    {

        SetSortingLayer();

        _renderer.sortingLayerName = _activeLayer;

    }

}

You can play the game from here

Thanks for reading. Don’t forget to subscribe for newsletter.

Here is a youtube video

Leave a Reply