itch.io is community of indie game creators and players

Devlogs

Week 9—Enemies / Interaction / Puzzles

Enter the Cell
A browser game made in HTML5

Week 9—Enemies / Interaction / Puzzles

enemies

types

There are 4 different enemies (bacteria)

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

Prefabs

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);
}

Files

  • Screen Recording 2020-09-07 at 00.07.28.mov 23 MB
    Sep 06, 2020
  • EnterTheCell.zip 4.9 MB
    Sep 06, 2020
Download Enter the Cell
Leave a comment