setting up enemy consumption and increasing score - maybe change?
This commit is contained in:
6728
Assets/Scenes/Main - amaan.unity
Normal file
6728
Assets/Scenes/Main - amaan.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scenes/Main - amaan.unity.meta
Normal file
7
Assets/Scenes/Main - amaan.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c3c99fe455db51e41bed31b035a387f5
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -21,10 +21,12 @@ public class BulletManager : MonoBehaviour
|
|||||||
public List<PatternMap> PatternMap = new List<PatternMap>();
|
public List<PatternMap> PatternMap = new List<PatternMap>();
|
||||||
public Pattern[] activePatterns;
|
public Pattern[] activePatterns;
|
||||||
|
|
||||||
|
private GameManager gameManager;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
gameManager = FindObjectOfType<GameManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// 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)
|
public void SpawnPattern(PatternTypes pattern, Enemy enemy)
|
||||||
{
|
{
|
||||||
GameObject patternObject = Instantiate(PatternMap.Find(x => x.patternType == pattern).pattern, enemy.transform.position, Quaternion.identity);
|
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()
|
public void PlayerDed()
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class Pattern : MonoBehaviour
|
|||||||
{
|
{
|
||||||
OnPatternUpdate();
|
OnPatternUpdate();
|
||||||
duration -= Time.deltaTime;
|
duration -= Time.deltaTime;
|
||||||
if (duration <= 0)
|
if (duration <= 0 || enemy.IsDead)
|
||||||
{
|
{
|
||||||
//find all particle systems in children and stop them
|
//find all particle systems in children and stop them
|
||||||
foreach (ParticleSystem ps in GetComponentsInChildren<ParticleSystem>())
|
foreach (ParticleSystem ps in GetComponentsInChildren<ParticleSystem>())
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ public class UIManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public TextMeshProUGUI playerHealthLabel;
|
public TextMeshProUGUI playerHealthLabel;
|
||||||
public TextMeshProUGUI gameOverLabel;
|
public TextMeshProUGUI gameOverLabel;
|
||||||
|
public TextMeshProUGUI scoreLabel;
|
||||||
|
|
||||||
public Button restartButton;
|
public Button restartButton;
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
|
|
||||||
@@ -23,11 +25,12 @@ public class UIManager : MonoBehaviour
|
|||||||
//round player health
|
//round player health
|
||||||
playerHealthLabel.text = "Health: " + Mathf.Round(gameManager.player.health).ToString();
|
playerHealthLabel.text = "Health: " + Mathf.Round(gameManager.player.health).ToString();
|
||||||
|
|
||||||
|
scoreLabel.text = "Score: " + Mathf.Round(gameManager.score).ToString();
|
||||||
|
|
||||||
if (gameManager.player.health <= 0)
|
if (gameManager.player.health <= 0)
|
||||||
{
|
{
|
||||||
gameOverLabel.gameObject.SetActive(true);
|
gameOverLabel.gameObject.SetActive(true);
|
||||||
restartButton.gameObject.SetActive(true);
|
restartButton.gameObject.SetActive(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ public class Enemy : MonoBehaviour
|
|||||||
public int baseScore;
|
public int baseScore;
|
||||||
public PatternTypes[] patterns;
|
public PatternTypes[] patterns;
|
||||||
public int CurrentPattern = 0;
|
public int CurrentPattern = 0;
|
||||||
|
public float scoreMultiplier = 0;
|
||||||
|
|
||||||
|
public bool IsDead { get; private set; }
|
||||||
|
|
||||||
private BulletManager bulletManager;
|
private BulletManager bulletManager;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
@@ -24,23 +28,39 @@ public class Enemy : MonoBehaviour
|
|||||||
|
|
||||||
private void Attack()
|
private void Attack()
|
||||||
{
|
{
|
||||||
bulletManager.SpawnPattern(patterns[CurrentPattern], this);
|
bulletManager.SpawnPattern(patterns[CurrentPattern], this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Consumed()
|
public void Consumed()
|
||||||
{
|
{
|
||||||
|
gameObject.SetActive(false); // TODO: some sort of effect
|
||||||
|
|
||||||
|
// once the enemy dies it should stop emitting bullets but keep any active bullets running
|
||||||
|
IsDead = true;
|
||||||
|
|
||||||
|
bulletManager.EnemyConsumed(scoreMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void OnPatternFinished()
|
public void OnPatternFinished()
|
||||||
{
|
{
|
||||||
CurrentPattern++;
|
if (gameObject.activeSelf)
|
||||||
if (CurrentPattern >= patterns.Length)
|
|
||||||
{
|
{
|
||||||
//Destroy(gameObject);
|
CurrentPattern++;
|
||||||
|
if (CurrentPattern >= patterns.Length)
|
||||||
|
{
|
||||||
|
//Destroy(gameObject);
|
||||||
|
}
|
||||||
|
Attack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
if (other.gameObject.GetComponent<Player>())
|
||||||
|
{
|
||||||
|
// okay.. player hit so we're being consumed
|
||||||
|
Consumed();
|
||||||
}
|
}
|
||||||
Attack();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user