Permalink
Cannot retrieve contributors at this time
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?
Intro_Scritping/Roguelike2d/Assets/Script/TextCore.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
89 lines (72 sloc)
2.25 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |