|
|
@ -19,7 +19,11 @@ public class playerController : MonoBehaviour { |
|
|
|
public GUIText gameOverDisplay; |
|
|
|
public GameObject dashDisplay; |
|
|
|
public GameObject playerFrac; |
|
|
|
|
|
|
|
public GameObject[] hearts; |
|
|
|
//public GameObject heart2;
|
|
|
|
//public GameObject heart3;
|
|
|
|
|
|
|
|
|
|
|
|
public float runSpeed; //run speed
|
|
|
|
public float jumpHeight; //jump height
|
|
|
|
public float health; //holds health
|
|
|
@ -46,7 +50,7 @@ public class playerController : MonoBehaviour { |
|
|
|
private float curDirection = -1; //direction player is pointing
|
|
|
|
private bool canJump = true; // if player can jump
|
|
|
|
private bool canSpin = true; // if player can spin
|
|
|
|
private List<GameObject> hearts = new List<GameObject> (); //list which holds health sprites;
|
|
|
|
//private List<GameObject> hearts = new List<GameObject> (); //list which holds health sprites;
|
|
|
|
private bool isSpinning = false; //checks if player is spin attacking
|
|
|
|
private float lastHit; |
|
|
|
private float lastAttack; |
|
|
@ -149,23 +153,15 @@ public class playerController : MonoBehaviour { |
|
|
|
updateHealth = true; |
|
|
|
|
|
|
|
if (updateHealth){ |
|
|
|
foreach (GameObject desHeart in hearts) //Destroy all heart sprites
|
|
|
|
GameObject.Destroy (desHeart); |
|
|
|
hearts.Clear(); //sets list to zero
|
|
|
|
foreach (GameObject heart in hearts) //Destroy all heart sprites
|
|
|
|
heart.SetActive(false); //sets list to zero
|
|
|
|
|
|
|
|
for (int i=1; i<= health; i++) { //creates new heart sprite for each health
|
|
|
|
GameObject heartCanister = Instantiate (heart) as GameObject; //creat heart sprite
|
|
|
|
Vector3 heartPos = new Vector3 (); |
|
|
|
|
|
|
|
//set position
|
|
|
|
heartPos.x = (healthPos.x + i * 0.033f); |
|
|
|
heartPos.y = healthPos.y; |
|
|
|
for (int i=0; i< health; i++) { //creates new heart sprite for each health
|
|
|
|
hearts[i].SetActive(true); |
|
|
|
|
|
|
|
heartCanister.transform.position = heartPos; |
|
|
|
hearts.Add(heartCanister); //adds heart to list
|
|
|
|
|
|
|
|
if (heartBlack == true && heartColor == false){ |
|
|
|
heartCanister.guiTexture.color = Color.black; |
|
|
|
//heartCanister.guiTexture.color = Color.black;
|
|
|
|
|
|
|
|
//else (heartCanister.guiTexture.color = Color.red);
|
|
|
|
} |
|
|
|