-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlackHole.cs
69 lines (55 loc) · 1.7 KB
/
BlackHole.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using UnityEngine;
using System.Collections;
public class BlackHole : MonoBehaviour {
public float divisorDelay = 13.52f;
public float nextDivisor = 0f;
public CircleCollider2D collider;
public static int rand;
float threshold;
float scoreRadius;
void OnTriggerEnter2D(Collider2D col)
{
int entered;
if (GameObject.FindObjectOfType<ScoreManager>().hasLost)
{
return;
}
if (int.TryParse(col.gameObject.GetComponent<TextMesh>().text, out entered))
{
if (entered % rand == 0)
{
GameObject.FindObjectOfType<ScoreManager>().score++;
}
else
{
GameObject.FindObjectOfType<ScoreManager>().score--;
}
}
Destroy(col.gameObject);
}
// Update is called once per frame
void FixedUpdate () {
if (GameObject.FindObjectOfType<ScoreManager>().hasLost)
{
return;
}
threshold = FindObjectOfType<BoxLauncher>().debugValue;
collider = transform.GetComponent<CircleCollider2D>();
int score = FindObjectOfType<ScoreManager>().score;
if (score > 0)
{
scoreRadius = score / 100;
} else
{
scoreRadius = 0;
}
collider.radius = 0.6f + (threshold / 2f) + scoreRadius;
nextDivisor -= Time.deltaTime;
if (nextDivisor <= 0)
{
nextDivisor = divisorDelay;
rand = ((int)Random.Range(1, 9));
gameObject.GetComponent<TextMesh>().text = rand.ToString();
}
}
}