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.
Files changed (49) hide show
  1. package/CharacterReactionIndicator.cs +181 -0
  2. package/CharacterReactionIndicator.cs.meta +11 -0
  3. package/DREditor.Presents.UI.asmdef +25 -0
  4. package/DREditor.Presents.UI.asmdef.meta +7 -0
  5. package/DialoguePresentResolver.cs +119 -0
  6. package/DialoguePresentResolver.cs.meta +11 -0
  7. package/GivePresentEventHandler.cs +68 -0
  8. package/GivePresentEventHandler.cs.meta +11 -0
  9. package/MenuPresentSelectEvaluator.cs +95 -0
  10. package/MenuPresentSelectEvaluator.cs.meta +11 -0
  11. package/PresentDisplayer.cs +154 -0
  12. package/PresentDisplayer.cs.meta +11 -0
  13. package/PresentIconSlot.cs +144 -0
  14. package/PresentIconSlot.cs.meta +11 -0
  15. package/PresentIconSpawner.cs +43 -0
  16. package/PresentIconSpawner.cs.meta +11 -0
  17. package/PresentResolver.cs +20 -0
  18. package/PresentResolver.cs.meta +11 -0
  19. package/PresentSelectEvaluator.cs +168 -0
  20. package/PresentSelectEvaluator.cs.meta +11 -0
  21. package/PresentUI.cs +281 -0
  22. package/PresentUI.cs.meta +11 -0
  23. package/ReactionIndicatorSpawner.cs +58 -0
  24. package/ReactionIndicatorSpawner.cs.meta +11 -0
  25. package/Samples/Animations/Present_UI.controller +220 -0
  26. package/Samples/Animations/Present_UI.controller.meta +8 -0
  27. package/Samples/Animations/UI_Pr_HideAnim.anim +232 -0
  28. package/Samples/Animations/UI_Pr_HideAnim.anim.meta +8 -0
  29. package/Samples/Animations.meta +8 -0
  30. package/Samples/DRE_Present_UI.unity +381 -0
  31. package/Samples/DRE_Present_UI.unity.meta +7 -0
  32. package/Samples/Present_Displayer_UI_ETemplate.prefab +900 -0
  33. package/Samples/Present_Displayer_UI_ETemplate.prefab.meta +7 -0
  34. package/Samples/Present_Icon_Slot_ETemplate.prefab +351 -0
  35. package/Samples/Present_Icon_Slot_ETemplate.prefab.meta +7 -0
  36. package/Samples/Present_UI_Canvas_Shell.prefab +1523 -0
  37. package/Samples/Present_UI_Canvas_Shell.prefab.meta +7 -0
  38. package/Samples/Present_UI_Canvas_Template.prefab +11800 -0
  39. package/Samples/Present_UI_Canvas_Template.prefab.meta +7 -0
  40. package/Samples/Present_UI_Character_Grid_ETemplate.prefab +154 -0
  41. package/Samples/Present_UI_Character_Grid_ETemplate.prefab.meta +7 -0
  42. package/Samples/Present_UI_Reaction_Indicator_ETemplate.prefab +95 -0
  43. package/Samples/Present_UI_Reaction_Indicator_ETemplate.prefab.meta +7 -0
  44. package/Samples/Present_UI_Slots_ETemplate.prefab +79 -0
  45. package/Samples/Present_UI_Slots_ETemplate.prefab.meta +7 -0
  46. package/Samples.meta +8 -0
  47. package/package.json +42 -6
  48. package/package.json.meta +7 -0
  49. package/README.md +0 -3
@@ -0,0 +1,181 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.UI;
3
+ using System.Linq;
4
+ using UnityEngine;
5
+ using UnityEngine.UI;
6
+
7
+ namespace DREditor.Presents.UI
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ [ClassHeader(nameof(SelectedItemDisplayer) +
13
+ "\n\n")]
14
+ [RequireComponent(typeof(Image))]
15
+ public class CharacterReactionIndicator : SelectedItemDisplayer
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ [Tooltip("")]
21
+ [SerializeField] protected string characterName;
22
+
23
+ /// <summary>
24
+ ///
25
+ /// </summary>
26
+ [Tooltip("")]
27
+ [SerializeField] protected PresentDatabase presentDatabase = null;
28
+
29
+
30
+ /// <summary>
31
+ ///
32
+ /// </summary>
33
+ [Header("")]
34
+ [Divider]
35
+ [Tooltip("")]
36
+ [SerializeField] protected Image indicatorImage = null;
37
+
38
+ /// <summary>
39
+ ///
40
+ /// </summary>
41
+ [Tooltip("")]
42
+ [SerializeField] protected Sprite positiveArrow = null;
43
+
44
+ /// <summary>
45
+ ///
46
+ /// </summary>
47
+ [Tooltip("")]
48
+ [SerializeField] protected Sprite negativeArrow = null;
49
+
50
+
51
+ /// <summary>
52
+ ///
53
+ /// </summary>
54
+ protected Present currentPresent = null;
55
+
56
+ /// <summary>
57
+ ///
58
+ /// </summary>
59
+ protected PresentManager presentDataHandler = null;
60
+
61
+
62
+ /// <summary>
63
+ ///
64
+ /// </summary>
65
+ /// <param name="name"></param>
66
+ public virtual void InitializeName(string name) => characterName = name;
67
+
68
+ /// <inheritdoc/>
69
+ public override void DisplaySelectedItem(int globalIndex)
70
+ {
71
+ if (presentDatabase.presents[globalIndex] is Present present)
72
+ currentPresent = present;
73
+ else
74
+ currentPresent = null;
75
+
76
+ DisplayReaction();
77
+ }
78
+
79
+ /// <summary>
80
+ ///
81
+ /// </summary>
82
+ protected virtual void DisplayReaction()
83
+ {
84
+ if (CurrentPresentValid())
85
+ return;
86
+
87
+ IReactionEntry reaction = currentPresent.attributes
88
+ .OfType<StudentReactionCollection>()
89
+ .FirstOrDefault()
90
+ .GetReactionByName(characterName);
91
+
92
+ if (reaction != null)
93
+ {
94
+ switch (reaction.ReactionIndex)
95
+ {
96
+ case 0:
97
+ DisplayLove();
98
+ return;
99
+ case 1:
100
+ DisplayLike();
101
+ return;
102
+ case 2:
103
+ DisplayNeutral();
104
+ return;
105
+ case 3:
106
+ DisplayDislike();
107
+ return;
108
+ case 4:
109
+ DisplayHate();
110
+ return;
111
+ }
112
+ }
113
+ else
114
+ {
115
+ UnityEngine.Debug.LogWarning("Couldn't find Student Reaction for: " + characterName +
116
+ ". Make sure that the present has a reaction for the character and that the " +
117
+ "characterName property on this script is spelled correctly!");
118
+
119
+ OnPresentNotFound();
120
+ }
121
+ }
122
+
123
+ /// <summary>
124
+ ///
125
+ /// </summary>
126
+ /// <returns></returns>
127
+ protected virtual bool CurrentPresentValid()
128
+ {
129
+ if (presentDataHandler == null)
130
+ presentDataHandler = FindAnyObjectByType<PresentManager>();
131
+
132
+ bool result = presentDataHandler != null && !presentDataHandler.HadPresent(currentPresent.ID);
133
+
134
+ if (result || currentPresent == null)
135
+ OnPresentNotFound();
136
+
137
+ return result;
138
+ }
139
+
140
+ /// <summary>
141
+ ///
142
+ /// </summary>
143
+ protected virtual void OnPresentNotFound() => DisplayNeutral();
144
+
145
+
146
+ /// <summary>
147
+ ///
148
+ /// </summary>
149
+ protected virtual void DisplayLove()
150
+ {
151
+ indicatorImage.sprite = positiveArrow;
152
+
153
+ indicatorImage.enabled = true;
154
+ }
155
+
156
+ /// <summary>
157
+ ///
158
+ /// </summary>
159
+ protected virtual void DisplayLike() => DisplayLove();
160
+
161
+ /// <summary>
162
+ ///
163
+ /// </summary>
164
+ protected virtual void DisplayNeutral() => indicatorImage.enabled = false;
165
+
166
+ /// <summary>
167
+ ///
168
+ /// </summary>
169
+ protected virtual void DisplayDislike() => DisplayHate();
170
+
171
+ /// <summary>
172
+ ///
173
+ /// </summary>
174
+ protected virtual void DisplayHate()
175
+ {
176
+ indicatorImage.sprite = negativeArrow;
177
+
178
+ indicatorImage.enabled = true;
179
+ }
180
+ }
181
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: a8ea21c9e47b44f46b690da925add04c
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "DREditor.Presents.UI",
3
+ "rootNamespace": "",
4
+ "references": [
5
+ "DREditor",
6
+ "DREditor.UI",
7
+ "DREditor.UIHandling",
8
+ "Unity.TextMeshPro",
9
+ "Unity.InputSystem",
10
+ "DREditor.Input",
11
+ "DREditor.UI.Menus",
12
+ "DREditor.DialogueEventHandling",
13
+ "DREditor.Controls",
14
+ "DREditor.Presents"
15
+ ],
16
+ "includePlatforms": [],
17
+ "excludePlatforms": [],
18
+ "allowUnsafeCode": false,
19
+ "overrideReferences": false,
20
+ "precompiledReferences": [],
21
+ "autoReferenced": true,
22
+ "defineConstraints": [],
23
+ "versionDefines": [],
24
+ "noEngineReferences": false
25
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 14bf24eb8813c164f8d7ea4120abd7fb
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,119 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues;
3
+ using DREditor.Dialogues.Events;
4
+ using DREditor.EventObjects;
5
+ using DREditor.Services;
6
+ using System.Collections;
7
+ using UnityEngine;
8
+
9
+ namespace DREditor.Presents.UI
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ [ClassHeader(nameof(PresentResolver) +
15
+ "\n\n")]
16
+ public class DialoguePresentResolver : PresentResolver
17
+ {
18
+ /// <summary>
19
+ ///
20
+ /// </summary>
21
+ [Tooltip("")]
22
+ [SerializeField] protected PresentDatabase presentDatabase = null;
23
+
24
+ /// <summary>
25
+ ///
26
+ /// </summary>
27
+ [Tooltip("")]
28
+ [SerializeField] protected SceneEvent OnPlayerDidntGivePresentChoice = null;
29
+
30
+
31
+ /// <summary>
32
+ ///
33
+ /// </summary>
34
+ [Header("")]
35
+ [Divider]
36
+ [Tooltip("")]
37
+ [SerializeField] protected string callEvaluateReaction = "EvaluateReaction";
38
+
39
+
40
+ /// <summary>
41
+ ///
42
+ /// </summary>
43
+ [Header("")]
44
+ [Divider]
45
+ [Tooltip("")]
46
+ [SerializeField] protected SceneEvent hideFakePause = null;
47
+
48
+ /// <summary>
49
+ ///
50
+ /// </summary>
51
+ [Tooltip("")]
52
+ [SerializeField] protected float pauseMenuStartUpTime = 1.2f;
53
+
54
+ /// <summary>
55
+ ///
56
+ /// </summary>
57
+ [Tooltip("")]
58
+ [SerializeField] protected int noSelectionIndex = 1;
59
+
60
+
61
+ /// <inheritdoc/>
62
+ public override IEnumerator ResolvePresentSelection(bool gavePresent, int selectedPresentIndex)
63
+ {
64
+ if (hideFakePause != null)
65
+ hideFakePause.Raise();
66
+
67
+ yield return new WaitForSecondsRealtime(pauseMenuStartUpTime);
68
+
69
+ if (gavePresent)
70
+ ResolveGivingPresent(selectedPresentIndex);
71
+ else
72
+ ResolveNotGivingPresent();
73
+ }
74
+
75
+ /// <summary>
76
+ ///
77
+ /// </summary>
78
+ /// <param name="selectedPresentIndex"></param>
79
+ protected virtual void ResolveGivingPresent(int selectedPresentIndex)
80
+ {
81
+ Present present = presentDatabase.presents[selectedPresentIndex];
82
+
83
+ UnityEngine.Debug.Log("REPORT: Removing present to give: " + present.DisplayName);
84
+
85
+ ServiceLocator.GetService<IPresentManager>().Get<IAmountablePresent>(present.ID)?.Remove();
86
+
87
+ DialogueEventSystem.TriggerEvent(callEvaluateReaction, presentDatabase.presents[selectedPresentIndex]);
88
+ }
89
+
90
+ /// <summary>
91
+ ///
92
+ /// </summary>
93
+ protected virtual void ResolveNotGivingPresent()
94
+ {
95
+ if (ServiceLocator.HasService<IDialogueManager>())
96
+ if (((Dialogue)ServiceLocator.GetService<IDialogueManager>().GetReader().GetCurrentDialogue())
97
+ .Choices[noSelectionIndex].NextDialogue != null)
98
+ ForceDidntGivePresentChoice();
99
+ else
100
+ ServiceLocator.GetService<IDialogueManager>().GetEnder().StopDialogue();
101
+ }
102
+
103
+ /// <summary>
104
+ ///
105
+ /// </summary>
106
+ protected virtual void ForceDidntGivePresentChoice()
107
+ {
108
+ DialogueReader dialogueReader = ServiceLocator.GetService<IDialogueManager>().GetReader();
109
+
110
+ Dialogue[] originalDialogue = new Dialogue[1];
111
+
112
+ originalDialogue[0] = ((Dialogue)dialogueReader.GetCurrentDialogue()).Choices[noSelectionIndex].NextDialogue;
113
+
114
+ dialogueReader.PlayDialogues(originalDialogue);
115
+
116
+ OnPlayerDidntGivePresentChoice.Raise();
117
+ }
118
+ }
119
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: b6fccfad620234e4d9ac4e3642ebd014
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,68 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.DialogueEventHandling;
3
+ using DREditor.EventObjects;
4
+ using DREditor.UI;
5
+ using System.Collections;
6
+ using UnityEngine;
7
+
8
+ namespace DREditor.Presents.UI
9
+ {
10
+ /// <summary>
11
+ ///
12
+ /// </summary>
13
+ [ClassHeader(nameof(DialogueEventHandler) +
14
+ "\n\n")]
15
+ public class GivePresentEventHandler : DialogueEventHandler
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ [Tooltip("")]
21
+ [SerializeField] protected SceneEvent showFakePause = null;
22
+
23
+ /// <summary>
24
+ ///
25
+ /// </summary>
26
+ [Tooltip("")]
27
+ [SerializeField] protected float pauseMenuStartUpTime = 1.2f;
28
+
29
+ /// <summary>
30
+ ///
31
+ /// </summary>
32
+ [Tooltip("")]
33
+ [SerializeField] protected MenuGroupBase presentUI = null;
34
+
35
+
36
+ /// <inheritdoc/>
37
+ protected override void OnDialogueEventTriggered(object o = null) => StartCoroutine(DelayDisplayPresentUI());
38
+
39
+ /// <summary>
40
+ ///
41
+ /// </summary>
42
+ /// <returns></returns>
43
+ protected virtual IEnumerator DelayDisplayPresentUI()
44
+ {
45
+ if (showFakePause != null)
46
+ showFakePause.Raise();
47
+
48
+ yield return new WaitForSecondsRealtime(pauseMenuStartUpTime);
49
+
50
+ presentUI.Show();
51
+
52
+ yield break;
53
+ }
54
+
55
+
56
+ /// <summary>
57
+ ///
58
+ /// </summary>
59
+ protected virtual void Reset() => SetDefaultEventString("GivePresent");
60
+
61
+
62
+ /// <summary>
63
+ ///
64
+ /// </summary>
65
+ [ContextMenu("Test Event")]
66
+ public void TestEvent() => OnDialogueEventTriggered();
67
+ }
68
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: bbd2a105d30fa634c9894dcaa75873fb
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,95 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues.Events;
3
+ using DREditor.UI;
4
+ using UnityEngine;
5
+ using UnityEngine.EventSystems;
6
+ using UnityEngine.UI;
7
+ using static UnityEngine.InputSystem.InputAction;
8
+
9
+ namespace DREditor.Presents.UI
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ [ClassHeader(nameof(PresentSelectEvaluator) +
15
+ "\n\n")]
16
+ public class MenuPresentSelectEvaluator : PresentSelectEvaluator
17
+ {
18
+ /// <summary>
19
+ ///
20
+ /// </summary>
21
+ [Header("")]
22
+ [Divider]
23
+ [Tooltip("")]
24
+ [SerializeField] protected MenuGroupBase choiceMenuGroup = null;
25
+
26
+ /// <summary>
27
+ ///
28
+ /// </summary>
29
+ [Tooltip("")]
30
+ [SerializeField] protected Selectable yesSelectable = null;
31
+
32
+
33
+ /// <summary>
34
+ ///
35
+ /// </summary>
36
+ [Header("")]
37
+ [Divider]
38
+ [Tooltip("")]
39
+ [SerializeField] protected bool callNextDayOnNoPresent = false;
40
+
41
+ /// <summary>
42
+ ///
43
+ /// </summary>
44
+ [Tooltip("")]
45
+ [SerializeField] protected string callNextDay = "NextDay";
46
+
47
+
48
+ /// <inheritdoc/>
49
+ protected override void OnEnable() => choiceMenuGroup.StartEvents.AddListener(OnChoiceMenuStart);
50
+
51
+ /// <inheritdoc/>
52
+ protected override void OnDisable() => choiceMenuGroup.StartEvents.RemoveListener(OnChoiceMenuStart);
53
+
54
+ /// <inheritdoc/>
55
+ protected override void OnSelectedValidPresent() => choiceMenuGroup.Show();
56
+
57
+ /// <summary>
58
+ ///
59
+ /// </summary>
60
+ /// <param name="ctx"></param>
61
+ protected virtual void BeforeEvaluateChoice(CallbackContext ctx) { }
62
+
63
+ /// <summary>
64
+ ///
65
+ /// </summary>
66
+ /// <param name="ctx"></param>
67
+ protected virtual void AfterEvaluateChoice(CallbackContext ctx) => choiceMenuGroup.Hide();
68
+
69
+ /// <inheritdoc/>
70
+ protected override void EvaluatePresentChoice(CallbackContext ctx)
71
+ {
72
+ BeforeEvaluateChoice(ctx);
73
+
74
+ base.EvaluatePresentChoice(ctx);
75
+
76
+ if (EventSystem.current.currentSelectedGameObject == yesSelectable.gameObject)
77
+ OnGivePresentSelected();
78
+ else
79
+ OnDontGivePresentSelected();
80
+
81
+ EventSystem.current.SetSelectedGameObject(null);
82
+
83
+ AfterEvaluateChoice(ctx);
84
+ }
85
+
86
+ /// <inheritdoc/>
87
+ protected override void OnGivePresentSelected()
88
+ {
89
+ base.OnGivePresentSelected();
90
+
91
+ if (!gavePresent && callNextDayOnNoPresent)
92
+ DialogueEventSystem.TriggerEvent(callNextDay);
93
+ }
94
+ }
95
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: cfd460d13582b454f959767b90e7fa16
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: