Week 9—Enemies / Interaction / Puzzles


Week 9—Enemies / Interaction / Puzzles

enemies

types

There are 4 different enemies (bacteria)

public enum InvaderType
{    COVID,    INVADER1,    INVADER2,    INVADER3,
}

Prefabs

Screen Shot 2020-09-20 at 21.05.06

how to instance

  • there is an InvaderManager Component which controls how to instance a invader

random get a invader prefab by using Random.Range

int index  = UnityEngine.Random.Range(0, 4);
if (type == (int)InvaderType.COVID)
{    prefab = GameManager.instance.Conf.InvaderCOVIDPrefab;
} else if (type == (int)InvaderType.INVADER1)
{    prefab = GameManager.instance.Conf.Invader1Prefab;
} else if (type == (int)InvaderType.INVADER2)
{    prefab = GameManager.instance.Conf.Invader2Prefab;
} else if (type == (int)InvaderType.INVADER3)
{    prefab = GameManager.instance.Conf.Invader3Prefab;
}

Interaction

white blood cell destroy invaders

produce a bullet every 2 seconds in white blood cell

InvokeRepeating("Attack",3,2);

decrease invader when bullet trigger OnTriggerEnter2D

if(other.gameObject.CompareTag("Invader"))
{
other.gameObject.GetComponent<InvaderHealth>().DecreaseHealth(DecreaseNumber);
}

destroy an invader

if this is not a covid and health become 0, it destroys itself and creates a covid instance.

Health -= number;
if (Health <= 0)
{    if (Type != InvaderType.COVID)    {        GameObject invaderInstance = InvaderManager.instance.Instance((int)InvaderType.COVID);    }    Destroy(gameObject);
}

Screen Shot 2020-09-20 at 21.22.57

Files

Screen Recording 2020-09-07 at 00.07.28.mov 23 MB
Sep 06, 2020
EnterTheCell.zip Play in browser
Sep 06, 2020

Get Enter the Cell

Leave a comment

Log in with itch.io to leave a comment.