From 8cc0583a8586827e7a5b889b01eacce566c7fc5d Mon Sep 17 00:00:00 2001 From: shakurass Date: Sun, 27 Apr 2014 15:50:32 -0600 Subject: [PATCH] Added score system and updated shanking with more angles! --- Assets/Prefabs/Shanking Detector.prefab | 6 +- Assets/Scenes/Main.unity | 70 ++++++++++++++++--- Assets/Scripts/Demon.cs | 11 +++ Assets/Scripts/GameController.cs | 18 +++++ Assets/Scripts/Patron.cs | 13 +++- Assets/Scripts/PlayerController.cs | 29 ++++---- Assets/Sprites/Animation/player_shank.anim | 6 +- .../Materials/brickwal-not-animatedl0.mat | 2 +- 8 files changed, 126 insertions(+), 29 deletions(-) diff --git a/Assets/Prefabs/Shanking Detector.prefab b/Assets/Prefabs/Shanking Detector.prefab index f018345..c6e77dd 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: 2, y: .100000001, z: .100000001} + m_LocalScale: {x: 3, y: .5, z: .5} m_Children: [] m_Father: {fileID: 0} --- !u!23 &2300000 @@ -36,7 +36,7 @@ Renderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 100000} - m_Enabled: 0 + m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 m_LightmapIndex: 255 @@ -81,7 +81,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 025a712113e797c408ae9865e9ac79c6, type: 3} m_Name: m_EditorClassIdentifier: - length: .00999999978 + length: .100000001 --- !u!1001 &100100000 Prefab: m_ObjectHideFlags: 1 diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 82fd99d..2a09007 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -853,7 +853,7 @@ Prefab: - target: {fileID: 11400002, guid: 90277a37311b8fc4bbb1fbb1544e7530, type: 2} propertyPath: destinations.Array.data[1] value: - objectReference: {fileID: 973833183} + objectReference: {fileID: 964066619} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 90277a37311b8fc4bbb1fbb1544e7530, type: 2} m_RootGameObject: {fileID: 632681052} @@ -882,7 +882,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 493161365} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -3.27643204, y: -5.14518356, z: -6.35511398} + m_LocalPosition: {x: 0, y: 1, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 1592614700} @@ -1059,6 +1059,56 @@ SphereCollider: serializedVersion: 2 m_Radius: .5 m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &621151319 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 621151320} + - 132: {fileID: 621151321} + m_Layer: 0 + m_Name: Score Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &621151320 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 621151319} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 1, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1592614700} +--- !u!132 &621151321 +GUIText: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 621151319} + m_Enabled: 1 + serializedVersion: 3 + m_Text: Score Text + m_Anchor: 2 + m_Alignment: 0 + m_PixelOffset: {x: -10, y: -10} + m_LineSpacing: 1 + m_TabSize: 4 + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_Material: {fileID: 0} + m_FontSize: 20 + m_FontStyle: 0 + m_Color: + serializedVersion: 2 + rgba: 4294967295 + m_PixelCorrect: 1 + m_RichText: 1 --- !u!1 &632681052 GameObject: m_ObjectHideFlags: 0 @@ -1147,7 +1197,7 @@ MonoBehaviour: m_EditorClassIdentifier: destinations: - {fileID: 582022781} - - {fileID: 973833183} + - {fileID: 964066619} currentDestIndex: 1 --- !u!195 &632681058 NavMeshAgent: @@ -1512,7 +1562,7 @@ Prefab: - target: {fileID: 11400002, guid: bccc8e6eeff34c1468a1024f0111109c, type: 2} propertyPath: destinations.Array.data[0] value: - objectReference: {fileID: 582022781} + objectReference: {fileID: 964066619} - target: {fileID: 11400002, guid: bccc8e6eeff34c1468a1024f0111109c, type: 2} propertyPath: destinations.Array.data[1] value: @@ -1597,7 +1647,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: destinations: - - {fileID: 582022781} + - {fileID: 964066619} - {fileID: 973833183} currentDestIndex: 1 --- !u!195 &912326065 @@ -1900,7 +1950,7 @@ MonoBehaviour: m_EditorClassIdentifier: destinations: - {fileID: 582022781} - - {fileID: 973833183} + - {fileID: 815705938} currentDestIndex: 1 --- !u!195 &975281920 NavMeshAgent: @@ -1978,8 +2028,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: cc84b14a55660b643805ae0f1878c40b, type: 3} m_Name: m_EditorClassIdentifier: - swigs: 99999 + swigs: 5 swigText: {fileID: 493161367} + scoreText: {fileID: 621151321} --- !u!4 &1164596950 Transform: m_ObjectHideFlags: 0 @@ -2105,7 +2156,7 @@ Prefab: - target: {fileID: 11400000, guid: e5c4c39c0dd99f94dbc695a71276c6eb, type: 2} propertyPath: destinations.Array.data[1] value: - objectReference: {fileID: 973833183} + objectReference: {fileID: 815705938} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: e5c4c39c0dd99f94dbc695a71276c6eb, type: 2} m_RootGameObject: {fileID: 975281914} @@ -2205,9 +2256,10 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1592614699} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 3.27643204, y: 6.14518356, z: 6.35511398} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: + - {fileID: 621151320} - {fileID: 493161366} m_Father: {fileID: 0} --- !u!1 &1605196873 diff --git a/Assets/Scripts/Demon.cs b/Assets/Scripts/Demon.cs index 11bb943..374ccd5 100644 --- a/Assets/Scripts/Demon.cs +++ b/Assets/Scripts/Demon.cs @@ -4,6 +4,16 @@ using System.Collections; public class Demon : MonoBehaviour { public Renderer characterSprite; + private GameController gameController; + + void Start() { + GameObject gameControllerObject = GameObject.FindWithTag("GameController"); + + if (gameControllerObject != null) + gameController = gameControllerObject.GetComponent (); + else + Debug.Log("Cannot find GameController script."); + } void OnTriggerEnter(Collider other) { @@ -12,6 +22,7 @@ public class Demon : MonoBehaviour { { //Instantiate (playerExplosion, other.transform.position, other.transform.rotation); Destroy(gameObject); + gameController.AddScore(); } if (other.tag == "VVAura") { diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 8df3396..79830f3 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -5,10 +5,14 @@ public class GameController : MonoBehaviour { public int swigs; public GUIText swigText; + public GUIText scoreText; + + private int score = 0; // Use this for initialization void Start () { UpdateSwigText (); + UpdateScoreText (); } // Update is called once per frame @@ -21,7 +25,21 @@ public class GameController : MonoBehaviour { UpdateSwigText(); } + public void AddScore() { + score += 100; + UpdateScoreText (); + } + + public void DetractScore() { + score -= 150; + UpdateScoreText (); + } + void UpdateSwigText() { swigText.text = "Swigs Left: " + swigs; } + + void UpdateScoreText() { + scoreText.text = "Score: " + score; + } } diff --git a/Assets/Scripts/Patron.cs b/Assets/Scripts/Patron.cs index 6783a76..76d36a0 100644 --- a/Assets/Scripts/Patron.cs +++ b/Assets/Scripts/Patron.cs @@ -3,13 +3,24 @@ using System.Collections; public class Patron : MonoBehaviour { - void OnTriggerEnter(Collider other) { + private GameController gameController; + + void Start() { + GameObject gameControllerObject = GameObject.FindWithTag("GameController"); + + if (gameControllerObject != null) + gameController = gameControllerObject.GetComponent (); + else + Debug.Log("Cannot find GameController script."); + } + void OnTriggerEnter(Collider other) { //Instantiate(explosion, transform.position, transform.rotation); if (other.tag == "Shank") { //Instantiate (playerExplosion, other.transform.position, other.transform.rotation); Destroy(gameObject); + gameController.DetractScore (); } } } diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index a917908..10d2597 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -66,34 +66,39 @@ public class PlayerController : MonoBehaviour { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); - if (!Mathf.Approximately (moveHorizontal, 0)) { // walking sideways - animator.SetBool("isWalking", true); - animator.SetBool("isWalkingUp", false); - } - else if (!Mathf.Approximately(moveVertical, 0)){ // Walking up + if (moveVertical > 0){ // Walking up animator.SetBool("isWalkingUp", true); animator.SetBool("isWalking", false); } + else if (!Mathf.Approximately (moveHorizontal, 0) || moveVertical < 0) { // walking sideways + animator.SetBool("isWalking", true); + animator.SetBool("isWalkingUp", false); + } else { animator.SetBool("isWalking", false); animator.SetBool("isWalkingUp", false); } - if (moveHorizontal < 0) { + if (moveHorizontal < 0 && moveVertical > 0) // left up + playerAngle.eulerAngles = new Vector3(0f, -135, 0f); + else if (moveHorizontal < 0 && moveVertical < 0) // left down + playerAngle.eulerAngles = new Vector3(0f, -225f, 0f); + else if (moveHorizontal > 0 && moveVertical > 0) //right up + playerAngle.eulerAngles = new Vector3(0f, -45f, 0f); + else if (moveHorizontal > 0 && moveVertical < 0) //right down + playerAngle.eulerAngles = new Vector3(0f, 45f, 0f); + else if (moveHorizontal < 0) { // Stab left playerAngle.eulerAngles = new Vector3(0f, -180f, 0f); MakePlayerSpriteFace(Direction.Left); } - if (moveHorizontal > 0) { + else if (moveHorizontal > 0) { // Stab right playerAngle.eulerAngles = new Vector3 (0f, 0f, 0f); MakePlayerSpriteFace(Direction.Right); } - if (moveVertical < 0) + else if (moveVertical < 0) // Stab down playerAngle.eulerAngles = new Vector3(0f, -270f, 0f); - if (moveVertical > 0) + else if (moveVertical > 0) // Stab up playerAngle.eulerAngles = new Vector3(0f, -90f, 0f); - -// rigidbody.MovePosition (rigidbody.position + movement * speed * Time.deltaTime); -// rigidbody.position.Normalize (); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); rigidbody.velocity = movement * speed; diff --git a/Assets/Sprites/Animation/player_shank.anim b/Assets/Sprites/Animation/player_shank.anim index 700832e..b65dc5d 100644 --- a/Assets/Sprites/Animation/player_shank.anim +++ b/Assets/Sprites/Animation/player_shank.anim @@ -18,9 +18,9 @@ AnimationClip: m_PPtrCurves: - curve: - time: 0 - value: {fileID: 21300000, guid: 8a7d20d19b593974894a1d833a048e02, type: 3} - - time: .5 value: {fileID: 21300002, guid: 8a7d20d19b593974894a1d833a048e02, type: 3} + - time: .166666672 + value: {fileID: 21300000, guid: 8a7d20d19b593974894a1d833a048e02, type: 3} attribute: m_Sprite path: classID: 212 @@ -33,7 +33,7 @@ AnimationClip: m_AnimationClipSettings: serializedVersion: 2 m_StartTime: 0 - m_StopTime: .666666687 + m_StopTime: .333333343 m_OrientationOffsetY: 0 m_Level: 0 m_CycleOffset: 0 diff --git a/Assets/Sprites/Materials/brickwal-not-animatedl0.mat b/Assets/Sprites/Materials/brickwal-not-animatedl0.mat index 3a67e2f..d32a17a 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: .5} + m_Offset: {x: 0, y: 0} m_Floats: {} m_Colors: data: