mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-03 04:34:26 -07:00
1.1.0 release! many new features.
This commit is contained in:
@@ -7,7 +7,6 @@ namespace TNHQoLImprovements
|
||||
{
|
||||
public static void ImproveHPTextReadability(GameObject gObjHUD)
|
||||
{
|
||||
Debug.Log("gObjHUD: " + gObjHUD);
|
||||
var canvas = gObjHUD.GetComponent<Canvas>();
|
||||
var gObjBG = new GameObject();
|
||||
Transform[] tranHPText = {
|
||||
|
||||
@@ -22,7 +22,8 @@ namespace TNHQoLImprovements
|
||||
private Text lblWinLose;
|
||||
|
||||
public static int[] winLose = { -1, 1 };
|
||||
public const string WIN_LOSE_TEXT = "<color=#10ff10>{0}</color> <color=red>{1}</color>";
|
||||
public const string WIN_LOSE_TEXT = "W: {0} L: {1}";
|
||||
//public const string WIN_LOSE_TEXT = "<color=#10ff10>{0}</color> <color=red>{1}</color>";
|
||||
|
||||
public static void OnHoldEnd(TNH_HoldPoint p, bool success)
|
||||
{
|
||||
@@ -34,11 +35,13 @@ namespace TNHQoLImprovements
|
||||
|
||||
void Start()
|
||||
{
|
||||
transform.localPosition = new Vector3(-333, 0, -450);
|
||||
|
||||
lblHoldCount = transform.GetChild(1).GetComponent<Text>();
|
||||
lblWinLose = transform.GetChild(2).GetComponent<Text>();
|
||||
|
||||
transform.GetChild(0).GetComponent<Text>().font = MeatKitPlugin.fontAgencyFB;
|
||||
lblHoldCount.font = MeatKitPlugin.fontAgencyFB;
|
||||
lblWinLose.font = MeatKitPlugin.fontAgencyFB;
|
||||
|
||||
winLose[0] = 0;
|
||||
winLose[1] = 0;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,15 @@ namespace TNHQoLImprovements
|
||||
private static Transform[] hands;
|
||||
private static GameObject tnhInfo;
|
||||
|
||||
public static bool InHold()
|
||||
{
|
||||
if (tnhManager == null)
|
||||
return false;
|
||||
|
||||
return tnhManager.Phase == TNH_Phase.Hold;
|
||||
}
|
||||
|
||||
// Bring extra info into game over
|
||||
public static void Patch(Harmony harmony)
|
||||
{
|
||||
var original = typeof(TNH_Manager).GetMethod("SetPhase", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
@@ -38,7 +47,6 @@ namespace TNHQoLImprovements
|
||||
}
|
||||
}
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
tnhManager = GameObject.Find("_GameManager").GetComponent<TNH_Manager>();
|
||||
|
||||
@@ -12,45 +12,46 @@ namespace TNHQoLImprovements
|
||||
public static void Patch(Harmony harmony)
|
||||
{
|
||||
var original = typeof(TNH_ObjectConstructorIcon).GetMethod("Init", BindingFlags.Public | BindingFlags.Instance);
|
||||
var postfix = typeof(ShopCostPatch).GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
var postfix = typeof(ShopCostPatch).GetMethod("AddCostNumber", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
harmony.Patch(original, new HarmonyMethod(postfix));
|
||||
}
|
||||
|
||||
private static void AddNumericalRepresentation(TNH_ObjectConstructorIcon __instance)
|
||||
private static void AddCostNumber(TNH_ObjectConstructorIcon __instance)
|
||||
{
|
||||
foreach (Transform curTran in __instance.gameObject.transform)
|
||||
{
|
||||
if (curTran.name.Contains("Cost"))
|
||||
curTran.gameObject.AddComponent<ShopCostNumber>();
|
||||
curTran.gameObject.AddComponent<CostNumber>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ShopCostNumber : MonoBehaviour
|
||||
public class CostNumber : MonoBehaviour
|
||||
{
|
||||
private TNH_ObjectConstructorIcon objConstructor;
|
||||
private TNH_ObjectConstructorIcon objConstructorIcon;
|
||||
private Text text;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
objConstructor = transform.parent.GetComponent<TNH_ObjectConstructorIcon>();
|
||||
objConstructorIcon = transform.parent.GetComponent<TNH_ObjectConstructorIcon>();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
var textTran = new GameObject().transform;
|
||||
textTran.SetParent(transform, false);
|
||||
textTran.localPosition = new Vector2(0, -245);
|
||||
textTran.localPosition = new Vector2(0, 245);
|
||||
|
||||
text = textTran.gameObject.AddComponent<Text>();
|
||||
text.font = MeatKitPlugin.fontAgencyFB;
|
||||
text.alignment = TextAnchor.MiddleCenter;
|
||||
text.fontSize = 50;
|
||||
text.font = MeatKitPlugin.fontBombardier;
|
||||
text.alignment = TextAnchor.MiddleCenter;
|
||||
text.fontSize = 72;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
text.text = objConstructor.Cost.ToString();
|
||||
text.text = objConstructorIcon.Cost.ToString();
|
||||
text.color = objConstructorIcon.GetComponent<Image>().color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using FistVR;
|
||||
|
||||
namespace TNHQoLImprovements
|
||||
{
|
||||
public static class ShopTokenPatch
|
||||
{
|
||||
public static void Patch(Harmony harmony)
|
||||
{
|
||||
var original = typeof(TNH_ObjectConstructor).GetMethod("Start", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
var postfix = typeof(ShopTokenPatch).GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
harmony.Patch(original, postfix: new HarmonyMethod(postfix));
|
||||
}
|
||||
private static void Postfix(TNH_ObjectConstructor __instance)
|
||||
{
|
||||
// add component to 1st token icon
|
||||
__instance.transform.GetChild(0).GetChild(0).GetChild(2).GetChild(0).gameObject.AddComponent<ShopTokenNumber>();
|
||||
}
|
||||
}
|
||||
|
||||
// child of TopCell (the 0th child)
|
||||
class ShopTokenNumber : MonoBehaviour
|
||||
{
|
||||
private Text text;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var gObjText = new GameObject("TokenCounter");
|
||||
gObjText.transform.SetParent(transform, false);
|
||||
gObjText.transform.localPosition = new Vector3(0, -4, 0);
|
||||
|
||||
text = gObjText.AddComponent<Text>();
|
||||
text.alignment = TextAnchor.MiddleCenter;
|
||||
text.font = MeatKitPlugin.fontBombardier;
|
||||
text.fontSize = 55;
|
||||
text.color = new Color(0.1307786f, 0.2461715f, 0.359f);
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
int tokens = InPlay.tnhManager.GetNumTokens();
|
||||
text.text = tokens.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54fa5d5e1f85520468a10f9556e53456
|
||||
timeCreated: 1643446256
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using FistVR;
|
||||
|
||||
namespace TNHQoLImprovements
|
||||
@@ -7,6 +8,7 @@ namespace TNHQoLImprovements
|
||||
{
|
||||
private GameObject holdCounter;
|
||||
private GameObject tokenCounter;
|
||||
private GameObject waveCounter;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
@@ -14,7 +16,10 @@ namespace TNHQoLImprovements
|
||||
holdCounter = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("HoldCounter"), transform);
|
||||
if (MeatKitPlugin.cfgShowTokens.Value)
|
||||
tokenCounter = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("TokenCounter"), transform);
|
||||
if (MeatKitPlugin.cfgShowWaves.Value)
|
||||
waveCounter = Instantiate<GameObject>(MeatKitPlugin.bundle.LoadAsset<GameObject>("WaveCounter"), transform);
|
||||
|
||||
PlayPos();
|
||||
}
|
||||
|
||||
public void PlayPos()
|
||||
@@ -24,6 +29,9 @@ namespace TNHQoLImprovements
|
||||
|
||||
if (tokenCounter != null)
|
||||
tokenCounter.transform.localPosition = new Vector3(333, 0, -450);
|
||||
|
||||
if (waveCounter != null)
|
||||
waveCounter.transform.localPosition = new Vector3(333, 0, -450);
|
||||
}
|
||||
|
||||
public void GameOverPos()
|
||||
@@ -33,6 +41,41 @@ namespace TNHQoLImprovements
|
||||
|
||||
if (tokenCounter != null)
|
||||
tokenCounter.transform.localPosition = new Vector3(250, 0, 0);
|
||||
|
||||
if (waveCounter != null)
|
||||
{
|
||||
waveCounter.gameObject.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0);
|
||||
waveCounter.transform.localPosition = new Vector3(0, 0, 140);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (InPlay.tnhManager.Phase == TNH_Phase.Dead)
|
||||
{
|
||||
if (tokenCounter != null)
|
||||
tokenCounter.SetActive(true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// we're in a hold; hide token count
|
||||
if(InPlay.tnhManager.Phase == TNH_Phase.Hold)
|
||||
{
|
||||
if (tokenCounter != null)
|
||||
tokenCounter.SetActive(false);
|
||||
|
||||
if (waveCounter != null)
|
||||
waveCounter.SetActive(true);
|
||||
}
|
||||
else // show token count
|
||||
{
|
||||
if (tokenCounter != null)
|
||||
tokenCounter.SetActive(true);
|
||||
|
||||
if (waveCounter != null)
|
||||
waveCounter.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,12 @@ namespace TNHQoLImprovements
|
||||
{
|
||||
public class TokenCounter : MonoBehaviour
|
||||
{
|
||||
private Text text;
|
||||
|
||||
void Start()
|
||||
{
|
||||
transform.localPosition = new Vector3(333, 0, -450);
|
||||
text = transform.GetChild(1).GetComponent<Text>();
|
||||
text.font = MeatKitPlugin.fontAgencyFB;
|
||||
|
||||
StartCoroutine(SetTokenImage());
|
||||
}
|
||||
@@ -18,7 +21,7 @@ namespace TNHQoLImprovements
|
||||
{
|
||||
int debug_iterations = 0;
|
||||
Sprite tokenSprite = null;
|
||||
while (tokenSprite == null) // END: loop until Token sprite is found
|
||||
while (tokenSprite == null) // loop until Token sprite is found
|
||||
{
|
||||
var obj = GameObject.Find("_TNH_ObjectConstructor(Clone)/_CanvasHolder/_UITest_Canvas/Icon_0/Cost_1/Image");
|
||||
if (obj != null)
|
||||
@@ -38,7 +41,7 @@ namespace TNHQoLImprovements
|
||||
void Update()
|
||||
{
|
||||
int tokens = InPlay.tnhManager.GetNumTokens();
|
||||
transform.GetChild(1).GetComponent<Text>().text = tokens.ToString();
|
||||
text.text = tokens.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,5 +29,7 @@ public class UIRingTimer : MonoBehaviour {
|
||||
|
||||
float amount = (endTime - Time.time) / length;
|
||||
ringImg.fillAmount = Mathf.Clamp01(amount);
|
||||
|
||||
transform.LookAt(MeatKitPlugin.playerCamera.transform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +1,38 @@
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
using FistVR;
|
||||
|
||||
namespace TNHQoLImprovements
|
||||
{
|
||||
public static class WavePatch
|
||||
{
|
||||
public static void Patch(Harmony harmony)
|
||||
{
|
||||
var original = typeof(TNH_Manager).GetMethod("HoldPointStarted", BindingFlags.Public | BindingFlags.Instance);
|
||||
var patch = typeof(WavePatch).GetMethod("OnHoldStart", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
harmony.Patch(original, postfix: new HarmonyMethod(patch));
|
||||
}
|
||||
|
||||
private static void OnHoldStart(TNH_HoldPoint p)
|
||||
{
|
||||
WaveCounter.WaveStarted.Invoke(p);
|
||||
}
|
||||
}
|
||||
|
||||
public class WaveCounter : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public class WaveStartedEvent : UnityEvent<TNH_HoldPoint> { }
|
||||
public static WaveStartedEvent WaveStarted = new WaveStartedEvent();
|
||||
private TNH_HoldPoint curHoldPoint;
|
||||
private Traverse<int> trCurPhaseIdx;
|
||||
private Traverse<int> trMaxPhases;
|
||||
|
||||
private bool initialized = false;
|
||||
|
||||
private TNH_HoldPoint holdPoint;
|
||||
private Text text;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Init(TNH_Manager manager)
|
||||
{
|
||||
holdPoint = manager.m_curHoldPoint;
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
text = transform.GetChild(1).GetComponent<Text>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (!initialized)
|
||||
return;
|
||||
}
|
||||
if (InPlay.tnhManager.Phase != TNH_Phase.Hold)
|
||||
return;
|
||||
|
||||
if(!ReferenceEquals(curHoldPoint, InPlay.tnhManager.m_curHoldPoint))
|
||||
{
|
||||
Debug.Log("Hold point updated!");
|
||||
curHoldPoint = InPlay.tnhManager.m_curHoldPoint;
|
||||
trCurPhaseIdx = Traverse.Create(curHoldPoint).Field<int>("m_phaseIndex");
|
||||
trMaxPhases = Traverse.Create(curHoldPoint).Field<int>("m_maxPhases");
|
||||
}
|
||||
text.text = string.Format("{0} / {1}", trCurPhaseIdx.Value, trMaxPhases.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user