Skip to content
Permalink
Browse files

Working transfer UI info

  • Loading branch information
smz11006 committed Dec 15, 2015
1 parent 13bc366 commit bbf03575abecc0a4cf8a7e72e5b98f40fddd9e6d

Some generated files are not rendered by default. Learn more.

Binary file not shown.

Some generated files are not rendered by default. Learn more.

Binary file not shown.

Some generated files are not rendered by default. Learn more.

Binary file not shown.
@@ -3,11 +3,13 @@

public class NextLevel : MonoBehaviour {
public GameObject player;
public int checker = 0;

void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "Player")
{
checker = checker + 1;
Debug.Log("HitExit");
Application.LoadLevel(0);
}
@@ -1,38 +1,68 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Persistence : MonoBehaviour {
public static Persistence Instance;

public int health = 100;
public int score = 0;
public int cores = 0;
public int power = 0;
TextCore textCore;

public GameObject uiController = GameObject.Find("UIElementController");
//public Canvas theUI;

public int health;
public int score;
public int cores;
public int power;

//Awake
void Awake()
{
//DontDestroyOnLoad(health);
//DontDestroyOnLoad(score);
//DontDestroyOnLoad(power);
DontDestroyOnLoad(gameObject);
}
//Collisoin Detection
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "EscapeCharge")
if (Instance == null)
{
DontDestroyOnLoad(gameObject);
Instance = this;
}
else if (Instance != this)
{
Debug.Log("Charge Counted");
power = power + 1;
Destroy(gameObject);
}

}

// Use this for initialization
void Start () {

}
void Start ()
{
textCore = GameObject.Find("UIElementController").GetComponent<TextCore>();

health = Persistence.Instance.health;
power = Persistence.Instance.power;
cores = Persistence.Instance.cores;
score = Persistence.Instance.score;
uiController = Persistence.Instance.uiController;
textCore = Persistence.Instance.textCore;
// theUI = Persistence.Instance.theUI;
}

// Update is called once per frame
void Update () {

}
void Update ()
{

health = textCore.health;
score = textCore.score;
power = textCore.power;
// cores = textCore.cores;

}

//Scene Transitions
public void SavePlayer()
{
Persistence.Instance.health = health;
Persistence.Instance.score = score;
Persistence.Instance.cores = cores;
Persistence.Instance.power = power;
Persistence.Instance.uiController = uiController;
Persistence.Instance.textCore = textCore;
}
}
@@ -6,6 +6,7 @@ public class Pickups : MonoBehaviour {
public int charge = 0;
public GameObject exit;


void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "EscapeCharge")
@@ -4,15 +4,86 @@


public class TextCore : MonoBehaviour {
public Text text;

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 () {

}

// Update is called once per frame
void Update () {

}
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);
}
}
}
Binary file not shown.
Binary file not shown.
BIN +840 Bytes (100%) Roguelike2d/Library/assetDatabase3
Binary file not shown.
BIN -288 Bytes (94%) Roguelike2d/Library/expandedItems
Binary file not shown.
Binary file not shown.

0 comments on commit bbf0357

Please sign in to comment.
You can’t perform that action at this time.