net.dreditor.presents.ui 0.0.0-stage → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CharacterReactionIndicator.cs +181 -0
- package/CharacterReactionIndicator.cs.meta +11 -0
- package/DREditor.Presents.UI.asmdef +25 -0
- package/DREditor.Presents.UI.asmdef.meta +7 -0
- package/DialoguePresentResolver.cs +119 -0
- package/DialoguePresentResolver.cs.meta +11 -0
- package/GivePresentEventHandler.cs +68 -0
- package/GivePresentEventHandler.cs.meta +11 -0
- package/MenuPresentSelectEvaluator.cs +95 -0
- package/MenuPresentSelectEvaluator.cs.meta +11 -0
- package/PresentDisplayer.cs +154 -0
- package/PresentDisplayer.cs.meta +11 -0
- package/PresentIconSlot.cs +144 -0
- package/PresentIconSlot.cs.meta +11 -0
- package/PresentIconSpawner.cs +43 -0
- package/PresentIconSpawner.cs.meta +11 -0
- package/PresentResolver.cs +20 -0
- package/PresentResolver.cs.meta +11 -0
- package/PresentSelectEvaluator.cs +168 -0
- package/PresentSelectEvaluator.cs.meta +11 -0
- package/PresentUI.cs +281 -0
- package/PresentUI.cs.meta +11 -0
- package/ReactionIndicatorSpawner.cs +58 -0
- package/ReactionIndicatorSpawner.cs.meta +11 -0
- package/Samples/Animations/Present_UI.controller +220 -0
- package/Samples/Animations/Present_UI.controller.meta +8 -0
- package/Samples/Animations/UI_Pr_HideAnim.anim +232 -0
- package/Samples/Animations/UI_Pr_HideAnim.anim.meta +8 -0
- package/Samples/Animations.meta +8 -0
- package/Samples/DRE_Present_UI.unity +381 -0
- package/Samples/DRE_Present_UI.unity.meta +7 -0
- package/Samples/Present_Displayer_UI_ETemplate.prefab +900 -0
- package/Samples/Present_Displayer_UI_ETemplate.prefab.meta +7 -0
- package/Samples/Present_Icon_Slot_ETemplate.prefab +351 -0
- package/Samples/Present_Icon_Slot_ETemplate.prefab.meta +7 -0
- package/Samples/Present_UI_Canvas_Shell.prefab +1523 -0
- package/Samples/Present_UI_Canvas_Shell.prefab.meta +7 -0
- package/Samples/Present_UI_Canvas_Template.prefab +11800 -0
- package/Samples/Present_UI_Canvas_Template.prefab.meta +7 -0
- package/Samples/Present_UI_Character_Grid_ETemplate.prefab +154 -0
- package/Samples/Present_UI_Character_Grid_ETemplate.prefab.meta +7 -0
- package/Samples/Present_UI_Reaction_Indicator_ETemplate.prefab +95 -0
- package/Samples/Present_UI_Reaction_Indicator_ETemplate.prefab.meta +7 -0
- package/Samples/Present_UI_Slots_ETemplate.prefab +79 -0
- package/Samples/Present_UI_Slots_ETemplate.prefab.meta +7 -0
- package/Samples.meta +8 -0
- package/package.json +42 -6
- package/package.json.meta +7 -0
- package/README.md +0 -3
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Services;
|
|
3
|
+
using DREditor.UI;
|
|
4
|
+
using System.Globalization;
|
|
5
|
+
using TMPro;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
|
|
8
|
+
namespace DREditor.Presents.UI
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
///
|
|
12
|
+
/// </summary>
|
|
13
|
+
[ClassHeader("")]
|
|
14
|
+
public class PresentDisplayer : SelectedItemDisplayer
|
|
15
|
+
{
|
|
16
|
+
/// <summary>
|
|
17
|
+
///
|
|
18
|
+
/// </summary>
|
|
19
|
+
[Header("")]
|
|
20
|
+
[Divider]
|
|
21
|
+
[Tooltip("")]
|
|
22
|
+
[SerializeField] protected PresentDatabase presentDatabase = null;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
[Header("")]
|
|
29
|
+
[Divider]
|
|
30
|
+
[Tooltip("")]
|
|
31
|
+
[SerializeField] protected TextMeshProUGUI percent = null;
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
///
|
|
35
|
+
/// </summary>
|
|
36
|
+
[Tooltip("")]
|
|
37
|
+
[SerializeField] protected TextMeshProUGUI id = null;
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
///
|
|
41
|
+
/// </summary>
|
|
42
|
+
[Tooltip("")]
|
|
43
|
+
[SerializeField] protected TextMeshProUGUI named = null;
|
|
44
|
+
|
|
45
|
+
/// <summary>
|
|
46
|
+
///
|
|
47
|
+
/// </summary>
|
|
48
|
+
[Tooltip("")]
|
|
49
|
+
[SerializeField] protected TextMeshProUGUI amount = null;
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
///
|
|
53
|
+
/// </summary>
|
|
54
|
+
[Tooltip("")]
|
|
55
|
+
[SerializeField] protected TextMeshProUGUI description = null;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
///
|
|
60
|
+
/// </summary>
|
|
61
|
+
[Header("")]
|
|
62
|
+
[Divider]
|
|
63
|
+
[Tooltip("")]
|
|
64
|
+
[SerializeField] protected string amountPrefix = "X ";
|
|
65
|
+
|
|
66
|
+
/// <summary>
|
|
67
|
+
///
|
|
68
|
+
/// </summary>
|
|
69
|
+
[Tooltip("")]
|
|
70
|
+
[SerializeField] protected string amountFormat = "D3";
|
|
71
|
+
|
|
72
|
+
/// <summary>
|
|
73
|
+
///
|
|
74
|
+
/// </summary>
|
|
75
|
+
[Tooltip("")]
|
|
76
|
+
[SerializeField] protected string idPrefix = "NO. ";
|
|
77
|
+
|
|
78
|
+
/// <summary>
|
|
79
|
+
///
|
|
80
|
+
/// </summary>
|
|
81
|
+
[Tooltip("")]
|
|
82
|
+
[SerializeField] protected string unknownDataText = "???";
|
|
83
|
+
|
|
84
|
+
/// <summary>
|
|
85
|
+
///
|
|
86
|
+
/// </summary>
|
|
87
|
+
[Tooltip("")]
|
|
88
|
+
[SerializeField] protected string percentFormat = "000";
|
|
89
|
+
|
|
90
|
+
/// <summary>
|
|
91
|
+
///
|
|
92
|
+
/// </summary>
|
|
93
|
+
[Tooltip("")]
|
|
94
|
+
[SerializeField] protected bool roundPercent = true;
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
/// <inheritdoc/>
|
|
98
|
+
public override void DisplaySelectedItem(int index)
|
|
99
|
+
{
|
|
100
|
+
Present present = presentDatabase.presents[index];
|
|
101
|
+
|
|
102
|
+
IAmountablePresent presentData = ServiceLocator.GetService<IPresentManager>().Get<IAmountablePresent>(present.ID);
|
|
103
|
+
|
|
104
|
+
percent.text = GetPercent(ServiceLocator.GetService<IPresentManager>().Count, presentDatabase.presents.Count);
|
|
105
|
+
|
|
106
|
+
id.text = GetFormattedAmount(idPrefix, present.ID, amountFormat);
|
|
107
|
+
|
|
108
|
+
if (presentData != null)
|
|
109
|
+
{
|
|
110
|
+
amount.text = GetFormattedAmount(amountPrefix, presentData.Amount, amountFormat);
|
|
111
|
+
|
|
112
|
+
named.text = present.DisplayName;
|
|
113
|
+
|
|
114
|
+
description.text = present.Description;
|
|
115
|
+
}
|
|
116
|
+
else
|
|
117
|
+
{
|
|
118
|
+
amount.text = unknownDataText;
|
|
119
|
+
|
|
120
|
+
named.text = unknownDataText;
|
|
121
|
+
|
|
122
|
+
description.text = unknownDataText;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/// <summary>
|
|
127
|
+
///
|
|
128
|
+
/// </summary>
|
|
129
|
+
/// <param name="prefix"></param>
|
|
130
|
+
/// <param name="value"></param>
|
|
131
|
+
/// <param name="format"></param>
|
|
132
|
+
/// <returns></returns>
|
|
133
|
+
protected virtual string GetFormattedAmount(string prefix, int value, string format)
|
|
134
|
+
=> $"{prefix}{value.ToString(format)}";
|
|
135
|
+
|
|
136
|
+
/// <summary>
|
|
137
|
+
///
|
|
138
|
+
/// </summary>
|
|
139
|
+
/// <param name="part"></param>
|
|
140
|
+
/// <param name="whole"></param>
|
|
141
|
+
/// <returns></returns>
|
|
142
|
+
protected virtual string GetPercent(int part, int whole)
|
|
143
|
+
{
|
|
144
|
+
float percent;
|
|
145
|
+
|
|
146
|
+
percent = (float)((double)part / whole * 100);
|
|
147
|
+
|
|
148
|
+
if (roundPercent)
|
|
149
|
+
percent = (float)Mathf.Round((float)percent);
|
|
150
|
+
|
|
151
|
+
return percent.ToString(percentFormat, CultureInfo.InvariantCulture) + " %";
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Processables;
|
|
3
|
+
using DREditor.Services;
|
|
4
|
+
using DREditor.UI;
|
|
5
|
+
using TMPro;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
using UnityEngine.UI;
|
|
8
|
+
|
|
9
|
+
namespace DREditor.Presents.UI
|
|
10
|
+
{
|
|
11
|
+
/// <summary>
|
|
12
|
+
///
|
|
13
|
+
/// </summary>
|
|
14
|
+
[ClassHeader(nameof(IGridIconSlot) +
|
|
15
|
+
"\n\n")]
|
|
16
|
+
public class PresentIconSlot : MonoBehaviour, IGridIconSlot
|
|
17
|
+
{
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
[Tooltip("")]
|
|
22
|
+
[SerializeField] protected PresentDatabase presentDatabase = null;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
[Header("")]
|
|
29
|
+
[Divider]
|
|
30
|
+
[Tooltip("")]
|
|
31
|
+
[SerializeField] protected Image presentIcon = null;
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
///
|
|
35
|
+
/// </summary>
|
|
36
|
+
[Tooltip("")]
|
|
37
|
+
[SerializeField] protected Sprite undiscoveredIcon;
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
///
|
|
41
|
+
/// </summary>
|
|
42
|
+
[Tooltip("")]
|
|
43
|
+
[SerializeField] protected GameObject newIcon = null;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/// <summary>
|
|
47
|
+
///
|
|
48
|
+
/// </summary>
|
|
49
|
+
[Header("")]
|
|
50
|
+
[Divider]
|
|
51
|
+
[Tooltip("")]
|
|
52
|
+
[SerializeField] protected Color selectedColor = Color.white;
|
|
53
|
+
|
|
54
|
+
/// <summary>
|
|
55
|
+
///
|
|
56
|
+
/// </summary>
|
|
57
|
+
[Tooltip("")]
|
|
58
|
+
[SerializeField] protected Color unselectedColor = Color.gray;
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
/// <summary>
|
|
62
|
+
///
|
|
63
|
+
/// </summary>
|
|
64
|
+
[Header("")]
|
|
65
|
+
[Divider]
|
|
66
|
+
[Tooltip("")]
|
|
67
|
+
[SerializeField] protected TextMeshProUGUI amountText = null;
|
|
68
|
+
|
|
69
|
+
/// <summary>
|
|
70
|
+
///
|
|
71
|
+
/// </summary>
|
|
72
|
+
[Tooltip("")]
|
|
73
|
+
[SerializeField] protected string amountPrefix = "X ";
|
|
74
|
+
|
|
75
|
+
/// <summary>
|
|
76
|
+
///
|
|
77
|
+
/// </summary>
|
|
78
|
+
[Tooltip("")]
|
|
79
|
+
[SerializeField] protected string amountFormat = "D3";
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
/// <inheritdoc/>
|
|
83
|
+
public virtual void UpdateSlot(int globalIndex, bool selected)
|
|
84
|
+
{
|
|
85
|
+
Present entry = presentDatabase.presents[globalIndex];
|
|
86
|
+
|
|
87
|
+
var pres = ServiceLocator.GetService<IPresentManager>().Get<IIdentifiable>(entry.ID);
|
|
88
|
+
|
|
89
|
+
if (selected && pres is INewPresentObtained obtainable && obtainable.JustObtained)
|
|
90
|
+
obtainable.NoLongerNew();
|
|
91
|
+
|
|
92
|
+
presentIcon.gameObject.SetActive(true);
|
|
93
|
+
|
|
94
|
+
if (selected)
|
|
95
|
+
presentIcon.color = selectedColor;
|
|
96
|
+
else
|
|
97
|
+
presentIcon.color = unselectedColor;
|
|
98
|
+
|
|
99
|
+
UpdateIcon(entry, pres);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// <summary>
|
|
103
|
+
///
|
|
104
|
+
/// </summary>
|
|
105
|
+
/// <param name="entry"></param>
|
|
106
|
+
/// <param name="presentData"></param>
|
|
107
|
+
protected virtual void UpdateIcon(Present entry, IIdentifiable presentData)
|
|
108
|
+
{
|
|
109
|
+
if (presentData != null)
|
|
110
|
+
{
|
|
111
|
+
presentIcon.sprite = entry.Image;
|
|
112
|
+
|
|
113
|
+
if (newIcon != null && presentData is INewPresentObtained obtainable)
|
|
114
|
+
newIcon.SetActive(obtainable.JustObtained);
|
|
115
|
+
|
|
116
|
+
if (presentData is IAmountablePresent amountable)
|
|
117
|
+
amountText.text = $"{amountPrefix} {amountable.Amount.ToString(amountFormat)}";
|
|
118
|
+
}
|
|
119
|
+
else
|
|
120
|
+
{
|
|
121
|
+
presentIcon.sprite = undiscoveredIcon;
|
|
122
|
+
|
|
123
|
+
if (newIcon != null)
|
|
124
|
+
newIcon.SetActive(false);
|
|
125
|
+
|
|
126
|
+
amountText.text = string.Empty;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
/// <inheritdoc/>
|
|
132
|
+
public virtual void ClearSlotState()
|
|
133
|
+
{
|
|
134
|
+
presentIcon.gameObject.SetActive(false);
|
|
135
|
+
|
|
136
|
+
presentIcon.sprite = undiscoveredIcon;
|
|
137
|
+
|
|
138
|
+
if (newIcon != null)
|
|
139
|
+
newIcon.SetActive(false);
|
|
140
|
+
|
|
141
|
+
amountText.text = string.Empty;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace DREditor.Presents.UI
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
///
|
|
8
|
+
/// </summary>
|
|
9
|
+
[ClassHeader("")]
|
|
10
|
+
public class PresentIconSpawner : MonoBehaviour
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
[Tooltip("")]
|
|
16
|
+
[SerializeField] protected GameObject presentIconPrefab;
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
[Tooltip("")]
|
|
22
|
+
[SerializeField] protected int spawnAmount = 32;
|
|
23
|
+
|
|
24
|
+
#if UNITY_EDITOR
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
[ContextMenu("Spawn Icons")]
|
|
29
|
+
public void SpawnIcons()
|
|
30
|
+
{
|
|
31
|
+
if (presentIconPrefab == null)
|
|
32
|
+
{
|
|
33
|
+
UnityEngine.Debug.LogWarning("ALERT: The prefab field must be filled out!");
|
|
34
|
+
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (int i = 0; i < spawnAmount; i++)
|
|
39
|
+
UnityEditor.PrefabUtility.InstantiatePrefab(presentIconPrefab, transform);
|
|
40
|
+
}
|
|
41
|
+
#endif
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System.Collections;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace DREditor.Presents.UI
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
///
|
|
9
|
+
/// </summary>
|
|
10
|
+
public abstract class PresentResolver : MonoBehaviour
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
/// <param name="gavePresent"></param>
|
|
16
|
+
/// <param name="selectedPresentIndex"></param>
|
|
17
|
+
/// <returns></returns>
|
|
18
|
+
public abstract IEnumerator ResolvePresentSelection(bool gavePresent, int selectedPresentIndex);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Services;
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using UnityEngine.Events;
|
|
7
|
+
using UnityEngine.InputSystem;
|
|
8
|
+
using static UnityEngine.InputSystem.InputAction;
|
|
9
|
+
|
|
10
|
+
namespace DREditor.Presents.UI
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
public abstract class PresentSelectEvaluator : MonoBehaviour
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[Tooltip("")]
|
|
21
|
+
[SerializeField] protected InputActionReference submit = null;
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
[Tooltip("")]
|
|
27
|
+
[SerializeField] protected PresentDatabase presentDatabase = null;
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
[Tooltip("")]
|
|
33
|
+
[SerializeField] protected PresentResolver presentResolver = null;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
[Header("")]
|
|
37
|
+
public UnityEvent onGavePresentSelected;
|
|
38
|
+
|
|
39
|
+
[Header("")]
|
|
40
|
+
public UnityEvent onDidntGivePresentSelected;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
///
|
|
45
|
+
/// </summary>
|
|
46
|
+
public event Action OnChoiceMenuStarted;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
/// <summary>
|
|
50
|
+
///
|
|
51
|
+
/// </summary>
|
|
52
|
+
protected bool gavePresent = false;
|
|
53
|
+
|
|
54
|
+
/// <summary>
|
|
55
|
+
///
|
|
56
|
+
/// </summary>
|
|
57
|
+
protected int selectedPresentIndex = -1;
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/// <summary>
|
|
61
|
+
///
|
|
62
|
+
/// </summary>
|
|
63
|
+
/// <param name="selectedPresentIndex"></param>
|
|
64
|
+
public virtual void UpdateSelectedPresentIndex(int selectedPresentIndex) => this.selectedPresentIndex = selectedPresentIndex;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
///
|
|
69
|
+
/// </summary>
|
|
70
|
+
protected abstract void OnEnable();
|
|
71
|
+
|
|
72
|
+
/// <summary>
|
|
73
|
+
///
|
|
74
|
+
/// </summary>
|
|
75
|
+
protected abstract void OnDisable();
|
|
76
|
+
|
|
77
|
+
/// <summary>
|
|
78
|
+
///
|
|
79
|
+
/// </summary>
|
|
80
|
+
protected virtual void OnChoiceMenuStart() => OnChoiceMenuStarted?.Invoke();
|
|
81
|
+
|
|
82
|
+
/// <summary>
|
|
83
|
+
///
|
|
84
|
+
/// </summary>
|
|
85
|
+
public virtual void SubscribeCheckPresentSelect()
|
|
86
|
+
=> submit.action.performed += CheckPresentSelection;
|
|
87
|
+
|
|
88
|
+
/// <summary>
|
|
89
|
+
///
|
|
90
|
+
/// </summary>
|
|
91
|
+
public virtual void UnsubscribeCheckPresentSelect()
|
|
92
|
+
=> submit.action.performed -= CheckPresentSelection;
|
|
93
|
+
|
|
94
|
+
/// <summary>
|
|
95
|
+
///
|
|
96
|
+
/// </summary>
|
|
97
|
+
/// <param name="ctx"></param>
|
|
98
|
+
protected virtual void CheckPresentSelection(CallbackContext ctx)
|
|
99
|
+
{
|
|
100
|
+
if (SelectedPresentIsValid())
|
|
101
|
+
{
|
|
102
|
+
submit.action.performed -= CheckPresentSelection;
|
|
103
|
+
|
|
104
|
+
submit.action.performed += EvaluatePresentChoice;
|
|
105
|
+
|
|
106
|
+
OnSelectedValidPresent();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/// <summary>
|
|
111
|
+
///
|
|
112
|
+
/// </summary>
|
|
113
|
+
protected abstract void OnSelectedValidPresent();
|
|
114
|
+
|
|
115
|
+
/// <summary>
|
|
116
|
+
///
|
|
117
|
+
/// </summary>
|
|
118
|
+
/// <returns></returns>
|
|
119
|
+
protected virtual bool SelectedPresentIsValid()
|
|
120
|
+
{
|
|
121
|
+
if (presentDatabase.presents.Count == 0)
|
|
122
|
+
return false;
|
|
123
|
+
|
|
124
|
+
Present present = presentDatabase.presents[selectedPresentIndex];
|
|
125
|
+
|
|
126
|
+
IAmountablePresent presentData = ServiceLocator.GetService<IPresentManager>().Get<IAmountablePresent>(present.ID);
|
|
127
|
+
|
|
128
|
+
return present != null && presentData != null && presentData.Amount > 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/// <summary>
|
|
132
|
+
///
|
|
133
|
+
/// </summary>
|
|
134
|
+
/// <param name="ctx"></param>
|
|
135
|
+
protected virtual void EvaluatePresentChoice(CallbackContext ctx)
|
|
136
|
+
=> submit.action.performed -= EvaluatePresentChoice;
|
|
137
|
+
|
|
138
|
+
/// <summary>
|
|
139
|
+
///
|
|
140
|
+
/// </summary>
|
|
141
|
+
protected virtual void OnGivePresentSelected()
|
|
142
|
+
{
|
|
143
|
+
gavePresent = selectedPresentIndex < presentDatabase.presents.Count && presentDatabase.presents[selectedPresentIndex] != null;
|
|
144
|
+
|
|
145
|
+
onGavePresentSelected?.Invoke();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/// <summary>
|
|
149
|
+
///
|
|
150
|
+
/// </summary>
|
|
151
|
+
protected virtual void OnDontGivePresentSelected() => onDidntGivePresentSelected?.Invoke();
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
/// <summary>
|
|
155
|
+
///
|
|
156
|
+
/// </summary>
|
|
157
|
+
/// <param name="selectedPresentIndex"></param>
|
|
158
|
+
/// <returns></returns>
|
|
159
|
+
public virtual IEnumerator HandlePresentSelection(int selectedPresentIndex)
|
|
160
|
+
{
|
|
161
|
+
UpdateSelectedPresentIndex(selectedPresentIndex);
|
|
162
|
+
|
|
163
|
+
yield return presentResolver.ResolvePresentSelection(gavePresent, selectedPresentIndex);
|
|
164
|
+
|
|
165
|
+
gavePresent = false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|