using Moonlit.Utils; using UnityEngine; namespace Moonlit.IceFishing { public class HoleView : MonoBehaviour { public GameObject IcePlane; public GameObject WaterPlane; public GameObject Tube; public GameObject TubeModel; public GameObject NormalMask; public GameObject UnderwaterMask; public GameObject FakeUnderwaterMask; public ParticleSystem Particles; [HideInInspector] public GameObject DrilledSnow; [HideInInspector] public float IcePlaneDepth; [HideInInspector] public float WaterPlaneDepth; private void Awake() { IcePlaneDepth = IcePlane.transform.localPosition.y; WaterPlaneDepth = WaterPlane.transform.localPosition.y; DrilledSnow = Object.Instantiate(Singleton.Instance.GetRandomSnowPrefab()); DrilledSnow.transform.SetParent(base.transform, false); if ((bool)Singleton.Instance.iceMaterial) { DrilledSnow.GetComponent().material = Singleton.Instance.iceMaterial; } } public void SetState(HoleData data) { switch (data.State) { case HoleData.HoleState.Drilling: IcePlane.SetActive(true); WaterPlane.SetActive(false); DrilledSnow.SetActive(false); SetDepth(data.Depth); break; case HoleData.HoleState.Finished: IcePlane.SetActive(false); WaterPlane.SetActive(true); DrilledSnow.SetActive(true); SetDepth(data.Depth); SetWaterLevel(0f); break; } } public void SetDepth(float depth) { DrilledSnow.transform.localScale = new Vector3(1f, 1f, depth * 0.8f); Tube.transform.localScale = new Vector3(1f, depth, 1f); IcePlane.transform.localPosition = new Vector3(0f, IcePlaneDepth - depth, 0f); UnderwaterMask.transform.localPosition = new Vector3(UnderwaterMask.transform.localPosition.x, 0f - depth, UnderwaterMask.transform.localPosition.z); FakeUnderwaterMask.transform.localPosition = UnderwaterMask.transform.localPosition - Vector3.up * 0.01f; } public void SetWaterLevel(float depth) { WaterPlane.transform.localPosition = new Vector3(0f, WaterPlaneDepth - depth, 0f); } } }