Added a troll window with moving close button
This commit is contained in:
@@ -219,8 +219,8 @@ RectTransform:
|
|||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 2035964200443923097}
|
|
||||||
- {fileID: 2762027888324636750}
|
- {fileID: 2762027888324636750}
|
||||||
|
- {fileID: 2035964200443923097}
|
||||||
m_Father: {fileID: 7011418079103154681}
|
m_Father: {fileID: 7011418079103154681}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
@@ -452,6 +452,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
<WindowImage>k__BackingField: {fileID: 3009414327569646558}
|
<WindowImage>k__BackingField: {fileID: 3009414327569646558}
|
||||||
<RectTransform>k__BackingField: {fileID: 7011418079103154681}
|
<RectTransform>k__BackingField: {fileID: 7011418079103154681}
|
||||||
|
<CloseButtonRectTransform>k__BackingField: {fileID: 2035964200443923097}
|
||||||
<InfoText>k__BackingField: {fileID: 2038821404454815492}
|
<InfoText>k__BackingField: {fileID: 2038821404454815492}
|
||||||
--- !u!114 &3265764588146964386
|
--- !u!114 &3265764588146964386
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace InterfaceOff
|
|||||||
{
|
{
|
||||||
[field: SerializeField] public Image WindowImage { get; private set; }
|
[field: SerializeField] public Image WindowImage { get; private set; }
|
||||||
[field: SerializeField] public RectTransform RectTransform { 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; }
|
[field: SerializeField] public Text InfoText { get; private set; }
|
||||||
|
|
||||||
public Rect Rect => new
|
public Rect Rect => new
|
||||||
|
|||||||
30
Assets/Scripts/Windows/TrollWindow.cs
Normal file
30
Assets/Scripts/Windows/TrollWindow.cs
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Windows/TrollWindow.cs.meta
Normal file
3
Assets/Scripts/Windows/TrollWindow.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bdeff80fcdb04744b0f3151d7370e6f1
|
||||||
|
timeCreated: 1768419826
|
||||||
Reference in New Issue
Block a user