-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoseCollider.cs
42 lines (34 loc) · 908 Bytes
/
LoseCollider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using UnityEngine;
using System.Collections;
public class LoseCollider : MonoBehaviour {
private float loseAmount;
private LevelManager levelManager;
private LifeDisplay lifeDisplay;
private int collisionCount;
// Use this for initialization
void Start () {
levelManager = GameObject.FindObjectOfType<LevelManager>();
lifeDisplay = GameObject.FindObjectOfType<LifeDisplay>();
loseAmount = PlayerPrefsManager.GetDifficulty();
print(loseAmount);
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D collider){
if(collider.GetComponent<Attacker>()){
IncrementCollisionCount();
LoseScenario(collisionCount);
}
}
void IncrementCollisionCount(){
collisionCount++;
lifeDisplay.decrementLives();
print(collisionCount);
}
void LoseScenario(int count){
if(count >= loseAmount){
levelManager.LoadLevel("03b_Lose");
}
}
}