fr.jeanf.questsystem 0.0.1
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/.github/workflows/publish.yml +23 -0
- package/.github/workflows.meta +8 -0
- package/README.md +20 -0
- package/README.md.meta +7 -0
- package/Runtime/Prefabs/QuestCore.prefab +359 -0
- package/Runtime/Prefabs/QuestCore.prefab.meta +7 -0
- package/Runtime/Prefabs/QuestIcon.prefab +474 -0
- package/Runtime/Prefabs/QuestIcon.prefab.meta +7 -0
- package/Runtime/Prefabs.meta +8 -0
- package/Runtime/Quests/GoToPlaces/PlaceToVisit.prefab +160 -0
- package/Runtime/Quests/GoToPlaces/PlaceToVisit.prefab.meta +7 -0
- package/Runtime/Quests/GoToPlaces/SpecificObjectCheck.prefab +158 -0
- package/Runtime/Quests/GoToPlaces/SpecificObjectCheck.prefab.meta +7 -0
- package/Runtime/Quests/GoToPlaces.meta +8 -0
- package/Runtime/Quests/Quest_StethoscopeCheck.prefab +645 -0
- package/Runtime/Quests/Quest_StethoscopeCheck.prefab.meta +7 -0
- package/Runtime/Quests/Quest_VisitAllPlaces.prefab +645 -0
- package/Runtime/Quests/Quest_VisitAllPlaces.prefab.meta +7 -0
- package/Runtime/Quests/Quest_VisitPlaces.prefab +247 -0
- package/Runtime/Quests/Quest_VisitPlaces.prefab.meta +7 -0
- package/Runtime/Quests.meta +8 -0
- package/Runtime/Scripts/Core/Quest.cs +101 -0
- package/Runtime/Scripts/Core/Quest.cs.meta +11 -0
- package/Runtime/Scripts/Core/QuestData.cs +18 -0
- package/Runtime/Scripts/Core/QuestData.cs.meta +11 -0
- package/Runtime/Scripts/Core/QuestInfoSO.cs +34 -0
- package/Runtime/Scripts/Core/QuestInfoSO.cs.meta +11 -0
- package/Runtime/Scripts/Core/QuestItem.cs +115 -0
- package/Runtime/Scripts/Core/QuestItem.cs.meta +11 -0
- package/Runtime/Scripts/Core/QuestManager.cs +243 -0
- package/Runtime/Scripts/Core/QuestManager.cs.meta +11 -0
- package/Runtime/Scripts/Core/QuestState.cs +12 -0
- package/Runtime/Scripts/Core/QuestState.cs.meta +11 -0
- package/Runtime/Scripts/Core/QuestStep.cs +38 -0
- package/Runtime/Scripts/Core/QuestStep.cs.meta +11 -0
- package/Runtime/Scripts/Core/QuestStepState.cs +19 -0
- package/Runtime/Scripts/Core/QuestStepState.cs.meta +11 -0
- package/Runtime/Scripts/Core.meta +8 -0
- package/Runtime/Scripts/Events/GameEventsManager.cs +29 -0
- package/Runtime/Scripts/Events/GameEventsManager.cs.meta +11 -0
- package/Runtime/Scripts/Events/InputEvents.cs +32 -0
- package/Runtime/Scripts/Events/InputEvents.cs.meta +11 -0
- package/Runtime/Scripts/Events/MiscEvents.cs +22 -0
- package/Runtime/Scripts/Events/MiscEvents.cs.meta +11 -0
- package/Runtime/Scripts/Events/PlayerEvents.cs +49 -0
- package/Runtime/Scripts/Events/PlayerEvents.cs.meta +11 -0
- package/Runtime/Scripts/Events/QuestEvents.cs +49 -0
- package/Runtime/Scripts/Events/QuestEvents.cs.meta +11 -0
- package/Runtime/Scripts/Events/ScenarioEvents.cs +22 -0
- package/Runtime/Scripts/Events/ScenarioEvents.cs.meta +11 -0
- package/Runtime/Scripts/Events.meta +8 -0
- package/Runtime/Scripts/Input/InputManager.cs +36 -0
- package/Runtime/Scripts/Input/InputManager.cs.meta +11 -0
- package/Runtime/Scripts/Input.meta +8 -0
- package/Runtime/Scripts/Prefabs/QuestCore.prefab +126 -0
- package/Runtime/Scripts/Prefabs/QuestCore.prefab.meta +7 -0
- package/Runtime/Scripts/Prefabs/QuestStatusListner_DEBUG.prefab +235 -0
- package/Runtime/Scripts/Prefabs/QuestStatusListner_DEBUG.prefab.meta +7 -0
- package/Runtime/Scripts/Prefabs.meta +8 -0
- package/Runtime/Scripts/Scenarios/ScenarioManager.cs +31 -0
- package/Runtime/Scripts/Scenarios/ScenarioManager.cs.meta +11 -0
- package/Runtime/Scripts/Scenarios.meta +8 -0
- package/Runtime/Scripts/jeanf.QuestSystem.asmdef +18 -0
- package/Runtime/Scripts/jeanf.QuestSystem.asmdef.meta +7 -0
- package/Runtime/Scripts/quests/GoToPlaces/PlaceToVisit.prefab +142 -0
- package/Runtime/Scripts/quests/GoToPlaces/PlaceToVisit.prefab.meta +7 -0
- package/Runtime/Scripts/quests/GoToPlaces/SpecificObjectCheck.prefab +158 -0
- package/Runtime/Scripts/quests/GoToPlaces/SpecificObjectCheck.prefab.meta +7 -0
- package/Runtime/Scripts/quests/GoToPlaces.meta +8 -0
- package/Runtime/Scripts/quests/Quest_StethoscopeCheck.prefab +645 -0
- package/Runtime/Scripts/quests/Quest_StethoscopeCheck.prefab.meta +7 -0
- package/Runtime/Scripts/quests/Quest_VisitAllPlaces.prefab +645 -0
- package/Runtime/Scripts/quests/Quest_VisitAllPlaces.prefab.meta +7 -0
- package/Runtime/Scripts/quests/Quest_VisitPlaces.prefab +272 -0
- package/Runtime/Scripts/quests/Quest_VisitPlaces.prefab.meta +7 -0
- package/Runtime/Scripts/quests.meta +8 -0
- package/Runtime/Scripts.meta +8 -0
- package/Runtime.meta +8 -0
- package/package.json +21 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
%YAML 1.1
|
|
2
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
3
|
+
--- !u!1 &4640217350749083558
|
|
4
|
+
GameObject:
|
|
5
|
+
m_ObjectHideFlags: 0
|
|
6
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
7
|
+
m_PrefabInstance: {fileID: 0}
|
|
8
|
+
m_PrefabAsset: {fileID: 0}
|
|
9
|
+
serializedVersion: 6
|
|
10
|
+
m_Component:
|
|
11
|
+
- component: {fileID: 7384171755721262312}
|
|
12
|
+
- component: {fileID: 6258318938562184048}
|
|
13
|
+
- component: {fileID: 156183605203104}
|
|
14
|
+
- component: {fileID: 5948494865006167922}
|
|
15
|
+
- component: {fileID: 3790095252236272238}
|
|
16
|
+
- component: {fileID: 1059188078616771896}
|
|
17
|
+
m_Layer: 0
|
|
18
|
+
m_Name: Quest_VisitPlaces
|
|
19
|
+
m_TagString: Untagged
|
|
20
|
+
m_Icon: {fileID: 0}
|
|
21
|
+
m_NavMeshLayer: 0
|
|
22
|
+
m_StaticEditorFlags: 0
|
|
23
|
+
m_IsActive: 1
|
|
24
|
+
--- !u!4 &7384171755721262312
|
|
25
|
+
Transform:
|
|
26
|
+
m_ObjectHideFlags: 0
|
|
27
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
28
|
+
m_PrefabInstance: {fileID: 0}
|
|
29
|
+
m_PrefabAsset: {fileID: 0}
|
|
30
|
+
m_GameObject: {fileID: 4640217350749083558}
|
|
31
|
+
serializedVersion: 2
|
|
32
|
+
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
|
33
|
+
m_LocalPosition: {x: 1.9499998, y: 1, z: 0.08000004}
|
|
34
|
+
m_LocalScale: {x: 3, y: 3, z: 3}
|
|
35
|
+
m_ConstrainProportionsScale: 0
|
|
36
|
+
m_Children:
|
|
37
|
+
- {fileID: 7028592712354630613}
|
|
38
|
+
m_Father: {fileID: 0}
|
|
39
|
+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
40
|
+
--- !u!33 &6258318938562184048
|
|
41
|
+
MeshFilter:
|
|
42
|
+
m_ObjectHideFlags: 0
|
|
43
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
44
|
+
m_PrefabInstance: {fileID: 0}
|
|
45
|
+
m_PrefabAsset: {fileID: 0}
|
|
46
|
+
m_GameObject: {fileID: 4640217350749083558}
|
|
47
|
+
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
|
48
|
+
--- !u!23 &156183605203104
|
|
49
|
+
MeshRenderer:
|
|
50
|
+
m_ObjectHideFlags: 0
|
|
51
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
52
|
+
m_PrefabInstance: {fileID: 0}
|
|
53
|
+
m_PrefabAsset: {fileID: 0}
|
|
54
|
+
m_GameObject: {fileID: 4640217350749083558}
|
|
55
|
+
m_Enabled: 1
|
|
56
|
+
m_CastShadows: 0
|
|
57
|
+
m_ReceiveShadows: 1
|
|
58
|
+
m_DynamicOccludee: 1
|
|
59
|
+
m_StaticShadowCaster: 0
|
|
60
|
+
m_MotionVectors: 1
|
|
61
|
+
m_LightProbeUsage: 1
|
|
62
|
+
m_ReflectionProbeUsage: 1
|
|
63
|
+
m_RayTracingMode: 2
|
|
64
|
+
m_RayTraceProcedural: 0
|
|
65
|
+
m_RenderingLayerMask: 257
|
|
66
|
+
m_RendererPriority: 0
|
|
67
|
+
m_Materials:
|
|
68
|
+
- {fileID: 2100000, guid: c666f86f06c916047b8d34519a39114e, type: 2}
|
|
69
|
+
m_StaticBatchInfo:
|
|
70
|
+
firstSubMesh: 0
|
|
71
|
+
subMeshCount: 0
|
|
72
|
+
m_StaticBatchRoot: {fileID: 0}
|
|
73
|
+
m_ProbeAnchor: {fileID: 0}
|
|
74
|
+
m_LightProbeVolumeOverride: {fileID: 0}
|
|
75
|
+
m_ScaleInLightmap: 1
|
|
76
|
+
m_ReceiveGI: 1
|
|
77
|
+
m_PreserveUVs: 0
|
|
78
|
+
m_IgnoreNormalsForChartDetection: 0
|
|
79
|
+
m_ImportantGI: 0
|
|
80
|
+
m_StitchLightmapSeams: 1
|
|
81
|
+
m_SelectedEditorRenderState: 3
|
|
82
|
+
m_MinimumChartSize: 4
|
|
83
|
+
m_AutoUVMaxDistance: 0.5
|
|
84
|
+
m_AutoUVMaxAngle: 89
|
|
85
|
+
m_LightmapParameters: {fileID: 0}
|
|
86
|
+
m_SortingLayerID: 0
|
|
87
|
+
m_SortingLayer: 0
|
|
88
|
+
m_SortingOrder: 0
|
|
89
|
+
m_AdditionalVertexStreams: {fileID: 0}
|
|
90
|
+
--- !u!65 &5948494865006167922
|
|
91
|
+
BoxCollider:
|
|
92
|
+
m_ObjectHideFlags: 0
|
|
93
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
94
|
+
m_PrefabInstance: {fileID: 0}
|
|
95
|
+
m_PrefabAsset: {fileID: 0}
|
|
96
|
+
m_GameObject: {fileID: 4640217350749083558}
|
|
97
|
+
m_Material: {fileID: 0}
|
|
98
|
+
m_IncludeLayers:
|
|
99
|
+
serializedVersion: 2
|
|
100
|
+
m_Bits: 0
|
|
101
|
+
m_ExcludeLayers:
|
|
102
|
+
serializedVersion: 2
|
|
103
|
+
m_Bits: 0
|
|
104
|
+
m_LayerOverridePriority: 0
|
|
105
|
+
m_IsTrigger: 1
|
|
106
|
+
m_ProvidesContacts: 0
|
|
107
|
+
m_Enabled: 1
|
|
108
|
+
serializedVersion: 3
|
|
109
|
+
m_Size: {x: 1, y: 1, z: 1}
|
|
110
|
+
m_Center: {x: 0, y: 0, z: 0}
|
|
111
|
+
--- !u!114 &3790095252236272238
|
|
112
|
+
MonoBehaviour:
|
|
113
|
+
m_ObjectHideFlags: 0
|
|
114
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
115
|
+
m_PrefabInstance: {fileID: 0}
|
|
116
|
+
m_PrefabAsset: {fileID: 0}
|
|
117
|
+
m_GameObject: {fileID: 4640217350749083558}
|
|
118
|
+
m_Enabled: 1
|
|
119
|
+
m_EditorHideFlags: 0
|
|
120
|
+
m_Script: {fileID: 11500000, guid: 1c5e2645e4ea25842a27fff4d2ae2e0a, type: 3}
|
|
121
|
+
m_Name:
|
|
122
|
+
m_EditorClassIdentifier:
|
|
123
|
+
_isDebug: 1
|
|
124
|
+
layerMask:
|
|
125
|
+
serializedVersion: 2
|
|
126
|
+
m_Bits: 512
|
|
127
|
+
colliderEnterEvent:
|
|
128
|
+
m_PersistentCalls:
|
|
129
|
+
m_Calls:
|
|
130
|
+
- m_Target: {fileID: 1059188078616771896}
|
|
131
|
+
m_TargetAssemblyTypeName: QuestPoint, Assembly-CSharp
|
|
132
|
+
m_MethodName: PlayerIsNear
|
|
133
|
+
m_Mode: 6
|
|
134
|
+
m_Arguments:
|
|
135
|
+
m_ObjectArgument: {fileID: 0}
|
|
136
|
+
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
|
137
|
+
m_IntArgument: 0
|
|
138
|
+
m_FloatArgument: 0
|
|
139
|
+
m_StringArgument: Room_001
|
|
140
|
+
m_BoolArgument: 1
|
|
141
|
+
m_CallState: 2
|
|
142
|
+
colliderExitEvent:
|
|
143
|
+
m_PersistentCalls:
|
|
144
|
+
m_Calls:
|
|
145
|
+
- m_Target: {fileID: 1059188078616771896}
|
|
146
|
+
m_TargetAssemblyTypeName: QuestPoint, Assembly-CSharp
|
|
147
|
+
m_MethodName: PlayerIsNear
|
|
148
|
+
m_Mode: 6
|
|
149
|
+
m_Arguments:
|
|
150
|
+
m_ObjectArgument: {fileID: 0}
|
|
151
|
+
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
|
152
|
+
m_IntArgument: 0
|
|
153
|
+
m_FloatArgument: 0
|
|
154
|
+
m_StringArgument:
|
|
155
|
+
m_BoolArgument: 0
|
|
156
|
+
m_CallState: 2
|
|
157
|
+
--- !u!114 &1059188078616771896
|
|
158
|
+
MonoBehaviour:
|
|
159
|
+
m_ObjectHideFlags: 0
|
|
160
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
161
|
+
m_PrefabInstance: {fileID: 0}
|
|
162
|
+
m_PrefabAsset: {fileID: 0}
|
|
163
|
+
m_GameObject: {fileID: 4640217350749083558}
|
|
164
|
+
m_Enabled: 1
|
|
165
|
+
m_EditorHideFlags: 0
|
|
166
|
+
m_Script: {fileID: 11500000, guid: 665634027c61d77469962dbe73b5aae3, type: 3}
|
|
167
|
+
m_Name:
|
|
168
|
+
m_EditorClassIdentifier:
|
|
169
|
+
_isDebug: 1
|
|
170
|
+
questInfoForPoint: {fileID: 11400000, guid: a249a914e47bba041b17cb82c0fd3105, type: 2}
|
|
171
|
+
startPoint: 1
|
|
172
|
+
finishPoint: 1
|
|
173
|
+
playerIsNear: 0
|
|
174
|
+
--- !u!1001 &5970478330721072192
|
|
175
|
+
PrefabInstance:
|
|
176
|
+
m_ObjectHideFlags: 0
|
|
177
|
+
serializedVersion: 2
|
|
178
|
+
m_Modification:
|
|
179
|
+
serializedVersion: 3
|
|
180
|
+
m_TransformParent: {fileID: 7384171755721262312}
|
|
181
|
+
m_Modifications:
|
|
182
|
+
- target: {fileID: 3349153003565132157, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
183
|
+
type: 3}
|
|
184
|
+
propertyPath: m_Name
|
|
185
|
+
value: QuestIcon
|
|
186
|
+
objectReference: {fileID: 0}
|
|
187
|
+
- target: {fileID: 3698006963746504597, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
188
|
+
type: 3}
|
|
189
|
+
propertyPath: m_LocalPosition.x
|
|
190
|
+
value: 0
|
|
191
|
+
objectReference: {fileID: 0}
|
|
192
|
+
- target: {fileID: 3698006963746504597, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
193
|
+
type: 3}
|
|
194
|
+
propertyPath: m_LocalPosition.y
|
|
195
|
+
value: 0
|
|
196
|
+
objectReference: {fileID: 0}
|
|
197
|
+
- target: {fileID: 3698006963746504597, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
198
|
+
type: 3}
|
|
199
|
+
propertyPath: m_LocalPosition.z
|
|
200
|
+
value: 0
|
|
201
|
+
objectReference: {fileID: 0}
|
|
202
|
+
- target: {fileID: 3698006963746504597, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
203
|
+
type: 3}
|
|
204
|
+
propertyPath: m_LocalRotation.w
|
|
205
|
+
value: 1
|
|
206
|
+
objectReference: {fileID: 0}
|
|
207
|
+
- target: {fileID: 3698006963746504597, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
208
|
+
type: 3}
|
|
209
|
+
propertyPath: m_LocalRotation.x
|
|
210
|
+
value: 0
|
|
211
|
+
objectReference: {fileID: 0}
|
|
212
|
+
- target: {fileID: 3698006963746504597, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
213
|
+
type: 3}
|
|
214
|
+
propertyPath: m_LocalRotation.y
|
|
215
|
+
value: 0
|
|
216
|
+
objectReference: {fileID: 0}
|
|
217
|
+
- target: {fileID: 3698006963746504597, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
218
|
+
type: 3}
|
|
219
|
+
propertyPath: m_LocalRotation.z
|
|
220
|
+
value: 0
|
|
221
|
+
objectReference: {fileID: 0}
|
|
222
|
+
- target: {fileID: 3698006963746504597, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
223
|
+
type: 3}
|
|
224
|
+
propertyPath: m_LocalEulerAnglesHint.x
|
|
225
|
+
value: 0
|
|
226
|
+
objectReference: {fileID: 0}
|
|
227
|
+
- target: {fileID: 3698006963746504597, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
228
|
+
type: 3}
|
|
229
|
+
propertyPath: m_LocalEulerAnglesHint.y
|
|
230
|
+
value: 0
|
|
231
|
+
objectReference: {fileID: 0}
|
|
232
|
+
- target: {fileID: 3698006963746504597, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
233
|
+
type: 3}
|
|
234
|
+
propertyPath: m_LocalEulerAnglesHint.z
|
|
235
|
+
value: 0
|
|
236
|
+
objectReference: {fileID: 0}
|
|
237
|
+
m_RemovedComponents: []
|
|
238
|
+
m_RemovedGameObjects: []
|
|
239
|
+
m_AddedGameObjects: []
|
|
240
|
+
m_AddedComponents: []
|
|
241
|
+
m_SourcePrefab: {fileID: 100100000, guid: 4e8b38634fd3e424885a3283009a28d7, type: 3}
|
|
242
|
+
--- !u!4 &7028592712354630613 stripped
|
|
243
|
+
Transform:
|
|
244
|
+
m_CorrespondingSourceObject: {fileID: 3698006963746504597, guid: 4e8b38634fd3e424885a3283009a28d7,
|
|
245
|
+
type: 3}
|
|
246
|
+
m_PrefabInstance: {fileID: 5970478330721072192}
|
|
247
|
+
m_PrefabAsset: {fileID: 0}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
public class Quest
|
|
6
|
+
{
|
|
7
|
+
// static info
|
|
8
|
+
public QuestInfoSO info;
|
|
9
|
+
|
|
10
|
+
// state info
|
|
11
|
+
public QuestState state;
|
|
12
|
+
private int currentQuestStepIndex;
|
|
13
|
+
public int currentStep;
|
|
14
|
+
private QuestStepState[] questStepStates;
|
|
15
|
+
|
|
16
|
+
public Quest(QuestInfoSO questInfo)
|
|
17
|
+
{
|
|
18
|
+
this.info = questInfo;
|
|
19
|
+
this.state = QuestState.REQUIREMENTS_NOT_MET;
|
|
20
|
+
this.currentQuestStepIndex = currentStep = 0;
|
|
21
|
+
this.questStepStates = new QuestStepState[info.questStepPrefabs.Length];
|
|
22
|
+
for (int i = 0; i < questStepStates.Length; i++)
|
|
23
|
+
{
|
|
24
|
+
questStepStates[i] = new QuestStepState();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public Quest(QuestInfoSO questInfo, QuestState questState, int currentQuestStepIndex, QuestStepState[] questStepStates)
|
|
29
|
+
{
|
|
30
|
+
this.info = questInfo;
|
|
31
|
+
this.state = questState;
|
|
32
|
+
this.currentQuestStepIndex = currentQuestStepIndex;
|
|
33
|
+
currentStep = this.currentQuestStepIndex;
|
|
34
|
+
this.questStepStates = questStepStates;
|
|
35
|
+
|
|
36
|
+
// if the quest step states and prefabs are different lengths,
|
|
37
|
+
// something has changed during development and the saved data is out of sync.
|
|
38
|
+
if (this.questStepStates.Length != this.info.questStepPrefabs.Length)
|
|
39
|
+
{
|
|
40
|
+
Debug.LogWarning("Quest Step Prefabs and Quest Step States are "
|
|
41
|
+
+ "of different lengths. This indicates something changed "
|
|
42
|
+
+ "with the QuestInfo and the saved data is now out of sync. "
|
|
43
|
+
+ "Reset your data - as this might cause issues. QuestId: " + this.info.id);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public void MoveToNextStep()
|
|
48
|
+
{
|
|
49
|
+
currentQuestStepIndex++;
|
|
50
|
+
currentStep = currentQuestStepIndex;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public bool CurrentStepExists()
|
|
54
|
+
{
|
|
55
|
+
return (currentQuestStepIndex < info.questStepPrefabs.Length);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public void InstantiateCurrentQuestStep(Transform parentTransform)
|
|
59
|
+
{
|
|
60
|
+
GameObject questStepPrefab = GetCurrentQuestStepPrefab();
|
|
61
|
+
if (questStepPrefab != null)
|
|
62
|
+
{
|
|
63
|
+
QuestStep questStep = Object.Instantiate<GameObject>(questStepPrefab, parentTransform)
|
|
64
|
+
.GetComponent<QuestStep>();
|
|
65
|
+
questStep.InitializeQuestStep(info.id, currentQuestStepIndex, questStepStates[currentQuestStepIndex].state);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private GameObject GetCurrentQuestStepPrefab()
|
|
70
|
+
{
|
|
71
|
+
GameObject questStepPrefab = null;
|
|
72
|
+
if (CurrentStepExists())
|
|
73
|
+
{
|
|
74
|
+
questStepPrefab = info.questStepPrefabs[currentQuestStepIndex];
|
|
75
|
+
}
|
|
76
|
+
else
|
|
77
|
+
{
|
|
78
|
+
Debug.LogWarning("Tried to get quest step prefab, but stepIndex was out of range indicating that "
|
|
79
|
+
+ "there's no current step: QuestId=" + info.id + ", stepIndex=" + currentQuestStepIndex);
|
|
80
|
+
}
|
|
81
|
+
return questStepPrefab;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public void StoreQuestStepState(QuestStepState questStepState, int stepIndex)
|
|
85
|
+
{
|
|
86
|
+
if (stepIndex < questStepStates.Length)
|
|
87
|
+
{
|
|
88
|
+
questStepStates[stepIndex].state = questStepState.state;
|
|
89
|
+
}
|
|
90
|
+
else
|
|
91
|
+
{
|
|
92
|
+
Debug.LogWarning("Tried to access quest step data, but stepIndex was out of range: "
|
|
93
|
+
+ "Quest Id = " + info.id + ", Step Index = " + stepIndex);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public QuestData GetQuestData()
|
|
98
|
+
{
|
|
99
|
+
return new QuestData(state, currentQuestStepIndex, questStepStates);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
[System.Serializable]
|
|
6
|
+
public class QuestData
|
|
7
|
+
{
|
|
8
|
+
public QuestState state;
|
|
9
|
+
public int questStepIndex;
|
|
10
|
+
public QuestStepState[] questStepStates;
|
|
11
|
+
|
|
12
|
+
public QuestData(QuestState state, int questStepIndex, QuestStepState[] questStepStates)
|
|
13
|
+
{
|
|
14
|
+
this.state = state;
|
|
15
|
+
this.questStepIndex = questStepIndex;
|
|
16
|
+
this.questStepStates = questStepStates;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
[CreateAssetMenu(fileName = "QuestInfoSO", menuName = "Quests/QuestInfoSO", order = 1)]
|
|
6
|
+
[ScriptableObjectDrawer]
|
|
7
|
+
public class QuestInfoSO : ScriptableObject
|
|
8
|
+
{
|
|
9
|
+
[field: SerializeField] public string id { get; private set; }
|
|
10
|
+
|
|
11
|
+
[Header("General")]
|
|
12
|
+
public string displayName;
|
|
13
|
+
|
|
14
|
+
[Header("Requirements")]
|
|
15
|
+
public int levelRequirement;
|
|
16
|
+
public QuestInfoSO[] questPrerequisites;
|
|
17
|
+
|
|
18
|
+
[Header("Steps")]
|
|
19
|
+
public GameObject[] questStepPrefabs;
|
|
20
|
+
|
|
21
|
+
[Header("Rewards")]
|
|
22
|
+
public string unlockedScenario;
|
|
23
|
+
|
|
24
|
+
// ensure the id is always the name of the Scriptable Object asset
|
|
25
|
+
private void OnValidate()
|
|
26
|
+
{
|
|
27
|
+
/*
|
|
28
|
+
#if UNITY_EDITOR
|
|
29
|
+
if (id == string.Empty) id = this.name;
|
|
30
|
+
if (this != null) UnityEditor.EditorUtility.SetDirty(this);
|
|
31
|
+
#endif
|
|
32
|
+
*/
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using jeanf.EventSystem;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
public class QuestItem : MonoBehaviour, IDebugBehaviour
|
|
8
|
+
{
|
|
9
|
+
public bool isDebug
|
|
10
|
+
{
|
|
11
|
+
get => _isDebug;
|
|
12
|
+
set => _isDebug = value;
|
|
13
|
+
}
|
|
14
|
+
[SerializeField] private bool _isDebug = false;
|
|
15
|
+
|
|
16
|
+
[Tooltip("Visual feedback for the quest state")]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
[Header("Quest")]
|
|
20
|
+
[SerializeField] private QuestInfoSO questInfoForPoint;
|
|
21
|
+
|
|
22
|
+
[ReadOnly] [Range(0,1)] [SerializeField] private float progress = 0.0f;
|
|
23
|
+
|
|
24
|
+
[Header("Config")]
|
|
25
|
+
[SerializeField] private bool startPoint = true;
|
|
26
|
+
[SerializeField] private bool finishPoint = true;
|
|
27
|
+
|
|
28
|
+
[SerializeField] [ReadOnly] private bool playerIsNear = false;
|
|
29
|
+
private string questId;
|
|
30
|
+
private QuestState currentQuestState;
|
|
31
|
+
|
|
32
|
+
// the event is Located in Assets/Resources/Quests/QuestsProgressChannel - it is searched for at Awake time.
|
|
33
|
+
private StringFloatEventChannelSO QuestProgress;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
private void Awake()
|
|
38
|
+
{
|
|
39
|
+
if (QuestProgress == null)
|
|
40
|
+
{
|
|
41
|
+
if(isDebug) Debug.Log("attempting to find Quests/QuestsProgressChannel in the resources folder" ,this);
|
|
42
|
+
QuestProgress = Resources.Load<StringFloatEventChannelSO>("Quests/QuestsProgressChannel");
|
|
43
|
+
if(QuestProgress == null) Debug.LogError("Quests/QuestsProgressChannel is not in the resources folder",this);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
var questIconPrefab = Instantiate(Resources.Load<GameObject>("Quests/QuestIcon"), this.transform);
|
|
48
|
+
|
|
49
|
+
questId = questInfoForPoint.id;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private void OnEnable()
|
|
53
|
+
{
|
|
54
|
+
QuestProgress.OnEventRaised += UpdateProgress;
|
|
55
|
+
GameEventsManager.instance.questEvents.onQuestStateChange += QuestStateChange;
|
|
56
|
+
GameEventsManager.instance.inputEvents.onSubmitPressed += UpdateState;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private void OnDisable() => Unsubscribe();
|
|
60
|
+
private void OnDestroy() => Unsubscribe();
|
|
61
|
+
|
|
62
|
+
private void Unsubscribe()
|
|
63
|
+
{
|
|
64
|
+
QuestProgress.OnEventRaised -= UpdateProgress;
|
|
65
|
+
GameEventsManager.instance.questEvents.onQuestStateChange -= QuestStateChange;
|
|
66
|
+
GameEventsManager.instance.inputEvents.onSubmitPressed -= UpdateState;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public void UpdateState()
|
|
70
|
+
{
|
|
71
|
+
if (isDebug) Debug.Log($"Updating State...");
|
|
72
|
+
if (!playerIsNear)
|
|
73
|
+
{
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (isDebug) Debug.Log($"Player is near, continuing ...");
|
|
77
|
+
|
|
78
|
+
// start or finish a quest
|
|
79
|
+
if (currentQuestState.Equals(QuestState.CAN_START) && startPoint)
|
|
80
|
+
{
|
|
81
|
+
if(isDebug) Debug.Log($"Starting quest: {questId}");
|
|
82
|
+
GameEventsManager.instance.questEvents.StartQuest(questId);
|
|
83
|
+
}
|
|
84
|
+
else if (currentQuestState.Equals(QuestState.CAN_FINISH) && finishPoint)
|
|
85
|
+
{
|
|
86
|
+
if(isDebug) Debug.Log($"Finishing quest: {questId}");
|
|
87
|
+
GameEventsManager.instance.questEvents.FinishQuest(questId);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private void UpdateProgress(string id, float progress)
|
|
92
|
+
{
|
|
93
|
+
if (id == questId)
|
|
94
|
+
{
|
|
95
|
+
this.progress = progress;
|
|
96
|
+
if(isDebug) Debug.Log($"questid [{id}] progress = {progress*100}%");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private void QuestStateChange(Quest quest)
|
|
102
|
+
{
|
|
103
|
+
// only update the quest state if this point has the corresponding quest
|
|
104
|
+
if (quest.info.id.Equals(questId))
|
|
105
|
+
{
|
|
106
|
+
currentQuestState = quest.state;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public void PlayerIsNear(bool value)
|
|
111
|
+
{
|
|
112
|
+
playerIsNear = value;
|
|
113
|
+
UpdateState();
|
|
114
|
+
}
|
|
115
|
+
}
|