2022-01-22 20:13:49 -08:00
|
|
|
using System.Collections;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using FistVR;
|
|
|
|
|
|
|
|
|
|
namespace TNHQoLImprovements
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Code here should only be run when in TNH play.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class InPlay : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private GameObject gObjHUD;
|
|
|
|
|
public static TNH_Manager tnhManager;
|
|
|
|
|
|
|
|
|
|
void ImproveHPTextReadability()
|
|
|
|
|
{
|
|
|
|
|
var canvas = gObjHUD.GetComponent<Canvas>();
|
|
|
|
|
var gObjBG = new GameObject();
|
2022-01-24 01:48:22 -08:00
|
|
|
Transform[] tranHPText = {
|
|
|
|
|
gObjHUD.transform.Find("Label_Title (1)"),
|
|
|
|
|
gObjHUD.transform.Find("Label_Title")
|
|
|
|
|
};
|
2022-01-22 20:13:49 -08:00
|
|
|
|
|
|
|
|
// apply background
|
2022-01-24 01:48:22 -08:00
|
|
|
if (MeatKitPlugin.cfgShowHPBackground.Value)
|
2022-01-22 20:13:49 -08:00
|
|
|
{
|
|
|
|
|
gObjBG.transform.parent = gObjHUD.transform;
|
|
|
|
|
gObjBG.transform.SetSiblingIndex(0);
|
|
|
|
|
gObjBG.transform.localPosition = new Vector3(0, 1, 0);
|
|
|
|
|
gObjBG.transform.localRotation = Quaternion.identity;
|
2022-01-24 01:48:22 -08:00
|
|
|
gObjBG.transform.localScale = tranHPText[0].localScale;
|
2022-01-22 20:13:49 -08:00
|
|
|
var rawImage = gObjBG.AddComponent<RawImage>();
|
2022-01-24 01:48:22 -08:00
|
|
|
rawImage.color = new Color(0, 0, 0, MeatKitPlugin.cfgHPBackgroundOpacity.Value);
|
2022-01-22 20:13:49 -08:00
|
|
|
rawImage.rectTransform.SetWidth(100);
|
|
|
|
|
rawImage.rectTransform.SetHeight(52);
|
|
|
|
|
}
|
2022-01-24 01:48:22 -08:00
|
|
|
if (MeatKitPlugin.cfgSolidifyHPText.Value)
|
|
|
|
|
{
|
|
|
|
|
foreach (var text in tranHPText)
|
|
|
|
|
{
|
|
|
|
|
// full alpha
|
|
|
|
|
text.GetComponent<Text>().color = Color.white;
|
|
|
|
|
// drop shadow
|
|
|
|
|
var shadow = text.gameObject.AddComponent<Shadow>();
|
|
|
|
|
shadow.effectColor = new Color(0, 0, 0, .95f);
|
|
|
|
|
shadow.effectDistance = new Vector2(0.5f, -0.5f);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-22 20:13:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use this for initialization
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
tnhManager = GameObject.Find("_GameManager").GetComponent<TNH_Manager>();
|
|
|
|
|
gObjHUD = GameObject.Find("HealthBar(Clone)/f");
|
|
|
|
|
|
2022-01-24 01:48:22 -08:00
|
|
|
if(MeatKitPlugin.cfgShowHPBackground.Value || MeatKitPlugin.cfgSolidifyHPText.Value)
|
|
|
|
|
ImproveHPTextReadability();
|
|
|
|
|
if (MeatKitPlugin.cfgShowTokens.Value)
|
2022-01-26 01:23:39 -08:00
|
|
|
Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("TokenCounter"), FindObjectOfType<TAH_Reticle>().transform.GetChild(3));
|
2022-01-24 01:48:22 -08:00
|
|
|
if (MeatKitPlugin.cfgShowHolds.Value)
|
2022-01-26 01:23:39 -08:00
|
|
|
Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("HoldCounter"), FindObjectOfType<TAH_Reticle>().transform.GetChild(3));
|
2022-01-22 20:13:49 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|