Organised fruit
This commit is contained in:
@@ -8,7 +8,7 @@ Material:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: UI-BrownMat
|
m_Name: UI-BrownMat
|
||||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
|
||||||
m_Parent: {fileID: 0}
|
m_Parent: {fileID: 0}
|
||||||
m_ModifiedSerializedProperties: 0
|
m_ModifiedSerializedProperties: 0
|
||||||
m_ValidKeywords: []
|
m_ValidKeywords: []
|
||||||
@@ -88,6 +88,7 @@ Material:
|
|||||||
- _AlphaToMask: 0
|
- _AlphaToMask: 0
|
||||||
- _Blend: 0
|
- _Blend: 0
|
||||||
- _BlendModePreserveSpecular: 1
|
- _BlendModePreserveSpecular: 1
|
||||||
|
- _BlendOp: 0
|
||||||
- _BumpScale: 1
|
- _BumpScale: 1
|
||||||
- _ClearCoatMask: 0
|
- _ClearCoatMask: 0
|
||||||
- _ClearCoatSmoothness: 0
|
- _ClearCoatSmoothness: 0
|
||||||
@@ -106,6 +107,7 @@ Material:
|
|||||||
- _Parallax: 0.005
|
- _Parallax: 0.005
|
||||||
- _QueueOffset: 0
|
- _QueueOffset: 0
|
||||||
- _ReceiveShadows: 1
|
- _ReceiveShadows: 1
|
||||||
|
- _SampleGI: 0
|
||||||
- _Smoothness: 0.5
|
- _Smoothness: 0.5
|
||||||
- _SmoothnessTextureChannel: 0
|
- _SmoothnessTextureChannel: 0
|
||||||
- _SpecularHighlights: 1
|
- _SpecularHighlights: 1
|
||||||
@@ -116,8 +118,8 @@ Material:
|
|||||||
- _XRMotionVectorsPass: 1
|
- _XRMotionVectorsPass: 1
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 0.30980393, g: 0.19607843, b: 0.10980392, a: 1}
|
- _BaseColor: {r: 0.509434, g: 0.29217535, b: 0.1273585, a: 0.3137255}
|
||||||
- _Color: {r: 0.3098039, g: 0.19607839, b: 0.10980389, a: 1}
|
- _Color: {r: 0.509434, g: 0.29217532, b: 0.12735847, a: 0.3137255}
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,11 @@ namespace Fruitomation.UI
|
|||||||
{
|
{
|
||||||
public class BasicUpgradeButton : MonoBehaviour
|
public class BasicUpgradeButton : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
[Serializable] private class LineInfo
|
||||||
|
{
|
||||||
|
public RectTransform[] LinePoints;
|
||||||
|
}
|
||||||
|
|
||||||
private enum UpgradeState
|
private enum UpgradeState
|
||||||
{
|
{
|
||||||
Unlocked,
|
Unlocked,
|
||||||
@@ -20,12 +25,16 @@ namespace Fruitomation.UI
|
|||||||
[Header("Settings")]
|
[Header("Settings")]
|
||||||
[SerializeField] private BasicUpgrade Upgrade;
|
[SerializeField] private BasicUpgrade Upgrade;
|
||||||
[SerializeField] private int UpgradeCost;
|
[SerializeField] private int UpgradeCost;
|
||||||
|
[SerializeField] private bool DrawDefaultLines;
|
||||||
|
|
||||||
[Header("References")]
|
[Header("References")]
|
||||||
[SerializeField] private BasicUpgradeButton[] RequiredUpgrades;
|
[SerializeField] private BasicUpgradeButton[] RequiredUpgrades;
|
||||||
[SerializeField] private Material LineMaterial;
|
[SerializeField] private Material LineMaterial;
|
||||||
|
|
||||||
private (LineRenderer, BasicUpgradeButton)[] UpgradeLines;
|
[Header("Lines")]
|
||||||
|
[SerializeField] private LineInfo[] Lines;
|
||||||
|
|
||||||
|
private (LineRenderer, BasicUpgradeButton, LineInfo)[] UpgradeLines;
|
||||||
|
|
||||||
private UpgradeState State = UpgradeState.Hidden;
|
private UpgradeState State = UpgradeState.Hidden;
|
||||||
private Button AttachedButton;
|
private Button AttachedButton;
|
||||||
@@ -36,28 +45,45 @@ namespace Fruitomation.UI
|
|||||||
AttachedText = gameObject.GetComponentInChildren<Text>();
|
AttachedText = gameObject.GetComponentInChildren<Text>();
|
||||||
AttachedButton = GetComponent<Button>();
|
AttachedButton = GetComponent<Button>();
|
||||||
|
|
||||||
AttachedButton.onClick.AddListener(() =>
|
AttachedButton.onClick.AddListener(() => { UpgradeManager.Unlock(Upgrade); });
|
||||||
{
|
|
||||||
UpgradeManager.Unlock(Upgrade);
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Stops null reference */
|
/* Stops null reference */
|
||||||
RequiredUpgrades ??= Array.Empty<BasicUpgradeButton>();
|
RequiredUpgrades ??= Array.Empty<BasicUpgradeButton>();
|
||||||
|
|
||||||
List<(LineRenderer, BasicUpgradeButton)> lines = new();
|
List<(LineRenderer, BasicUpgradeButton, LineInfo)> lines = new();
|
||||||
foreach (BasicUpgradeButton required in RequiredUpgrades)
|
if (DrawDefaultLines)
|
||||||
{
|
{
|
||||||
GameObject go = new("LineRenderer(Script Spawned)");
|
foreach (BasicUpgradeButton required in RequiredUpgrades)
|
||||||
go.transform.SetParent(transform);
|
{
|
||||||
|
GameObject go = new("LineRenderer(Script Spawned)");
|
||||||
|
go.transform.SetParent(transform);
|
||||||
|
|
||||||
RectTransform rt = go.AddComponent<RectTransform>();
|
RectTransform rt = go.AddComponent<RectTransform>();
|
||||||
rt.anchoredPosition = new Vector2();
|
rt.anchoredPosition = new Vector2();
|
||||||
|
|
||||||
LineRenderer lr = go.AddComponent<LineRenderer>();
|
LineRenderer lr = go.AddComponent<LineRenderer>();
|
||||||
lr.material = LineMaterial;
|
lr.material = LineMaterial;
|
||||||
lr.positionCount = 2;
|
lr.positionCount = 2;
|
||||||
|
|
||||||
lines.Add((lr, required));
|
lines.Add((lr, required, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (LineInfo line in Lines)
|
||||||
|
{
|
||||||
|
GameObject go = new("LineRenderer(Script Spawned)");
|
||||||
|
go.transform.SetParent(transform);
|
||||||
|
|
||||||
|
RectTransform rt = go.AddComponent<RectTransform>();
|
||||||
|
rt.anchoredPosition = new Vector2();
|
||||||
|
|
||||||
|
LineRenderer lr = go.AddComponent<LineRenderer>();
|
||||||
|
lr.material = LineMaterial;
|
||||||
|
|
||||||
|
lines.Add((lr, null, line));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
UpgradeLines = lines.ToArray();
|
UpgradeLines = lines.ToArray();
|
||||||
}
|
}
|
||||||
@@ -72,10 +98,24 @@ namespace Fruitomation.UI
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
foreach ((LineRenderer lr, BasicUpgradeButton button) in UpgradeLines)
|
foreach ((LineRenderer lr, BasicUpgradeButton button, LineInfo info) in UpgradeLines)
|
||||||
{
|
{
|
||||||
lr.SetPosition(0, transform.position);
|
if (DrawDefaultLines)
|
||||||
lr.SetPosition(1, button.transform.position);
|
{
|
||||||
|
lr.SetPosition(0, transform.position);
|
||||||
|
lr.SetPosition(1, button.transform.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lr.positionCount = info.LinePoints.Length;
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
foreach (RectTransform point in info.LinePoints)
|
||||||
|
{
|
||||||
|
lr.SetPosition(index++, point.position);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UpgradeManager.Is(Upgrade))
|
if (UpgradeManager.Is(Upgrade))
|
||||||
|
|||||||
Reference in New Issue
Block a user