From c0ee8ea5c3db410f8e5b2887cc3a4a4eb736c63e Mon Sep 17 00:00:00 2001 From: shakurass Date: Sun, 27 Apr 2014 18:49:23 -0600 Subject: [PATCH] Added patron spawner. --- Assets/Prefabs/Shanking Detector.prefab | 2 +- Assets/Scenes/Main.unity | 25 +++++++++++----- Assets/Scripts/GameController.cs | 30 +++++++++++++++++++ Assets/Scripts/PlayerController.cs | 16 +++++++--- .../Materials/brickwal-not-animatedl0.mat | 2 +- 5 files changed, 61 insertions(+), 14 deletions(-) diff --git a/Assets/Prefabs/Shanking Detector.prefab b/Assets/Prefabs/Shanking Detector.prefab index c6e77dd..939834b 100644 --- a/Assets/Prefabs/Shanking Detector.prefab +++ b/Assets/Prefabs/Shanking Detector.prefab @@ -27,7 +27,7 @@ Transform: m_GameObject: {fileID: 100000} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 3, y: .5, z: .5} + m_LocalScale: {x: 3.5, y: .5, z: .5} m_Children: [] m_Father: {fileID: 0} --- !u!23 &2300000 diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 6b763b9..1b85bed 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -511,7 +511,7 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 186161493} - m_LocalRotation: {x: .382683456, y: 0, z: 0, w: .923879504} + m_LocalRotation: {x: .382683486, y: 0, z: 0, w: .923879564} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: .889999986, z: 1} m_Children: [] @@ -629,7 +629,7 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 317209490} - m_LocalRotation: {x: .382683456, y: 0, z: 0, w: .923879504} + m_LocalRotation: {x: .382683486, y: 0, z: 0, w: .923879564} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: .889999986, z: 1} m_Children: [] @@ -886,7 +886,7 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 400339584} - m_LocalRotation: {x: .382683456, y: 0, z: 0, w: .923879504} + m_LocalRotation: {x: .382683486, y: 0, z: 0, w: .923879564} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: .889999986, z: 1} m_Children: [] @@ -1420,7 +1420,7 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 659898285} - m_LocalRotation: {x: .382683456, y: 0, z: 0, w: .923879504} + m_LocalRotation: {x: .382683486, y: 0, z: 0, w: .923879564} m_LocalPosition: {x: .827395439, y: 0, z: 0} m_LocalScale: {x: .939999998, y: .810000002, z: 1} m_Children: [] @@ -1562,7 +1562,7 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 739477386} - m_LocalRotation: {x: .382683456, y: 0, z: 0, w: .923879504} + m_LocalRotation: {x: .382683486, y: 0, z: 0, w: .923879564} m_LocalPosition: {x: .827395439, y: 0, z: 0} m_LocalScale: {x: .939999998, y: .810000002, z: 1} m_Children: [] @@ -2570,6 +2570,15 @@ MonoBehaviour: swigs: 5 swigText: {fileID: 493161367} scoreText: {fileID: 621151321} + patronCount: 10 + spawnWait: .5 + startWait: 1 + waveWait: 1 + patron: + - {fileID: 100002, guid: 90277a37311b8fc4bbb1fbb1544e7530, type: 2} + - {fileID: 100002, guid: e5c4c39c0dd99f94dbc695a71276c6eb, type: 2} + - {fileID: 100000, guid: 41b19f6c96ad15e4dace633fe1d0a962, type: 2} + - {fileID: 100000, guid: bccc8e6eeff34c1468a1024f0111109c, type: 2} --- !u!4 &1164596950 Transform: m_ObjectHideFlags: 0 @@ -3647,7 +3656,7 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1880321583} - m_LocalRotation: {x: .382683456, y: 0, z: 0, w: .923879504} + m_LocalRotation: {x: .382683486, y: 0, z: 0, w: .923879564} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: .939999998, y: .810000002, z: 1} m_Children: [] @@ -3920,7 +3929,7 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 2009917412} - m_LocalRotation: {x: .382683456, y: 0, z: 0, w: .923879504} + m_LocalRotation: {x: .382683486, y: 0, z: 0, w: .923879564} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: .850000024, z: 1} m_Children: [] @@ -4011,7 +4020,7 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 2107301824} - m_LocalRotation: {x: .382683456, y: 0, z: 0, w: .923879504} + m_LocalRotation: {x: .382683486, y: 0, z: 0, w: .923879564} m_LocalPosition: {x: .827395439, y: 0, z: 0} m_LocalScale: {x: .939999998, y: .810000002, z: 1} m_Children: [] diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 79830f3..185f4e8 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -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(); diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 10d2597..e0593c5 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -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); diff --git a/Assets/Sprites/Materials/brickwal-not-animatedl0.mat b/Assets/Sprites/Materials/brickwal-not-animatedl0.mat index 089d98c..3b9a9ab 100644 --- a/Assets/Sprites/Materials/brickwal-not-animatedl0.mat +++ b/Assets/Sprites/Materials/brickwal-not-animatedl0.mat @@ -19,7 +19,7 @@ Material: second: m_Texture: {fileID: 2800000, guid: 26c9dff0fed396341b045e42e3a0b500, type: 3} m_Scale: {x: 1, y: .5} - m_Offset: {x: 0, y: 0} + m_Offset: {x: 0, y: .5} data: first: name: _BumpMap