2022-01-22 20:13:49 -08:00
|
|
|
using System.Collections;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2022-01-24 03:40:08 -08:00
|
|
|
using FistVR;
|
2022-01-22 20:13:49 -08:00
|
|
|
|
|
|
|
|
namespace TNHQoLImprovements
|
|
|
|
|
{
|
|
|
|
|
public class TokenCounter : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2022-01-28 19:57:50 -08:00
|
|
|
transform.localPosition = new Vector3(333, 0, -450);
|
2022-01-22 20:13:49 -08:00
|
|
|
|
2022-01-28 19:57:50 -08:00
|
|
|
StartCoroutine(SetTokenImage());
|
2022-01-22 20:13:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerator SetTokenImage()
|
|
|
|
|
{
|
|
|
|
|
int debug_iterations = 0;
|
|
|
|
|
Sprite tokenSprite = null;
|
|
|
|
|
while (tokenSprite == null) // END: loop until Token sprite is found
|
|
|
|
|
{
|
|
|
|
|
var obj = GameObject.Find("_TNH_ObjectConstructor(Clone)/_CanvasHolder/_UITest_Canvas/Icon_0/Cost_1/Image");
|
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
tokenSprite = obj.GetComponent<Image>().sprite;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
debug_iterations++;
|
2022-01-24 03:40:08 -08:00
|
|
|
yield return new WaitForEndOfFrame();
|
2022-01-22 20:13:49 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Debug.Log("Token sprite found after " + debug_iterations.ToString() + " iterations.");
|
|
|
|
|
transform.GetChild(0).GetComponent<Image>().sprite = tokenSprite;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
int tokens = InPlay.tnhManager.GetNumTokens();
|
|
|
|
|
transform.GetChild(1).GetComponent<Text>().text = tokens.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|