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

How to Debug Slow Lambda Response Times

What the hell is Kubernetes and how it works?

Test Driven Development (TDD) Restful API Using Mock Server Postman

How to Read Data from Hive & Write to MS SQL Table Using Spark-Shell

Preparing Ahead for Go-Live

Planning

What I learned in my first year as a software engineer

10 Useful Python Tricks - Check Wether you Know Them All!

Managing a Multi-Project and still having time to chill

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

Medium Post#1 HIEA 112

Birth of Meta Worlds

People View NFTs All Wrong

View of the semester