Skip to content
Permalink
bbf03575ab
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
89 lines (72 sloc) 2.25 KB
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class TextCore : MonoBehaviour {
public GameObject persistentStats = GameObject.Find("Persistent Counter");
// public GameObject reference;
// public GameObject exit = GameObject.Find("Exit");
public GameObject player = GameObject.Find("Player");
public int health = 100;
public int score = 0;
public int cores = 0;
public int power = 0;
public Text powerText;
public Text coreText;
public Text scoreText;
public Text healthText;
public static string healthString;
public static string scoreString;
public static string coreString;
public static string powerString;
//Awake
void Awake()
{
DontDestroyOnLoad(gameObject);
Persistence persistence = persistentStats.GetComponent<Persistence>();
health = persistence.health;
score = persistence.score;
power = persistence.power;
}
// Use this for initialization
void Start()
{
persistentStats = GameObject.Find("Persistent Counter");
Persistence persistence = persistentStats.GetComponent<Persistence>();
if (persistence.health != health)
{
health = persistence.health;
score = persistence.score;
cores = persistence.cores;
power = persistence.power;
}
// persistence.health = health;
}
// Update is called once per frame
void Update()
{
// NextLevel nextLevel = exit.GetComponent<NextLevel>();
Pickups pickups = player.GetComponent<Pickups>();
cores = pickups.charge;
if (pickups.charge > 4)
{
cores = 4;
}
// cores = nextlevel.checker;
healthString = health.ToString();
scoreString = score.ToString();
coreString = cores.ToString();
powerString = power.ToString();
healthText.text = healthString;
scoreText.text = scoreString;
coreText.text = coreString;
powerText.text = powerString;
}
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "Player")
{
Debug.Log("HitExit");
Application.LoadLevel(0);
}
}
}