Day 41 — Improvements: updated spawning and enemy shields

private _beamEnemyCount = 1;
[SerializeField]
private GameObject _beamEnemy;
if (_beamEnemyCount < 1)
{
Instantiate(_beamEnemy, new Vector3(0, 6, 0), Quaternion.identity);
_beamEnemyCount += 1;
}
while (_playerAlive == true)
{
float randomValue = Random.value;
if (randomValue <= 0.1f)
{
int multishotChance = Random.Range(0, 7);
Instantiate(_powerups[multishotChance], new Vector3(Random.Range(-10.7f, 10.7f), 6.2f, 0), Quaternion.identity);
yield return new WaitForSeconds(3.0f);
}
else if (randomValue > 0.1f && randomValue < 0.5f)
{
float secondValue = Random.value;
if (secondValue < 0.4f)
{
int randomPowerUp = Random.Range(0, 6);
Instantiate(_powerups[randomPowerUp], new Vector3(Random.Range(-10.7f, 10.7f), 6.2f, 0), Quaternion.identity);
yield return new WaitForSeconds(Random.Range(3.0f, 7.0f));
}
else
{
Debug.Log("Chance for health spawn");
int randomPowerUp = Random.Range(0, 5);
Instantiate(_powerups[randomPowerUp], new Vector3(Random.Range(-10.7f, 10.7f), 6.2f, 0), Quaternion.identity);
yield return new WaitForSeconds(Random.Range(3.0f, 7.0f));
}
}
else if (randomValue > 0.5f)
{
Debug.Log("Ammo Spawn");
Instantiate(_powerups[3], new Vector3(Random.Range(-10.7f, 10.7f), 6.2f, 0), Quaternion.identity);
yield return new WaitForSeconds(Random.Range(3.0f, 7.0f));
}
}

Enemy Shields

private bool _shieldActive = true;
[SerializeField]
private GameObject _shield;
if (_shieldActive == true)
{
_shieldActive = false;
_shield.SetActive(false);
Destroy(other.gameObject);
}

--

--

--

Hey and welcome! My name is Connor and my goal here is to put out a daily post for a full year about my game development journey.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why organising a hackathon is awesome and every student should try it.

The Ultimate Guide to PyTrends: the Google Trends API (with Python code examples)

mStable Community Forum Launch

PVS-Studio searches for bugs in the DuckStation project

Two main errors your agile project may have right now and how to solve them

Highlights This Week: MyMDT Beta Test Ends Today; MailTime iOS Cloud Version To Be Launched Soon

Theming Obsidian — How to Install new Themes and Where to Find Them

Why you should choose flutter?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Connor Fullarton

Connor Fullarton

Hey and welcome! My name is Connor and my goal here is to put out a daily post for a full year about my game development journey.

More from Medium

Part of your CCNA / CCNP education is deciding what network topology to use when you’re putting…

Kikoverse Biweekly Newsletter (4.6–4.20)

‘Ride’ competition launched A challenge to design a transit hub for buses by UNI.xyz

Reflection in ES6