Added score system and updated shanking with more angles!
This commit is contained in:
parent
5bebe754ce
commit
8cc0583a85
8 changed files with 126 additions and 29 deletions
|
|
@ -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 <GameController> ();
|
||||
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") {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <GameController> ();
|
||||
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 ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue