Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Working transfer UI info
  • Loading branch information
smz11006 committed Dec 15, 2015
1 parent 13bc366 commit bbf0357
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 30 deletions.
9 changes: 9 additions & 0 deletions Roguelike2d/Assets/Prefabs/Persistence.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Roguelike2d/Assets/Scenes/ProcGenTest.unity
Binary file not shown.
2 changes: 2 additions & 0 deletions Roguelike2d/Assets/Script/NextLevel.cs
Expand Up @@ -3,11 +3,13 @@ using System.Collections;

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);
}
Expand Down
72 changes: 51 additions & 21 deletions Roguelike2d/Assets/Script/Persistence.cs
@@ -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;
}
}
1 change: 1 addition & 0 deletions Roguelike2d/Assets/Script/Pickups.cs
Expand Up @@ -6,6 +6,7 @@ public class Pickups : MonoBehaviour {
public int charge = 0;
public GameObject exit;


void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "EscapeCharge")
Expand Down
89 changes: 80 additions & 9 deletions Roguelike2d/Assets/Script/TextCore.cs
Expand Up @@ -4,15 +4,86 @@ using UnityEngine.UI;


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 modified Roguelike2d/Library/CurrentLayout.dwlt
Binary file not shown.
Binary file modified Roguelike2d/Library/ScriptAssemblies/Assembly-CSharp.dll.mdb
Binary file not shown.
Binary file modified Roguelike2d/Library/assetDatabase3
Binary file not shown.
Binary file modified Roguelike2d/Library/expandedItems
Binary file not shown.
Binary file modified Roguelike2d/Library/metadata/00/00000000000000004000000000000000
Binary file not shown.

0 comments on commit bbf0357

Please sign in to comment.