setting up enemy consumption and increasing score - maybe change?
This commit is contained in:
@@ -21,10 +21,12 @@ public class BulletManager : MonoBehaviour
|
||||
public List<PatternMap> PatternMap = new List<PatternMap>();
|
||||
public Pattern[] activePatterns;
|
||||
|
||||
private GameManager gameManager;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
gameManager = FindObjectOfType<GameManager>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -33,6 +35,11 @@ public class BulletManager : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
public void EnemyConsumed(float multiplier)
|
||||
{
|
||||
gameManager.EnemyConsumed(multiplier);
|
||||
}
|
||||
|
||||
public void SpawnPattern(PatternTypes pattern, Enemy enemy)
|
||||
{
|
||||
GameObject patternObject = Instantiate(PatternMap.Find(x => x.patternType == pattern).pattern, enemy.transform.position, Quaternion.identity);
|
||||
|
||||
@@ -31,9 +31,13 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
public void EnemyConsumed()
|
||||
public void EnemyConsumed(float multiplier = 0)
|
||||
{
|
||||
enemiesConsumed++;
|
||||
|
||||
float incMutliplier = (multiplier > 0) ? multiplier : scoreMultiplier;
|
||||
|
||||
score += Mathf.FloorToInt(50 * incMutliplier); // TODO: how do we want this to work exactly?
|
||||
}
|
||||
|
||||
public void PlayerDed()
|
||||
|
||||
@@ -20,7 +20,7 @@ public class Pattern : MonoBehaviour
|
||||
{
|
||||
OnPatternUpdate();
|
||||
duration -= Time.deltaTime;
|
||||
if (duration <= 0)
|
||||
if (duration <= 0 || enemy.IsDead)
|
||||
{
|
||||
//find all particle systems in children and stop them
|
||||
foreach (ParticleSystem ps in GetComponentsInChildren<ParticleSystem>())
|
||||
|
||||
@@ -8,6 +8,8 @@ public class UIManager : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI playerHealthLabel;
|
||||
public TextMeshProUGUI gameOverLabel;
|
||||
public TextMeshProUGUI scoreLabel;
|
||||
|
||||
public Button restartButton;
|
||||
private GameManager gameManager;
|
||||
|
||||
@@ -23,11 +25,12 @@ public class UIManager : MonoBehaviour
|
||||
//round player health
|
||||
playerHealthLabel.text = "Health: " + Mathf.Round(gameManager.player.health).ToString();
|
||||
|
||||
scoreLabel.text = "Score: " + Mathf.Round(gameManager.score).ToString();
|
||||
|
||||
if (gameManager.player.health <= 0)
|
||||
{
|
||||
gameOverLabel.gameObject.SetActive(true);
|
||||
restartButton.gameObject.SetActive(true);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user