diff --git a/Assets/Prefabs/SampleChild.prefab b/Assets/Prefabs/SampleChild.prefab index 67afde0..010950d 100644 --- a/Assets/Prefabs/SampleChild.prefab +++ b/Assets/Prefabs/SampleChild.prefab @@ -219,8 +219,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - - {fileID: 2035964200443923097} - {fileID: 2762027888324636750} + - {fileID: 2035964200443923097} m_Father: {fileID: 7011418079103154681} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} @@ -452,6 +452,7 @@ MonoBehaviour: m_EditorClassIdentifier: k__BackingField: {fileID: 3009414327569646558} k__BackingField: {fileID: 7011418079103154681} + k__BackingField: {fileID: 2035964200443923097} k__BackingField: {fileID: 2038821404454815492} --- !u!114 &3265764588146964386 MonoBehaviour: diff --git a/Assets/Scripts/WindowComponents.cs b/Assets/Scripts/WindowComponents.cs index 5a5e227..fce4293 100644 --- a/Assets/Scripts/WindowComponents.cs +++ b/Assets/Scripts/WindowComponents.cs @@ -8,6 +8,7 @@ namespace InterfaceOff { [field: SerializeField] public Image WindowImage { get; private set; } [field: SerializeField] public RectTransform RectTransform { get; private set; } + [field: SerializeField] public RectTransform CloseButtonRectTransform { get; private set; } [field: SerializeField] public Text InfoText { get; private set; } public Rect Rect => new diff --git a/Assets/Scripts/Windows/TrollWindow.cs b/Assets/Scripts/Windows/TrollWindow.cs new file mode 100644 index 0000000..79067d9 --- /dev/null +++ b/Assets/Scripts/Windows/TrollWindow.cs @@ -0,0 +1,30 @@ +using UnityEngine; + +namespace InterfaceOff +{ + public class TrollWindow : WindowBase + { + private int m_Health = int.MaxValue; + + public override void OnWindowInstantiation() + { + m_Health = Random.Range(2, 6); + Components.InfoText.text = "TROLL"; + } + + public override void OnWindowClicked() + { + /* Decreases health and destroys if at 0 */ + m_Health--; + if (m_Health <= 0) + { + Destroy(gameObject); + return; + } + + /* If not at zero randomly moves the close button */ + float randX = Random.Range(-80, 80); + Components.CloseButtonRectTransform.anchoredPosition = new Vector2(randX, 0); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Windows/TrollWindow.cs.meta b/Assets/Scripts/Windows/TrollWindow.cs.meta new file mode 100644 index 0000000..2d662f0 --- /dev/null +++ b/Assets/Scripts/Windows/TrollWindow.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bdeff80fcdb04744b0f3151d7370e6f1 +timeCreated: 1768419826 \ No newline at end of file