-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMainGame.cs
116 lines (106 loc) · 2.58 KB
/
MainGame.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<<<<<<< HEAD
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace TowerDefenseGame
{
public class MainGame
{
public float nextTime_ = 0.0f;
public float timeBetweenBalloons_ = 1.0f;
public GameObject balloonPrefab_;
public int numBalloons_ = 0;
public int balloonsInWave_ = 5;
public static int totalScore_ = 0;
public static int lives_ = 5;
public int numberOfWaves_ = 1;
public bool needToBeCalled_ = true;
//singelton
private static MainGame instance = null;
public static MainGame Instance { get { return instance; } }
// Use this for initialization
void Start()
{
totalScore_ = 0;
}
// Update is called once per frame
public void makeNextWave()
{
if (numberOfWaves_ % 5 == 0)
{
timeBetweenBalloons_ -= .1f;
}
balloonsInWave_ += 3;
numBalloons_ = 0;
needToBeCalled_ = true;
numberOfWaves_++;
}
}
=======
using UnityEngine;
using System.Collections;
public class MainGame : MonoBehaviour {
public float nextTime_= 0.0f;
public float timeBetweenBalloons_=1.0f;
public GameObject balloonPrefab_;
public int numBalloons_ = 0;
public int balloonsInWave_ = 5;
public static int totalScore_ = 0;
public static int lives_ = 5;
public int numberOfWaves_ = 1;
public bool needToBeCalled_= true;
// Use this for initialization
void Start () {
totalScore_ = 0;
}
// Update is called once per frame
void Update () {
if (lives_ > 0) {
if (nextTime_ < Time.time) {
if(numBalloons_ < balloonsInWave_)
{
CreateBalloon();
numBalloons_++;
}
else
{
if(needToBeCalled_)
{
StartCoroutine(DelayWave());
needToBeCalled_= false;
}
}
nextTime_ = Time.time + timeBetweenBalloons_;
}
}
}
public void CreateBalloon()
{
Instantiate (balloonPrefab_);
}
public void OnGUI()
{
GUI.color = Color.white;
GUI.Label(new Rect(10, 10, 120, 20), "Lives: " + lives_.ToString());
GUI.Label(new Rect(10, 30, 60, 20), "Score: " + totalScore_.ToString());
}
public IEnumerator DelayWave()
{
yield return new WaitForSeconds(8f);
makeNextWave ();
}
public void makeNextWave()
{
if (numberOfWaves_ % 5 == 0)
{
timeBetweenBalloons_-=.1f;
}
balloonsInWave_ += 3;
numBalloons_ = 0;
needToBeCalled_ = true;
}
>>>>>>> 63821ce59e773a75b21d8639e4b7d2ade7850df0
}