Skip to content

Commit

Permalink
Improve UI: Add tower health, coints, time, game name, update textures
Browse files Browse the repository at this point in the history
  • Loading branch information
BabichMikhail committed May 11, 2018
1 parent d8aab83 commit bd0eaa1
Show file tree
Hide file tree
Showing 9 changed files with 628 additions and 734 deletions.
Binary file added Assets/Resources/images/heart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions Assets/Resources/images/heart.png.meta

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

Binary file added Assets/Resources/images/points.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions Assets/Resources/images/points.png.meta

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

21 changes: 21 additions & 0 deletions Assets/Resources/scripts/ClockController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using UnityEngine;
using UnityEngine.UI;

public class ClockController : MonoBehaviour {
private float initializedAt;

private void Awake()
{
initializedAt = Time.time;
}

void Update () {
var startedAt = (int)(Time.time - initializedAt);
float minutes = startedAt / 60;
float seconds = startedAt - minutes * 60;
var secondsString = seconds.ToString();
if (secondsString.Length == 1)
secondsString = "0" + secondsString;
gameObject.GetComponentInChildren<Text>().text = minutes.ToString() + ":" + secondsString;
}
}
11 changes: 11 additions & 0 deletions Assets/Resources/scripts/ClockController.cs.meta

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

7 changes: 0 additions & 7 deletions Assets/Resources/scripts/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public class Container {
private static GameObject routeContainer;
private static GameObject towerContainer;
private static Canvas createTowerCanvas;
private static Canvas updateTowerCanvas;
private static List<GameObject[]> towers = new List<GameObject[]>();

private static Container instance;
Expand Down Expand Up @@ -54,10 +53,4 @@ public Canvas GetCreateTowerCanvas()
createTowerCanvas = GameObject.FindGameObjectWithTag("CreateTowerCanvas").GetComponent<Canvas>();
return createTowerCanvas;
}
public Canvas GetUpdateTowerCanvas()
{
if (updateTowerCanvas == null)
updateTowerCanvas = GameObject.FindGameObjectWithTag("UpdateTowerCanvas").GetComponent<Canvas>();
return updateTowerCanvas;
}
}
4 changes: 4 additions & 0 deletions Assets/Resources/scripts/MainTowerController.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using UnityEngine;
using UnityEngine.UI;

public class MainTowerController : MonoBehaviour {
public int health = Config.MAIN_TOWER_HEALTH;
public GameObject defeatMenu;
public GameObject gameMenu;

public GameObject towerHealthText;

private void Update()
{
health = Mathf.Max(health, 0);
towerHealthText.GetComponent<Text>().text = (health / 10).ToString();
if (health == 0) {
gameMenu.GetComponent<Canvas>().enabled = false;
defeatMenu.GetComponent<Canvas>().enabled = true;
Expand Down
Loading

0 comments on commit bd0eaa1

Please sign in to comment.