Added patron spawner.
This commit is contained in:
parent
5aac6aa72a
commit
c0ee8ea5c3
5 changed files with 61 additions and 14 deletions
|
|
@ -6,13 +6,21 @@ public class GameController : MonoBehaviour {
|
|||
public int swigs;
|
||||
public GUIText swigText;
|
||||
public GUIText scoreText;
|
||||
public int patronCount;
|
||||
public float spawnWait;
|
||||
public float startWait;
|
||||
public float waveWait;
|
||||
public GameObject[] patron;
|
||||
|
||||
private int score = 0;
|
||||
private int patrons = 0;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
UpdateSwigText ();
|
||||
UpdateScoreText ();
|
||||
|
||||
StartCoroutine (SpawnWaves ());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
|
@ -20,6 +28,28 @@ public class GameController : MonoBehaviour {
|
|||
|
||||
}
|
||||
|
||||
IEnumerator SpawnWaves ()
|
||||
{
|
||||
yield return new WaitForSeconds (startWait);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (patrons < patronCount)
|
||||
{
|
||||
Vector3 spawnPosition = new Vector3 (40f, 2.5f, 10f);
|
||||
Quaternion spawnRotation = Quaternion.identity;
|
||||
|
||||
GameObject patron = Instantiate (patron[Random.Range (0, patron.Length)], spawnPosition, spawnRotation);
|
||||
|
||||
patrons++;
|
||||
|
||||
yield return new WaitForSeconds (spawnWait);
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds (waveWait);
|
||||
}
|
||||
}
|
||||
|
||||
public void TakeSwig() {
|
||||
swigs -= 1;
|
||||
UpdateSwigText();
|
||||
|
|
|
|||
|
|
@ -79,14 +79,22 @@ public class PlayerController : MonoBehaviour {
|
|||
animator.SetBool("isWalkingUp", false);
|
||||
}
|
||||
|
||||
if (moveHorizontal < 0 && moveVertical > 0) // left up
|
||||
if (moveHorizontal < 0 && moveVertical > 0) { // left up
|
||||
playerAngle.eulerAngles = new Vector3(0f, -135, 0f);
|
||||
else if (moveHorizontal < 0 && moveVertical < 0) // left down
|
||||
MakePlayerSpriteFace(Direction.Left);
|
||||
}
|
||||
else if (moveHorizontal < 0 && moveVertical < 0) {// left down
|
||||
playerAngle.eulerAngles = new Vector3(0f, -225f, 0f);
|
||||
else if (moveHorizontal > 0 && moveVertical > 0) //right up
|
||||
MakePlayerSpriteFace(Direction.Left);
|
||||
}
|
||||
else if (moveHorizontal > 0 && moveVertical > 0) {//right up
|
||||
playerAngle.eulerAngles = new Vector3(0f, -45f, 0f);
|
||||
else if (moveHorizontal > 0 && moveVertical < 0) //right down
|
||||
MakePlayerSpriteFace(Direction.Right);
|
||||
}
|
||||
else if (moveHorizontal > 0 && moveVertical < 0) {//right down
|
||||
playerAngle.eulerAngles = new Vector3(0f, 45f, 0f);
|
||||
MakePlayerSpriteFace(Direction.Right);
|
||||
}
|
||||
else if (moveHorizontal < 0) { // Stab left
|
||||
playerAngle.eulerAngles = new Vector3(0f, -180f, 0f);
|
||||
MakePlayerSpriteFace(Direction.Left);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue