Organised fruit
This commit is contained in:
@@ -8,7 +8,7 @@ Material:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
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_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
@@ -88,6 +88,7 @@ Material:
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BlendOp: 0
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
@@ -106,6 +107,7 @@ Material:
|
||||
- _Parallax: 0.005
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _SampleGI: 0
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
@@ -116,8 +118,8 @@ Material:
|
||||
- _XRMotionVectorsPass: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.30980393, g: 0.19607843, b: 0.10980392, a: 1}
|
||||
- _Color: {r: 0.3098039, g: 0.19607839, b: 0.10980389, a: 1}
|
||||
- _BaseColor: {r: 0.509434, g: 0.29217535, b: 0.1273585, a: 0.3137255}
|
||||
- _Color: {r: 0.509434, g: 0.29217532, b: 0.12735847, a: 0.3137255}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,11 @@ namespace Fruitomation.UI
|
||||
{
|
||||
public class BasicUpgradeButton : MonoBehaviour
|
||||
{
|
||||
[Serializable] private class LineInfo
|
||||
{
|
||||
public RectTransform[] LinePoints;
|
||||
}
|
||||
|
||||
private enum UpgradeState
|
||||
{
|
||||
Unlocked,
|
||||
@@ -20,12 +25,16 @@ namespace Fruitomation.UI
|
||||
[Header("Settings")]
|
||||
[SerializeField] private BasicUpgrade Upgrade;
|
||||
[SerializeField] private int UpgradeCost;
|
||||
[SerializeField] private bool DrawDefaultLines;
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField] private BasicUpgradeButton[] RequiredUpgrades;
|
||||
[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 Button AttachedButton;
|
||||
@@ -36,15 +45,14 @@ namespace Fruitomation.UI
|
||||
AttachedText = gameObject.GetComponentInChildren<Text>();
|
||||
AttachedButton = GetComponent<Button>();
|
||||
|
||||
AttachedButton.onClick.AddListener(() =>
|
||||
{
|
||||
UpgradeManager.Unlock(Upgrade);
|
||||
});
|
||||
AttachedButton.onClick.AddListener(() => { UpgradeManager.Unlock(Upgrade); });
|
||||
|
||||
/* Stops null reference */
|
||||
RequiredUpgrades ??= Array.Empty<BasicUpgradeButton>();
|
||||
|
||||
List<(LineRenderer, BasicUpgradeButton)> lines = new();
|
||||
List<(LineRenderer, BasicUpgradeButton, LineInfo)> lines = new();
|
||||
if (DrawDefaultLines)
|
||||
{
|
||||
foreach (BasicUpgradeButton required in RequiredUpgrades)
|
||||
{
|
||||
GameObject go = new("LineRenderer(Script Spawned)");
|
||||
@@ -57,7 +65,25 @@ namespace Fruitomation.UI
|
||||
lr.material = LineMaterial;
|
||||
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();
|
||||
}
|
||||
@@ -72,12 +98,26 @@ namespace Fruitomation.UI
|
||||
|
||||
private void Update()
|
||||
{
|
||||
foreach ((LineRenderer lr, BasicUpgradeButton button) in UpgradeLines)
|
||||
foreach ((LineRenderer lr, BasicUpgradeButton button, LineInfo info) in UpgradeLines)
|
||||
{
|
||||
if (DrawDefaultLines)
|
||||
{
|
||||
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))
|
||||
{
|
||||
State = UpgradeState.Unlocked;
|
||||
|
||||
Reference in New Issue
Block a user