From db8589c61a77439d269df727aeaca77620ddc636 Mon Sep 17 00:00:00 2001 From: kabix09 Date: Tue, 3 Jan 2023 22:44:24 +0100 Subject: [PATCH] Missions - saving --- .../Mission/New Mission Dialogue.asset | 127 ++++++------ .../Resources/Mission/New Mission Kill.asset | 184 ++++++++++++++++++ .../Mission/New Mission Kill.asset.meta | 8 + ...Mission.asset => TestCollectMission.asset} | 11 +- .../Mission/TestCollectMission.asset.meta | 8 + .../Resources/Mission/TestKillMission.asset | 39 ++++ ....asset.meta => TestKillMission.asset.meta} | 0 Assets/Scripts/AnimatedDoorBehaviour.cs | 4 +- Assets/Scripts/DoorBehaviour.cs | 1 + Assets/Scripts/Enemies' Scprits/Enemy.cs | 6 +- .../Enemies' Scprits/FollowingEnemy.cs | 3 +- .../FollowingPatrollingEnemy.cs | 3 +- .../Application/Dialogue/Dialogue.cs | 15 +- .../Dialogue/Manager/DialogueManager.cs | 2 +- .../Application/Dialogue/MissionDialogue.cs | 18 +- .../Condition/CollectMissionCondition.cs | 11 +- ...sionCondion.cs => KillMissionCondition.cs} | 11 +- .../Condition/KillMissionCondition.cs.meta} | 2 +- .../Mission/Condition/MissionCondition.cs | 4 +- .../Subject/CollectRequiredSubject.cs | 8 +- .../Condition/Subject/KillRequiredSubject.cs | 9 +- .../Condition/Subject/RequiredSubject.cs | 10 +- .../Mission/Manager/ConditionManager.cs | 8 +- .../Application/Mission/Mission.cs | 35 +++- .../Mission/Model/MissionStepModel.cs | 25 ++- .../Application/Mission/NpcMissionManager.cs | 111 +++++++---- .../Application/Mission/Save/Condition.meta | 8 + .../MissionConditionDataListManager.cs | 22 +++ .../MissionConditionDataListManager.cs.meta} | 2 +- .../Condition/MissionConditionDataLoader.cs | 42 ++++ .../MissionConditionDataLoader.cs.meta | 11 ++ .../Condition/MissionConditionDataManager.cs | 114 +++++++++++ .../MissionConditionDataManager.cs.meta | 11 ++ .../Condition/SaveMissionConditionManager.cs | 125 ++++++++++++ .../SaveMissionConditionManager.cs.meta | 11 ++ .../Mission/Save/MissionDataListManager.cs | 21 ++ .../Save/MissionDataListManager.cs.meta | 11 ++ .../Mission/Save/MissionDataLoader.cs | 39 ++++ .../Mission/Save/MissionDataLoader.cs.meta | 11 ++ .../Mission/Save/MissionDataManager.cs | 146 ++++++++++++++ .../Mission/Save/MissionDataManager.cs.meta | 11 ++ .../Mission/Save/SaveMissionManager.cs | 23 ++- .../Application/Player/PlayerActions.cs | 8 +- .../Manager/Panel/SceneBaseDataManager.cs | 1 - .../Draggable/DraggablePanelController.cs | 8 +- .../WarehousePanelController.cs | 1 - .../Shared/Manager/UI/UIBaseManager.cs | 1 - .../Shared/Manager/UI/UIWarehouseManager.cs | 6 +- .../Application/Shared/Mapper/IModelMapper.cs | 2 +- .../UI/Equipment/EquipmentUIManager.cs | 4 +- .../REFACTORING/Models/Mission/Condition.meta | 8 + .../Condition/CollectMissionConditionData.cs | 40 ++++ .../CollectMissionConditionData.cs.meta | 11 ++ .../Condition/KillMissionConditionData.cs | 48 +++++ .../KillMissionConditionData.cs.meta | 11 ++ .../Mission/Condition/MissionConditionData.cs | 63 ++++++ .../Condition/MissionConditionData.cs.meta | 11 ++ .../Mission/Dialogue/MissionDialogueData.cs | 4 +- .../Dialogue/MissionDialogueStepData.cs | 11 -- .../REFACTORING/Models/Mission/MissionData.cs | 45 ++++- .../Models/Mission/RequiredSubject.meta | 8 + .../CollectRequiredSubjectData.cs | 34 ++++ .../CollectRequiredSubjectData.cs.meta | 11 ++ .../KillRequiredSubjectData.cs | 77 ++++++++ .../KillRequiredSubjectData.cs.meta | 11 ++ .../RequiredSubject/RequiredSubjectData.cs | 45 +++++ .../RequiredSubjectData.cs.meta | 11 ++ .../Models/Mission/Step/MissionStepData.cs | 18 +- Assets/Scripts/SaveController.cs | 9 + 69 files changed, 1573 insertions(+), 205 deletions(-) create mode 100644 Assets/Resources/Mission/New Mission Kill.asset create mode 100644 Assets/Resources/Mission/New Mission Kill.asset.meta rename Assets/Resources/Mission/{TestMission.asset => TestCollectMission.asset} (84%) create mode 100644 Assets/Resources/Mission/TestCollectMission.asset.meta create mode 100644 Assets/Resources/Mission/TestKillMission.asset rename Assets/Resources/Mission/{TestMission.asset.meta => TestKillMission.asset.meta} (100%) rename Assets/Scripts/REFACTORING/Application/Mission/Condition/{KillMissionCondion.cs => KillMissionCondition.cs} (66%) rename Assets/Scripts/REFACTORING/{Models/Mission/Dialogue/MissionDialogueStepData.cs.meta => Application/Mission/Condition/KillMissionCondition.cs.meta} (83%) create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/Condition.meta create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataListManager.cs rename Assets/Scripts/REFACTORING/Application/Mission/{Condition/KillMissionCondion.cs.meta => Save/Condition/MissionConditionDataListManager.cs.meta} (83%) create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataLoader.cs create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataLoader.cs.meta create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataManager.cs create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataManager.cs.meta create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/SaveMissionConditionManager.cs create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/SaveMissionConditionManager.cs.meta create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataListManager.cs create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataListManager.cs.meta create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataLoader.cs create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataLoader.cs.meta create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataManager.cs create mode 100644 Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataManager.cs.meta create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/Condition.meta create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/Condition/CollectMissionConditionData.cs create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/Condition/CollectMissionConditionData.cs.meta create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/Condition/KillMissionConditionData.cs create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/Condition/KillMissionConditionData.cs.meta create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/Condition/MissionConditionData.cs create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/Condition/MissionConditionData.cs.meta delete mode 100644 Assets/Scripts/REFACTORING/Models/Mission/Dialogue/MissionDialogueStepData.cs create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject.meta create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/CollectRequiredSubjectData.cs create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/CollectRequiredSubjectData.cs.meta create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/KillRequiredSubjectData.cs create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/KillRequiredSubjectData.cs.meta create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/RequiredSubjectData.cs create mode 100644 Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/RequiredSubjectData.cs.meta diff --git a/Assets/Resources/Mission/New Mission Dialogue.asset b/Assets/Resources/Mission/New Mission Dialogue.asset index 7be2ee0f..9241c5e6 100644 --- a/Assets/Resources/Mission/New Mission Dialogue.asset +++ b/Assets/Resources/Mission/New Mission Dialogue.asset @@ -12,11 +12,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 67587597537a4344cad65ddbcebee119, type: 3} m_Name: New Mission Dialogue m_EditorClassIdentifier: - SpeakerName: Luberjack 2 - CurrentStep: 0 + SpeakerName: Lumberjack xd + CurrentStep: 2 DialogueSteps: - - Header: Luberjack 2 - WasDisplayed: 0 + - Header: Lumberjack xd + WasDisplayed: 1 ListOfSentences: - Sentence: Could you help me? Buttons: [] @@ -56,14 +56,24 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 - - Sentence: Thank you very much, now go! - Buttons: [] + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: Dialogue, Assembly-CSharp + m_MethodName: FinishDialogue + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 EndOfDialogueStepAction: m_PersistentCalls: m_Calls: - m_Target: {fileID: 11400000} m_TargetAssemblyTypeName: Dialogue, Assembly-CSharp - m_MethodName: ShowNextPanel + m_MethodName: GoToNextSentence m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} @@ -73,58 +83,57 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 - - Header: Luberjack 2 - WasDisplayed: 0 - ListOfSentences: - - Sentence: Fantastic!! - Buttons: [] - - Sentence: Please take this reward - Buttons: - - ButtonName: Take - Type: 1 - ButtonActions: - m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 11400000} - m_TargetAssemblyTypeName: MissionDialogue, Assembly-CSharp - m_MethodName: GiveReward - m_Mode: 1 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 - - m_Target: {fileID: 11400000} - m_TargetAssemblyTypeName: Dialogue, Assembly-CSharp - m_MethodName: GoToNextSentence - m_Mode: 1 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 - EndOfDialogueStepAction: - m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 11400000} - m_TargetAssemblyTypeName: MissionDialogue, Assembly-CSharp - m_MethodName: FinishMission - m_Mode: 1 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 - - Header: Luberjack 2 + - Header: Lumberjack xd + WasDisplayed: 1 + ListOfSentences: + - Sentence: Thank you very much, now go! + Buttons: [] + EndOfDialogueStepAction: + m_PersistentCalls: + m_Calls: [] + - Header: Lumberjack xd + WasDisplayed: 0 + ListOfSentences: + - Sentence: Have you ound it? + Buttons: + - ButtonName: yes + Type: 1 + ButtonActions: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: MissionDialogue, Assembly-CSharp + m_MethodName: HandleCondition + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - ButtonName: no + Type: 1 + ButtonActions: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: Dialogue, Assembly-CSharp + m_MethodName: BreakDialogueStep + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + EndOfDialogueStepAction: + m_PersistentCalls: + m_Calls: [] + - Header: Lumberjack xd WasDisplayed: 0 ListOfSentences: - Sentence: Fantastic!! diff --git a/Assets/Resources/Mission/New Mission Kill.asset b/Assets/Resources/Mission/New Mission Kill.asset new file mode 100644 index 00000000..566d8470 --- /dev/null +++ b/Assets/Resources/Mission/New Mission Kill.asset @@ -0,0 +1,184 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 67587597537a4344cad65ddbcebee119, type: 3} + m_Name: New Mission Kill + m_EditorClassIdentifier: + SpeakerName: Lumberjack kill mission + CurrentStep: 1 + DialogueSteps: + - Header: Lumberjack kill mission + WasDisplayed: 1 + ListOfSentences: + - Sentence: Please kill 2 bats for me + Buttons: + - ButtonName: I dont want to kill them + Type: 1 + ButtonActions: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: MissionDialogue, Assembly-CSharp + m_MethodName: RejectMission + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - ButtonName: I will kill them + Type: 1 + ButtonActions: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: MissionDialogue, Assembly-CSharp + m_MethodName: AcceptMission + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: Dialogue, Assembly-CSharp + m_MethodName: FinishDialogue + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + EndOfDialogueStepAction: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: Dialogue, Assembly-CSharp + m_MethodName: GoToNextSentence + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - Header: Lumberjack kill mission + WasDisplayed: 1 + ListOfSentences: + - Sentence: Thank you very much, now go! + Buttons: [] + EndOfDialogueStepAction: + m_PersistentCalls: + m_Calls: [] + - Header: Lumberjack kill mission + WasDisplayed: 0 + ListOfSentences: + - Sentence: Have you kill them? + Buttons: + - ButtonName: no + Type: 1 + ButtonActions: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: Dialogue, Assembly-CSharp + m_MethodName: BreakDialogueStep + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - ButtonName: yes + Type: 1 + ButtonActions: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: MissionDialogue, Assembly-CSharp + m_MethodName: HandleCondition + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + EndOfDialogueStepAction: + m_PersistentCalls: + m_Calls: [] + - Header: Lumberjack kill mission + WasDisplayed: 0 + ListOfSentences: + - Sentence: Fantastic!! + Buttons: [] + - Sentence: Please take this reward + Buttons: + - ButtonName: Take + Type: 1 + ButtonActions: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: MissionDialogue, Assembly-CSharp + m_MethodName: GiveReward + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: Dialogue, Assembly-CSharp + m_MethodName: GoToNextSentence + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + EndOfDialogueStepAction: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 11400000} + m_TargetAssemblyTypeName: MissionDialogue, Assembly-CSharp + m_MethodName: FinishMission + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 diff --git a/Assets/Resources/Mission/New Mission Kill.asset.meta b/Assets/Resources/Mission/New Mission Kill.asset.meta new file mode 100644 index 00000000..486b7458 --- /dev/null +++ b/Assets/Resources/Mission/New Mission Kill.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f78fd8078bd29a24dbe821cdde4c511b +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Mission/TestMission.asset b/Assets/Resources/Mission/TestCollectMission.asset similarity index 84% rename from Assets/Resources/Mission/TestMission.asset rename to Assets/Resources/Mission/TestCollectMission.asset index 09e2f51f..3e9ac417 100644 --- a/Assets/Resources/Mission/TestMission.asset +++ b/Assets/Resources/Mission/TestCollectMission.asset @@ -10,7 +10,7 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 0a3bcdd1e2dba0c4791bcb151c0df6c1, type: 3} - m_Name: TestMission + m_Name: TestCollectMission m_EditorClassIdentifier: MissionName: Test mission I PlayerTask: @@ -18,13 +18,12 @@ MonoBehaviour: title: description: difficulty: 0 - SpeakerName: - Status: 0 + SpeakerName: Lumberjack kill mission + Status: 3 CurrentStep: 0 MissionStepsList: - - SpeakerName: - Status: 0 - DialogueStepTemplate: {fileID: 11400000, guid: fe2810d79ff17f74eab5cf9a916167b4, type: 2} + - SpeakerName: Lumberjack kill mission + Status: 2 DialogueStep: {fileID: 11400000, guid: fe2810d79ff17f74eab5cf9a916167b4, type: 2} MissionConditions: Key: 0 diff --git a/Assets/Resources/Mission/TestCollectMission.asset.meta b/Assets/Resources/Mission/TestCollectMission.asset.meta new file mode 100644 index 00000000..1722f206 --- /dev/null +++ b/Assets/Resources/Mission/TestCollectMission.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9e6ca23e6f35bc94891c0cdf2a450fae +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Mission/TestKillMission.asset b/Assets/Resources/Mission/TestKillMission.asset new file mode 100644 index 00000000..898d0da7 --- /dev/null +++ b/Assets/Resources/Mission/TestKillMission.asset @@ -0,0 +1,39 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0a3bcdd1e2dba0c4791bcb151c0df6c1, type: 3} + m_Name: TestKillMission + m_EditorClassIdentifier: + MissionName: mission kill test + PlayerTask: + id: 0 + title: + description: + difficulty: 0 + SpeakerName: Lumberjack kill mission + Status: 3 + CurrentStep: 0 + MissionStepsList: + - SpeakerName: Lumberjack kill mission + Status: 2 + DialogueStep: {fileID: 11400000, guid: f78fd8078bd29a24dbe821cdde4c511b, type: 2} + MissionConditions: + Key: 0 + Value: + - Type: 1 + RequiredElements: + - RequiredAmount: 2 + RequiredObject: {fileID: 8184504007427166059, guid: 90bf7de365b8fee4993aa2e50b64fe14, type: 3} + Reward: + Items: + - {fileID: 11400000, guid: dc7fdbc8450965344914371023ddb0c5, type: 2} + - {fileID: 11400000, guid: 5ca5ea8918f15904c8bad3fe9694e5a5, type: 2} + Cash: 300 diff --git a/Assets/Resources/Mission/TestMission.asset.meta b/Assets/Resources/Mission/TestKillMission.asset.meta similarity index 100% rename from Assets/Resources/Mission/TestMission.asset.meta rename to Assets/Resources/Mission/TestKillMission.asset.meta diff --git a/Assets/Scripts/AnimatedDoorBehaviour.cs b/Assets/Scripts/AnimatedDoorBehaviour.cs index 84115ac8..8b0997fb 100644 --- a/Assets/Scripts/AnimatedDoorBehaviour.cs +++ b/Assets/Scripts/AnimatedDoorBehaviour.cs @@ -67,7 +67,9 @@ public class AnimatedDoorBehaviour : TriggerDoor SaveController.GetComponent().SaveChests(); SaveController.GetComponent().SaveShops(); - SaveController.GetComponent().SaveDialogues(); + SaveController.GetComponent().SaveDialogues(); + SaveController.GetComponent().SaveMissions(); + // 2. Change scene SceneManager.LoadScene(gateway.nextMapName); diff --git a/Assets/Scripts/DoorBehaviour.cs b/Assets/Scripts/DoorBehaviour.cs index 57439d45..f4b74fa4 100644 --- a/Assets/Scripts/DoorBehaviour.cs +++ b/Assets/Scripts/DoorBehaviour.cs @@ -49,6 +49,7 @@ public class DoorBehaviour : MonoBehaviour SaveController.GetComponent().SaveChests(); SaveController.GetComponent().SaveShops(); SaveController.GetComponent().SaveDialogues(); + SaveController.GetComponent().SaveMissions(); // 2. Change scene SceneManager.LoadScene(gateway.nextMapName); diff --git a/Assets/Scripts/Enemies' Scprits/Enemy.cs b/Assets/Scripts/Enemies' Scprits/Enemy.cs index 6304141c..7b333bdf 100644 --- a/Assets/Scripts/Enemies' Scprits/Enemy.cs +++ b/Assets/Scripts/Enemies' Scprits/Enemy.cs @@ -5,14 +5,16 @@ using UnityEngine; public class Enemy : MonoBehaviour { public float moveSpeed; - public string enemyName; + public string enemyName; // var for name (must be unique (playerPrefs.set/get string "enemyName - s") public FloatValue maxHealth; public float health; public float baseAttack; + public string MinionName; // var used for multiplied name - for mission poroggress (kill condition) + private void Awake() { - health = maxHealth.initialValue; + health = maxHealth.initialValue; } diff --git a/Assets/Scripts/Enemies' Scprits/FollowingEnemy.cs b/Assets/Scripts/Enemies' Scprits/FollowingEnemy.cs index be58f03b..76661984 100644 --- a/Assets/Scripts/Enemies' Scprits/FollowingEnemy.cs +++ b/Assets/Scripts/Enemies' Scprits/FollowingEnemy.cs @@ -222,7 +222,8 @@ public class FollowingEnemy : Enemy other.GetComponent().GetExp(expValue); // pass info about killing assigned enemy to mission manager listener - ConditionManager.Instance.UpdateKillCondition(gameObject.name); + // pass enemy name from script NOT object name (thats allow to have many different objects variantsa with this same aggregate key (private name - not preffab name) ) + ConditionManager.Instance.UpdateKillCondition(gameObject.GetComponent().MinionName); } } diff --git a/Assets/Scripts/Enemies' Scprits/FollowingPatrollingEnemy.cs b/Assets/Scripts/Enemies' Scprits/FollowingPatrollingEnemy.cs index cdf57a64..5f012552 100644 --- a/Assets/Scripts/Enemies' Scprits/FollowingPatrollingEnemy.cs +++ b/Assets/Scripts/Enemies' Scprits/FollowingPatrollingEnemy.cs @@ -194,7 +194,8 @@ public class FollowingPatrollingEnemy : Enemy other.GetComponent().GetExp(expValue); // pass info about killing assigned enemy to mission manager listener - ConditionManager.Instance.UpdateKillCondition(gameObject.name); + // pass enemy name from script NOT object name (thats allow to have many different objects variantsa with this same aggregate key (private name - not preffab name) ) + ConditionManager.Instance.UpdateKillCondition(gameObject.GetComponent().MinionName); } } diff --git a/Assets/Scripts/REFACTORING/Application/Dialogue/Dialogue.cs b/Assets/Scripts/REFACTORING/Application/Dialogue/Dialogue.cs index 911bd507..1490c5d6 100644 --- a/Assets/Scripts/REFACTORING/Application/Dialogue/Dialogue.cs +++ b/Assets/Scripts/REFACTORING/Application/Dialogue/Dialogue.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using UnityEditor; using UnityEngine; using UnityEngine.Events; @@ -266,10 +267,12 @@ public class Dialogue : ScriptableObject, IDialogue /// public void ResetDialogue() { + CurrentStep = 0; + DialogueSteps.ForEach(step => step.WasDisplayed = false); } - public void UpdateDialogueState(DialogueData dialogueData) + public virtual void UpdateDialogueState(DialogueData dialogueData) { // 1 Rule - speaker name shouldnt change !!! its our 'key' @@ -283,9 +286,15 @@ public class Dialogue : ScriptableObject, IDialogue } #endregion - public DialogueStepModel GetCurrentStep() + public DialogueStepModel? GetCurrentStep() {// TODO - argument out of colection :/ - return DialogueSteps[CurrentStep]; + + var currentStep = DialogueSteps.ElementAtOrDefault(CurrentStep); + + if (currentStep != null && currentStep.WasDisplayed && CurrentStep < DialogueSteps.Count) + CurrentStep++; + + return DialogueSteps.Count > CurrentStep ? DialogueSteps[CurrentStep] : null; } diff --git a/Assets/Scripts/REFACTORING/Application/Dialogue/Manager/DialogueManager.cs b/Assets/Scripts/REFACTORING/Application/Dialogue/Manager/DialogueManager.cs index 50e0bce2..4952b2f0 100644 --- a/Assets/Scripts/REFACTORING/Application/Dialogue/Manager/DialogueManager.cs +++ b/Assets/Scripts/REFACTORING/Application/Dialogue/Manager/DialogueManager.cs @@ -149,7 +149,7 @@ public class DialogueManager : MonoBehaviour public virtual bool GetCurrentDialoguePanelStatus() { var multiDialStatius = Dialogue.DialogueStepStatus(); - Debug.Log(multiDialStatius); + // parse result (dialoge no, step no) // dialogue not exist - finished // dialoge exists & step no > steps sum - finished diff --git a/Assets/Scripts/REFACTORING/Application/Dialogue/MissionDialogue.cs b/Assets/Scripts/REFACTORING/Application/Dialogue/MissionDialogue.cs index f4cab8d4..67dd8342 100644 --- a/Assets/Scripts/REFACTORING/Application/Dialogue/MissionDialogue.cs +++ b/Assets/Scripts/REFACTORING/Application/Dialogue/MissionDialogue.cs @@ -28,7 +28,8 @@ public class MissionDialogue : Dialogue Parent.GetOriginMission().Accept(); // show next panel if exists - ShowNextPanel(); + //ShowNextPanel(); + // no we allow to decide programers which one use GoToNextSentence or ShowNextPanel } /// @@ -52,7 +53,6 @@ public class MissionDialogue : Dialogue Debug.Log("Handle Conditoion"); var result = Parent.HanldeMissionStepCondition(); - Debug.Log(CurrentStep); if (result) GoToNextSentence(); else BreakDialogueStep(); } @@ -68,5 +68,19 @@ public class MissionDialogue : Dialogue Parent.GetOriginMission().FinishMission(); } #endregion + + #region Dialogue Status API + + + public void UpdateDialogueState(MissionDialogueData dialogueData) + { + CurrentStep = dialogueData.CurrentStep; + + for (int i = 0; i < dialogueData.DialogueStepModelDataList.Count; i++) + { + DialogueSteps[i].WasDisplayed = dialogueData.DialogueStepModelDataList[i].WasDisplayed; + } + } + #endregion } diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Condition/CollectMissionCondition.cs b/Assets/Scripts/REFACTORING/Application/Mission/Condition/CollectMissionCondition.cs index 5a6afd5d..ec7cf02d 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/Condition/CollectMissionCondition.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/Condition/CollectMissionCondition.cs @@ -5,17 +5,12 @@ using System.Text; using System.Threading.Tasks; -class CollectMissionCondition : MissionCondition +public class CollectMissionCondition : MissionCondition { - public CollectMissionCondition() - { - Type = MissionTypeEnum.Collect; - } + public CollectMissionCondition() : base (MissionTypeEnum.Collect) {} - public CollectMissionCondition(MissionCondition missionCondition) + public CollectMissionCondition(MissionCondition missionCondition) : base (MissionTypeEnum.Collect) { - Type = MissionTypeEnum.Collect; - // Convert base type Subject on specified sub-class (with own functions) RequiredElements.Clear(); foreach (RequiredSubject requiredSubject in missionCondition.RequiredElements) diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondion.cs b/Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondition.cs similarity index 66% rename from Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondion.cs rename to Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondition.cs index 22cd0d29..aa741741 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondion.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondition.cs @@ -5,17 +5,12 @@ using System.Text; using System.Threading.Tasks; using UnityEngine; -class KillMissionCondion : MissionCondition +public class KillMissionCondition : MissionCondition { - public KillMissionCondion() - { - Type = MissionTypeEnum.Kill; - } + public KillMissionCondition() : base(MissionTypeEnum.Kill) { } - public KillMissionCondion(MissionCondition missionCondition) + public KillMissionCondition(MissionCondition missionCondition) : base(MissionTypeEnum.Kill) { - Type = MissionTypeEnum.Kill; - // Convert base type Subject on specified sub-class (with own functions) RequiredElements.Clear(); foreach(RequiredSubject requiredSubject in missionCondition.RequiredElements) diff --git a/Assets/Scripts/REFACTORING/Models/Mission/Dialogue/MissionDialogueStepData.cs.meta b/Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondition.cs.meta similarity index 83% rename from Assets/Scripts/REFACTORING/Models/Mission/Dialogue/MissionDialogueStepData.cs.meta rename to Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondition.cs.meta index 6829356b..1f8f9668 100644 --- a/Assets/Scripts/REFACTORING/Models/Mission/Dialogue/MissionDialogueStepData.cs.meta +++ b/Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondition.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 65cb4fb8a7aa29641b4979c6ea2ad31f +guid: 99f1bc87bda30e042be2b016a67537f4 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Condition/MissionCondition.cs b/Assets/Scripts/REFACTORING/Application/Mission/Condition/MissionCondition.cs index 8542b5b7..1378cf86 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/Condition/MissionCondition.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/Condition/MissionCondition.cs @@ -14,7 +14,7 @@ public class MissionCondition [SerializeField] public List RequiredElements = new List(); - public MissionCondition() { } + public MissionCondition(MissionTypeEnum type) { Type = type; } public bool IsConditionMeeted() { @@ -28,7 +28,7 @@ public class MissionCondition { case MissionTypeEnum.Kill: { - return new KillMissionCondion(this); + return new KillMissionCondition(this); } case MissionTypeEnum.Collect: { diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/CollectRequiredSubject.cs b/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/CollectRequiredSubject.cs index a16a7e80..fa77fc31 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/CollectRequiredSubject.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/CollectRequiredSubject.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnityEngine; /// @@ -13,6 +9,8 @@ public class CollectRequiredSubject : RequiredSubject { protected override string MODEL_LOCALIZATION => "Items/"; + public CollectRequiredSubject(int requiredAmount) : base(requiredAmount) { } + public CollectRequiredSubject(RequiredSubject requiredSubject) : base(requiredSubject.RequiredAmount, requiredSubject.RequiredObject) { } public CollectRequiredSubject(int requiredAmount, GameObject enemy) : base(requiredAmount, enemy) { } @@ -31,4 +29,4 @@ public class CollectRequiredSubject : RequiredSubject return isConditionMet; } -} +} \ No newline at end of file diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/KillRequiredSubject.cs b/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/KillRequiredSubject.cs index 04b1af87..19efbc68 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/KillRequiredSubject.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/KillRequiredSubject.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using UnityEngine; [Serializable] -class KillRequiredSubject : RequiredSubject // Enemy - WTF is this class... +public class KillRequiredSubject : RequiredSubject // Enemy - WTF is this class... { protected override string MODEL_LOCALIZATION => "Enemies/"; @@ -15,15 +15,18 @@ class KillRequiredSubject : RequiredSubject // Enemy - WTF is this class... public KillRequiredSubject(RequiredSubject requiredSubject) : base(requiredSubject.RequiredAmount, requiredSubject.RequiredObject) { } - public KillRequiredSubject(int requiredAmount, GameObject enemy) : base(requiredAmount, enemy) { } + public KillRequiredSubject(int requiredAmount, GameObject enemy, int currentAmount) : base(requiredAmount, enemy) { CurrentAmount = currentAmount; } - public KillRequiredSubject(int requiredAmount, string enemyName) : base(requiredAmount, enemyName) { } + public KillRequiredSubject(int requiredAmount, string enemyName, int currentAmount) : base(requiredAmount, enemyName) { CurrentAmount = currentAmount; } + + public KillRequiredSubject(int requiredAmount, int currentAmount) : base(requiredAmount) { CurrentAmount = currentAmount; } public void IncreaseAmount() { Debug.Log("IncreaseAmount"); CurrentAmount += 1; + Debug.Log("New Amount: " + CurrentAmount); } public void IncreaseAmount(int amount) diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/RequiredSubject.cs b/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/RequiredSubject.cs index 305fea95..43db0614 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/RequiredSubject.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/Condition/Subject/RequiredSubject.cs @@ -16,6 +16,11 @@ public class RequiredSubject [SerializeField] public GameObject RequiredObject; + public RequiredSubject(int requiredAmount) + { + RequiredAmount = requiredAmount; + } + public RequiredSubject(int requiredAmount, GameObject _object) { RequiredAmount = requiredAmount; @@ -25,7 +30,7 @@ public class RequiredSubject public RequiredSubject(int requiredAmount, string objectName) { RequiredAmount = requiredAmount; - RequiredObject = MonoBehaviour.Instantiate(FindObjectInResource(objectName)); + RequiredObject = FindObjectInResource(objectName); } public GameObject FindObjectInResource(string modelName) @@ -33,10 +38,11 @@ public class RequiredSubject var resource = Resources.Load(MODEL_LOCALIZATION + modelName); if (!resource) - throw new System.Exception($"Resource {modelName} not found!!"); + throw new System.Exception($"required Subject Resource {MODEL_LOCALIZATION + modelName} not found!!"); return resource; } + public virtual bool CheckCondition() { return false; } } diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Manager/ConditionManager.cs b/Assets/Scripts/REFACTORING/Application/Mission/Manager/ConditionManager.cs index a136750a..abd62116 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/Manager/ConditionManager.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/Manager/ConditionManager.cs @@ -41,6 +41,8 @@ class ConditionManager : MonoBehaviour { if(HasMissionActiveCondition(missionName)) { + // Npc mission manager may try to register current condition - but player may have registered and saved it ealier + // and after loiading game system will read this condition and pass to list from memory files Debug.LogError($"Mission '{missionName}' has currently active Condition"); return; @@ -52,8 +54,6 @@ class ConditionManager : MonoBehaviour conditionsToContinue ) ); - - Debug.Log("Condition registered :D"); } /// @@ -68,7 +68,7 @@ class ConditionManager : MonoBehaviour .Where(missionCondition => missionCondition.Type == MissionTypeEnum.Kill) .ToList() .ForEach(killCondition => killCondition.RequiredElements - .Where(element => element.RequiredObject.name == objectName) + .Where(element => element.RequiredObject.GetComponent().MinionName == objectName) .ToList() .ForEach(element => ((KillRequiredSubject)element).IncreaseAmount()) ); @@ -87,7 +87,7 @@ class ConditionManager : MonoBehaviour if(!HasMissionActiveCondition(missionName)) { Debug.LogError($"Data inconsistency!!! Mission dont have any registered condition to check"); - return true; + return false; } int unmeetedConditions = Conditions diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Mission.cs b/Assets/Scripts/REFACTORING/Application/Mission/Mission.cs index c087f64a..25991f8b 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/Mission.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/Mission.cs @@ -27,7 +27,7 @@ public class Mission : ScriptableObject public MissionStatusEnum Status = MissionStatusEnum.None; [SerializeField] - int CurrentStep = 0; + public int CurrentStep = 0; [SerializeField] public List MissionStepsList; @@ -54,7 +54,7 @@ public class Mission : ScriptableObject }*/ // Set by hand as mission condition as final astion specyfic step - public void CheckMissionrequirements() + public void CheckMissionRequirements() { } @@ -181,7 +181,7 @@ public class Mission : ScriptableObject foreach (var MissionStep in MissionStepsList) { // jesli krok jest aktywny & ma niewypowiedziane zdania - if ((MissionStep.Status == MissionStepStatusEnum.Active || MissionStep.Status == MissionStepStatusEnum.AfterCondition) && MissionStep.DialogueStep.GetCurrentStep().DialogueController.listOfDialogue.Count != 0) + if ((MissionStep.Status == MissionStepStatusEnum.Active || MissionStep.Status == MissionStepStatusEnum.AfterCondition) && MissionStep.DialogueStep.GetCurrentStep()?.DialogueController.listOfDialogue.Count != 0) { MissionStep.DialogueStep.StartDialogue(); @@ -267,6 +267,35 @@ public class Mission : ScriptableObject MissionStepsList[CurrentStep].ActivateStep(); } + #region Dialogue Status API + /// + /// Function to reset rememebered dialogue status + /// + /// (Scriptable objects clones are overwritten during clone modification) + /// + public void ResetMission() + { + Status = MissionStatusEnum.None; + + CurrentStep = 0; + + MissionStepsList.ForEach(step => step.ResetMissionStep()); + } + + public void UpdateMissionState(MissionData missionData) + { + // 1 Rule - speaker name shouldnt change !!! its our 'key' + + Status = missionData.Status; + + CurrentStep = missionData.CurrentStep; + + for (int i = 0; i < missionData.MissionStepsDataList.Count; i++) + { + MissionStepsList[i].UpdateMissionStepState(missionData.MissionStepsDataList[i]); + } + } + #endregion public MissionStepModel GetCurrentStep() { diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Model/MissionStepModel.cs b/Assets/Scripts/REFACTORING/Application/Mission/Model/MissionStepModel.cs index a3bec25a..5f56052e 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/Model/MissionStepModel.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/Model/MissionStepModel.cs @@ -71,18 +71,13 @@ public class MissionStepModel RegisterCondition(); - + ((MissionDataManager)MissionDataManager.Instance).RegisterMission(MissionOrigin); // save mission status aftre each activating partial mission } #region Condition Mangment section public void RegisterCondition() { - Debug.Log(MissionConditions); - Debug.Log(MissionConditions.Value[0].Type); - - ConditionManager.Instance.RegisterCondition(MissionOrigin.MissionName, BuildConditionsList()); - Debug.Log("Condition registered"); } /// @@ -137,6 +132,24 @@ public class MissionStepModel return ConditionManager.Instance.CheckCondition(MissionOrigin.MissionName); } #endregion + + #region Mission Status API + + public void ResetMissionStep() + { + Status = MissionStepStatusEnum.None; + + DialogueStep.ResetDialogue(); + } + + public void UpdateMissionStepState(MissionStepData dialogueData) + { + // 1 Rule - speaker name shouldnt change !!! its our 'key' + Status = dialogueData.Status; + + DialogueStep.UpdateDialogueState(dialogueData.MissionDialogueData); + } + #endregion } diff --git a/Assets/Scripts/REFACTORING/Application/Mission/NpcMissionManager.cs b/Assets/Scripts/REFACTORING/Application/Mission/NpcMissionManager.cs index fa0994b5..915f6b91 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/NpcMissionManager.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/NpcMissionManager.cs @@ -23,11 +23,36 @@ public class NpcMissionManager : DialogueManager // ScriptableObject //public List, MissionCondition>> EndactionEventList; - public void Start() + public override void Start() { - Mission = Instantiate(MissionTemplate); - Mission.SetSpeakerName(gameObject.GetComponent().Name); - //Mission.BuildMission(); + base.Start(); + + CanBeOpened = false; + OpenInDefaultWay = false; + + CreateInstanceBasedOnLanguage(); + + + // UPDATE DIALOGUE + // search in scene manager list + if (Mission != null) + { + var machedDialogueData = ((MissionDataManager)MissionDataManager.Instance).GetMission(Mission); + + if (machedDialogueData != null) + { + UpdateMissionState(machedDialogueData); + } + else + { + Debug.Log("Start - UpdateProggres"); + UpdateProggres(); + } + } + + Mission.BuildMission(); + + if (FreeDialogue != null) FreeDialogue.Build(); @@ -45,8 +70,6 @@ public class NpcMissionManager : DialogueManager // ScriptableObject { CanBeOpened = true; - SpeakerName = collision.gameObject.name; - Mission.StartDialogue(); } } @@ -61,29 +84,56 @@ public class NpcMissionManager : DialogueManager // ScriptableObject { CanBeOpened = false; - if (GetCurrentDialoguePanelStatus()) + if (Mission != null && GetCurrentDialoguePanelStatus()) { - Debug.Log("BreakDialogueStep"); - Mission.BreakDialogueStep(); +/* Debug.Log("BreakDialogueStep"); +*/ Mission.BreakDialogueStep(); } } } - -/* public void Talk() + public override void CreateInstanceBasedOnLanguage() { - if (Mission == null || Mission.Status == MissionStatusEnum.Finished) - { - // show free dialogue - //if(FreeDialogue != null) - //FreeDialogue.DialogueController. - } else - { - // continue mission - Mission.StartDialogue(); - } + // DONT CLONE TO HAVE CONSTANT DATA - init - deep copy - to prevent overwritting chil;dern :D + Mission = MissionTemplate; + + Mission.ResetMission(); + /* var cloneDialogues = new List>(Dialogue.Dialogues); + + Dialogue.Dialogues.Clear(); + foreach (var dial in cloneDialogues) + { + Dialogue.Dialogues.Add(new IndexValuePair(dial.Key, Instantiate(dial.Value))); + }*/ + + Mission.SetSpeakerName(gameObject.GetComponent().Name); + + // update dial state - sync in order to prepare to save + Mission.MissionStepsList.ForEach(dial => dial.DialogueStep.SetActionAfterEachDialogueStep(UpdateProggres)); + + // Add one more action - to reset proggress + //Dialogue.Dialogues.ForEach(dial => dial.Value.SetActionAfterEachDialogueStep(dial.Value.ResetDialogue)); // reset dial } -*/ + + public void UpdateMissionState(MissionData missionState) + { + // 1 Rule - speaker name shouldnt change !!! its our 'key' + + Mission.UpdateMissionState(missionState); + } + + /// + /// Function to sync local dialogue state with remote one + /// Handled in Scene Manager + /// + public void UpdateProggres() + { + ((MissionDataManager)MissionDataManager.Instance).RegisterMission(Mission); + } + + + + protected override bool ComponentEnabledCondition() { return !gameObject.GetComponent().enabled; @@ -91,24 +141,11 @@ public class NpcMissionManager : DialogueManager // ScriptableObject public override bool GetCurrentDialoguePanelStatus() { - Debug.Log(Mission - .GetCurrentStep() - .DialogueStep.CurrentStep - ); - - Debug.Log(Mission - .GetCurrentStep() - .DialogueStep - .GetCurrentStep() - .DialogueController - .CurrentPanel - ); - return Mission .GetCurrentStep() .DialogueStep - .GetCurrentStep() // ? - .DialogueController + .GetCurrentStep() + ?.DialogueController .CurrentPanel != null; } } diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition.meta b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition.meta new file mode 100644 index 00000000..2e27caf1 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 980c28d408eb117438efae51b5d2a416 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataListManager.cs b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataListManager.cs new file mode 100644 index 00000000..17cf5d2f --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataListManager.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +public class MissionConditionDataListManager : DataListManager>> +{ + // WE DONT NEED HERE UI MANAGER - because dialoges ane;t associated with ui panels in way like inventory / chest or shop + + public override void AddElementToList(IndexValuePair> newElement) + { + Elements.Add(newElement); + } + + public override void RemoveElementFromList(IndexValuePair> element) + { + throw new NotImplementedException(); + } +} + diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondion.cs.meta b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataListManager.cs.meta similarity index 83% rename from Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondion.cs.meta rename to Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataListManager.cs.meta index 74fddaad..627a972b 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/Condition/KillMissionCondion.cs.meta +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataListManager.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 439e1e19b22afd4478b4c1151588c35b +guid: 8d515fca317b6ce4882ed8be7036497a MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataLoader.cs b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataLoader.cs new file mode 100644 index 00000000..f1de1982 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataLoader.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +class MissionConditionDataLoader : SceneBaseDataLoader>> +{ + public MissionConditionDataLoader(string _objectListName, string _objectFolderName) + { + SaveModelSystem = new SaveMissionConditionManager(); + SaveModelSystem.ObjectFolderName = _objectFolderName; + SaveModelSystem.ObjectListName = _objectListName; + } + + protected override List>> LoadDynamicData() + { + SaveModelSystem.Path = PathBuilder.BuildSavePath().GetString(); + + return SaveModelSystem.LoadModelList(); + } + + protected override bool SaveDynamicData(List>> _elements) + { + SaveModelSystem.Path = PathBuilder.BuildSavePath().GetString(); + + return base.SaveDynamicData(_elements); + } + + protected override List>> LoadGenericData() + { + throw new NotImplementedException(); + } + + protected override bool SaveGenericData(List>> _elements) + { + throw new NotImplementedException(); + } +} + + diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataLoader.cs.meta b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataLoader.cs.meta new file mode 100644 index 00000000..01f0d30b --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataLoader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 51a727db7d9c63642b9eb8e111adcc29 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataManager.cs b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataManager.cs new file mode 100644 index 00000000..7dac7137 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataManager.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +[RequireComponent(typeof(ConditionManager))] +class MissionConditionDataManager : SceneBaseDataManager>> +{ + protected override string OBJECT_FOLDER_NAME { get { return "MissionCondition"; } } + + protected override string OBJECT_LIST_NAME { get { return "MissionsConditionsList"; } } + + [SerializeField] + public List>> MissionConditionDataList; + + public override void Awake() + { + if (Instance == null) + { + Instance = this; + + // moved from start beacuse we need to prepare env before NpcMissionmanager start registering and uipdating mission model + Debug.Log("Start Mission manager"); + + DynamicDataList = new MissionConditionDataListManager(); + + DataLoader = new MissionConditionDataLoader(OBJECT_LIST_NAME, OBJECT_FOLDER_NAME); + + base.Start(); // (afterStart invoking - to load saved data) + } + else + { + Destroy(gameObject); + } + } + + // ZMIANA KONCEPCJI + // ZMIAST TRZYMAC SUROWE OBIEKTY TYM RAZEM ZAPISUJMY modele Datai updatujmy obiket w NPC Managerze + + // nadpisujemy by nir duplikowac wywoałania i nadpisyuwanie MissionDataList z Awake + public override void Start() + { + + } + + + protected override void AfterStart() + { + if (OnMapAppearanceMethod.GameStatus == GameStatus.NewGame) + { + if (OnMapAppearanceMethod.Gateway != OnMapAppearanceMethodEnum.NewGame) + UseDynamicSettings(); // if there is nothing saved we will use UseDefaultSettings + else + UseDefaultSettings(); + } + else + { + UseDynamicSettings(); + } + } + + + + protected override void UseDefaultSettings() + { + DynamicDataList.SetList(new List>>()); + + MissionConditionDataList = DynamicDataList.GetList(); + + gameObject.GetComponent().Conditions = SaveMissionConditionManager.ConvertListOfDataModelsToListOfObject(MissionConditionDataList); + // we dont need to convert anything + // Instead of build elements on scene we collect shops distracted on scene from npc's + } + + protected override void UseDynamicSettings() + { + // when chest detect player in near arrea and player press "c" + // open panel -> chest controller handle Open panel in Scene Chest Manager passing info about what Chest Palyer want to open + // Manager Build panel and pass info about chest content + LoadDynamicData(); + + + // VERy VERY provisional SOLUTION + if (DynamicDataList.GetList().Count == 0) + { + UseDefaultSettings(); + } + + MissionConditionDataList = DynamicDataList.GetList(); + + // map data to model + gameObject.GetComponent().Conditions = SaveMissionConditionManager.ConvertListOfDataModelsToListOfObject(MissionConditionDataList); + } + + + + +/* public MissionConditionData? GetMissionCondition(MissionCondition newMission) + { + return DynamicDataList.GetList().Where(mission => mission.SpeakerName == newMission.SpeakerName && mission.MissionName == newMission.MissionName).FirstOrDefault(); + }*/ + + public override bool SaveDynamicData() + { + // fill local list by elements from ConditionManager list + MissionConditionDataList.Clear(); + + MissionConditionDataList = SaveMissionConditionManager.ConvertObjectsListToListOfDataModels(ConditionManager.Instance.Conditions); + + return SaveData(MissionConditionDataList, SceneElementTypeEnum.Dynamic); + } +} \ No newline at end of file diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataManager.cs.meta b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataManager.cs.meta new file mode 100644 index 00000000..bd05ef29 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/MissionConditionDataManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f16469a3a30fc8f43bec2fb2eeedd293 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/SaveMissionConditionManager.cs b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/SaveMissionConditionManager.cs new file mode 100644 index 00000000..197343b4 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/SaveMissionConditionManager.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Serialization.Formatters.Binary; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +class SaveMissionConditionManager : SaveModelSystem>> // TODO change MissionConditionData +{ + public override bool SaveModelItem(IndexValuePair> model) + { + return base.SaveModelItem(model); + } + + public override bool SaveModelList(List>> list) + { + BinaryFormatter formatter = new BinaryFormatter(); + + Debug.Log("Saved Mision Condition list at " + Path); + + if (!Directory.Exists(Path)) Directory.CreateDirectory(Path); + + /* Main logic of conversion data format */ + var data = list; // ConvertObjectsListToListOfDataModels(list); + + FileStream stream = new FileStream( + Path + GetFileName(ObjectListName), + FileMode.Create + ); + + formatter.Serialize(stream, data); + stream.Close(); + + return true; + } + + public override IndexValuePair> LoadModelItem() + { + return base.LoadModelItem(); + } + + public override List>> LoadModelList() + { + string path = Path + GetFileName(ObjectListName); + + if (File.Exists(path)) + { + BinaryFormatter formatter = new BinaryFormatter(); + FileStream stream = new FileStream(path, FileMode.Open); + + List>> missionsList = formatter.Deserialize(stream) as List>>; + stream.Close(); + + return missionsList; // ConvertListOfDataModelsToListOfObject(questsList); + } + else + { + Debug.Log("Save file not found in " + path); + } + + return new List>>(); + } + + // ----------------- USELLES IN THIS CLASS ----------------- + #region unused + // Support function + + // 1. From model to data format + + public static MissionConditionData ConvertObjectToDataModel(MissionCondition model) + { + return MissionConditionData.Build(model); + } + + public static List>> ConvertObjectsListToListOfDataModels(List>> modelsList) + { + List>> convertedList = new List>>(); + + foreach (IndexValuePair> dataModel in modelsList) + { + IndexValuePair> conditionsForMapList = new IndexValuePair>(dataModel.Key, new List()); + + foreach (MissionCondition condition in dataModel.Value) + { + conditionsForMapList.Value.Add( + ConvertObjectToDataModel(condition) + ); + } + + convertedList.Add(conditionsForMapList); + } + + return convertedList; + } + + // 2. From data to model format + public static MissionCondition ConvertDataModelToObject(MissionConditionData dataModel) + { + return dataModel.MapDataToObject(); + } + + public static List>> ConvertListOfDataModelsToListOfObject(List>> dataModelsList) + { + List>> conditioncConvertedList = new List>>(); + + foreach (IndexValuePair> dataModel in dataModelsList) + { + IndexValuePair> conditionsForMapList = new IndexValuePair>(dataModel.Key, new List()); + + foreach (MissionConditionData condition in dataModel.Value) + { + conditionsForMapList.Value.Add( + ConvertDataModelToObject(condition) + ); + } + + conditioncConvertedList.Add(conditionsForMapList); + } + + return conditioncConvertedList; + } + #endregion +} \ No newline at end of file diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/SaveMissionConditionManager.cs.meta b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/SaveMissionConditionManager.cs.meta new file mode 100644 index 00000000..3b90b130 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/Condition/SaveMissionConditionManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c2634054ce8ca494fb0c9a5363223117 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataListManager.cs b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataListManager.cs new file mode 100644 index 00000000..85082048 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataListManager.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +class MissionDataListManager : DataListManager +{ + // WE DONT NEED HERE UI MANAGER - because dialoges ane;t associated with ui panels in way like inventory / chest or shop + + public override void AddElementToList(MissionData newElement) + { + Elements.Add(newElement); + } + + public override void RemoveElementFromList(MissionData element) + { + throw new NotImplementedException(); + } +} + diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataListManager.cs.meta b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataListManager.cs.meta new file mode 100644 index 00000000..1d9dc6c7 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataListManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0869a13ed3dcbe94e9ea9ea5356913a1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataLoader.cs b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataLoader.cs new file mode 100644 index 00000000..74cdba3d --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataLoader.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +class MissionDataLoader : SceneBaseDataLoader +{ + public MissionDataLoader(string _objectListName, string _objectFolderName) + { + SaveModelSystem = new SaveMissionManager(); + SaveModelSystem.ObjectFolderName = _objectFolderName; + SaveModelSystem.ObjectListName = _objectListName; + } + + protected override List LoadDynamicData() + { + SaveModelSystem.Path = PathBuilder.BuildSavePath().WithMap(CurrentMap).WithDataType(SceneElementTypeEnum.Dynamic).GetString(); + + return SaveModelSystem.LoadModelList(); + } + + protected override bool SaveDynamicData(List _elements) + { + SaveModelSystem.Path = PathBuilder.BuildSavePath().WithMap(CurrentMap).WithDataType(SceneElementTypeEnum.Dynamic).GetString(); + + return base.SaveDynamicData(_elements); + } + + protected override List LoadGenericData() + { + throw new NotImplementedException(); + } + + protected override bool SaveGenericData(List _elements) + { + throw new NotImplementedException(); + } +} + diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataLoader.cs.meta b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataLoader.cs.meta new file mode 100644 index 00000000..dec3c6eb --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataLoader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6f38b619116e96a4fb4f31949ad37365 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataManager.cs b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataManager.cs new file mode 100644 index 00000000..70324da5 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataManager.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.SceneManagement; + +class MissionDataManager : SceneBaseDataManager +{ + protected override string OBJECT_FOLDER_NAME { get { return "Mission"; } } + protected override string OBJECT_LIST_NAME { get { return "MissionsList"; } } + + [SerializeField] + public List MissionDataList; + + public override void Awake() + { + if (Instance == null) + { + Instance = this; + + // moved from start beacuse we need to prepare env before NpcMissionmanager start registering and uipdating mission model + Debug.Log("Start Mission manager"); + + DynamicDataList = new MissionDataListManager(); + + DataLoader = new MissionDataLoader(OBJECT_LIST_NAME, OBJECT_FOLDER_NAME); + + base.Start(); // (afterStart invoking - to load saved data) + + } + else + { + Destroy(gameObject); + } + } + + // ZMIANA KONCEPCJI + // ZMIAST TRZYMAC SUROWE OBIEKTY TYM RAZEM ZAPISUJMY modele Datai updatujmy obiket w NPC Managerze + + // nadpisujemy by nir duplikowac wywoałania i nadpisyuwanie MissionDataList z Awake + public override void Start() + { + + } + + + protected override void AfterStart() + { + if (OnMapAppearanceMethod.GameStatus == GameStatus.NewGame) + { + if (OnMapAppearanceMethod.Gateway != OnMapAppearanceMethodEnum.NewGame) + UseDynamicSettings(); // if there is nothing saved we will use UseDefaultSettings + else + UseDefaultSettings(); + } + else + { + UseDynamicSettings(); + } + } + + + protected SceneBaseDataManager GetObjectType() + { + return GameObject.FindObjectOfType(); + } + + protected SceneBaseDataManager CreateInstance(ref GameObject managerGameObject) + { + return managerGameObject.AddComponent(); + } + + + + protected override void UseDefaultSettings() + { + DynamicDataList.SetList(new List()); + + MissionDataList = DynamicDataList.GetList(); + + // we dont need to convert anything + // Instead of build elements on scene we collect shops distracted on scene from npc's + } + + protected override void UseDynamicSettings() + { + // when chest detect player in near arrea and player press "c" + // open panel -> chest controller handle Open panel in Scene Chest Manager passing info about what Chest Palyer want to open + // Manager Build panel and pass info about chest content + Debug.Log("UseDynamicSettings"); + LoadDynamicData(); + + + // VERy VERY provisional SOLUTION + if (DynamicDataList.GetList().Count == 0) + { + UseDefaultSettings(); + } + + MissionDataList = DynamicDataList.GetList(); + } + + + public void RegisterMission(Mission newMission) + { + if (DynamicDataList.GetList().Where(mission => mission.SpeakerName == newMission.SpeakerName && mission.MissionName == newMission.MissionName).Any()) + { + // if dial is already registered - update it + UpdateMission(newMission); + } + else + { + var misssionData = SaveMissionManager.ConvertObjectToDataModel(newMission); + + //DynamicDataList.AddElementToList(multiDialogueData); - nie dodwaca bo modyfikacja jednej duplikuje + MissionDataList.Add(misssionData); + } + } + + // update proggress in dialogue - BUT FUNCTION BELOW SYNCH THIS ALREADY righhr??? + public void UpdateMission(Mission newMission) + { + if (!DynamicDataList.GetList().Where(mission => mission.SpeakerName == newMission.SpeakerName && mission.MissionName == newMission.MissionName).Any()) + Debug.LogError($"There is no registered dialoge like {newMission.SpeakerName}"); + else + { + var missionData = SaveMissionManager.ConvertObjectToDataModel(newMission); + + + MissionDataList.RemoveAll(mission => mission.SpeakerName == newMission.SpeakerName && mission.MissionName == newMission.MissionName); + + // duplicated from registerDialogue + MissionDataList.Add(missionData); + } + } + + public MissionData? GetMission(Mission newMission) + { + return DynamicDataList.GetList().Where(mission => mission.SpeakerName == newMission.SpeakerName && mission.MissionName == newMission.MissionName).FirstOrDefault(); + } + + public override bool SaveDynamicData() + { + return SaveData(MissionDataList, SceneElementTypeEnum.Dynamic); + } +} \ No newline at end of file diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataManager.cs.meta b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataManager.cs.meta new file mode 100644 index 00000000..7a528d9e --- /dev/null +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/MissionDataManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b1278ade00000f84ba28d4671ff3f7f9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Application/Mission/Save/SaveMissionManager.cs b/Assets/Scripts/REFACTORING/Application/Mission/Save/SaveMissionManager.cs index 97147a40..be489a13 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/Save/SaveMissionManager.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/Save/SaveMissionManager.cs @@ -4,14 +4,14 @@ using System.Runtime.Serialization.Formatters.Binary; using UnityEngine; -class SaveMissionManager : SaveModelSystem +class SaveMissionManager : SaveModelSystem { - public override bool SaveModelItem(Mission model) + public override bool SaveModelItem(MissionData model) { return base.SaveModelItem(model); } - public override bool SaveModelList(List list) + public override bool SaveModelList(List list) { BinaryFormatter formatter = new BinaryFormatter(); @@ -20,7 +20,7 @@ class SaveMissionManager : SaveModelSystem if (!Directory.Exists(Path)) Directory.CreateDirectory(Path); /* Main logic of conversion data format */ - var data = ConvertObjectsListToListOfDataModels(list); + var data = list; // ConvertObjectsListToListOfDataModels(list); FileStream stream = new FileStream( Path + GetFileName(ObjectListName), @@ -33,12 +33,12 @@ class SaveMissionManager : SaveModelSystem return true; } - public override Mission LoadModelItem() + public override MissionData LoadModelItem() { return base.LoadModelItem(); } - public override List LoadModelList() + public override List LoadModelList() { string path = Path + GetFileName(ObjectListName); @@ -47,25 +47,27 @@ class SaveMissionManager : SaveModelSystem BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); - List questsList = formatter.Deserialize(stream) as List; + List missionsList = formatter.Deserialize(stream) as List; stream.Close(); - return ConvertListOfDataModelsToListOfObject(questsList); + return missionsList; // ConvertListOfDataModelsToListOfObject(questsList); } else { Debug.Log("Save file not found in " + path); } - return new List(); + return new List(); } + // ----------------- USELLES IN THIS CLASS ----------------- + #region unused // Support function // 1. From model to data format public static MissionData ConvertObjectToDataModel(Mission model) { - return new MissionData(); //model + return new MissionData(model); } public static List ConvertObjectsListToListOfDataModels(List modelsList) @@ -97,4 +99,5 @@ class SaveMissionManager : SaveModelSystem return convertedList; } + #endregion } diff --git a/Assets/Scripts/REFACTORING/Application/Player/PlayerActions.cs b/Assets/Scripts/REFACTORING/Application/Player/PlayerActions.cs index 0faa7972..7ea5f799 100644 --- a/Assets/Scripts/REFACTORING/Application/Player/PlayerActions.cs +++ b/Assets/Scripts/REFACTORING/Application/Player/PlayerActions.cs @@ -31,8 +31,10 @@ public class PlayerActions : MonoBehaviour Debug.Log($"Give reward - {reward.Cash}"); // 3. Save changes - GameObject.FindObjectOfType().SavePlayerEquipmentItems(); - GameObject.FindObjectOfType().SavePlayerInventory(); - GameObject.FindObjectOfType().SaveAccountBalance(); + // TODO - sync saving process reward / mission proggress + // currently its saving only after changing scene and saving manually by player + //GameObject.FindObjectOfType().SavePlayerEquipmentItems(); + //GameObject.FindObjectOfType().SavePlayerInventory(); + //GameObject.FindObjectOfType().SaveAccountBalance(); } } diff --git a/Assets/Scripts/REFACTORING/Application/Shared/Manager/Panel/SceneBaseDataManager.cs b/Assets/Scripts/REFACTORING/Application/Shared/Manager/Panel/SceneBaseDataManager.cs index c3825fad..d6f8113a 100644 --- a/Assets/Scripts/REFACTORING/Application/Shared/Manager/Panel/SceneBaseDataManager.cs +++ b/Assets/Scripts/REFACTORING/Application/Shared/Manager/Panel/SceneBaseDataManager.cs @@ -154,7 +154,6 @@ public abstract class SceneBaseDataManager : MonoBehaviour // approach: // 1. get from outside, update local list && us it // 2. Handle list synchronized all the time & pass local list - Debug.Log(DynamicDataList.GetList()); return SaveData(DynamicDataList.GetList(), SceneElementTypeEnum.Dynamic); } #endregion diff --git a/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/Panel/Draggable/DraggablePanelController.cs b/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/Panel/Draggable/DraggablePanelController.cs index a560b06b..4fa77bd4 100644 --- a/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/Panel/Draggable/DraggablePanelController.cs +++ b/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/Panel/Draggable/DraggablePanelController.cs @@ -57,15 +57,15 @@ public abstract class DraggablePanelController : PanelController(i, ChildBoxList[i].Item)); } - else + else { UiManager.RemoveByPosition(i); } @@ -86,9 +86,9 @@ public abstract class DraggablePanelController : PanelController(dropItemSlot.Number, tmpDraggedItem)); // !!! remember item from dropped position to future operation !!! diff --git a/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/Panel/WarehousePanel/WarehousePanelController.cs b/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/Panel/WarehousePanel/WarehousePanelController.cs index 7c1a468c..6b3affe8 100644 --- a/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/Panel/WarehousePanel/WarehousePanelController.cs +++ b/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/Panel/WarehousePanel/WarehousePanelController.cs @@ -28,7 +28,6 @@ public abstract class WarehousePanelController : DraggablePanelController public override void DoubleLeftMouseClick(ItemSlot itemSlot) { - Debug.Log("Used item"); if(AllowToUseItemInPanel) { ItemEffectsManager.Instance.UseItemEffect(itemSlot, Type); diff --git a/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/UIBaseManager.cs b/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/UIBaseManager.cs index a4ada27f..5afe01b0 100644 --- a/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/UIBaseManager.cs +++ b/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/UIBaseManager.cs @@ -219,7 +219,6 @@ public abstract class UIBaseManager : MonoBehaviour, ManagerInterface public void Add(T model) { // throw new System.NotImplementedException(); - Elements.Add(model); UpdateList(); diff --git a/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/UIWarehouseManager.cs b/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/UIWarehouseManager.cs index 8a2dd8ad..868340ab 100644 --- a/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/UIWarehouseManager.cs +++ b/Assets/Scripts/REFACTORING/Application/Shared/Manager/UI/UIWarehouseManager.cs @@ -59,7 +59,11 @@ public abstract class UIWarehouseManager : UISlotPanelManager +public interface IModelMapper { public abstract T MapDataToObject(string prefarbAssetName); diff --git a/Assets/Scripts/REFACTORING/Application/UI/Equipment/EquipmentUIManager.cs b/Assets/Scripts/REFACTORING/Application/UI/Equipment/EquipmentUIManager.cs index 96e23d33..7f48ba40 100644 --- a/Assets/Scripts/REFACTORING/Application/UI/Equipment/EquipmentUIManager.cs +++ b/Assets/Scripts/REFACTORING/Application/UI/Equipment/EquipmentUIManager.cs @@ -89,8 +89,8 @@ public class EquipmentUIManager : UIWarehouseManager if (!CheckIfSlotExists(keyPosition)) return; // throw new System.Exception($"Slot with number: {keyPosition} don't exist"); - Debug.Log($"Remove from position: {keyPosition}"); - +/* Debug.Log($"Remove from position: {keyPosition}"); +*/ Elements.RemoveAll(equipment => equipment.Key == keyPosition); Elements.Add(new IndexValuePair(keyPosition, null)); diff --git a/Assets/Scripts/REFACTORING/Models/Mission/Condition.meta b/Assets/Scripts/REFACTORING/Models/Mission/Condition.meta new file mode 100644 index 00000000..e489f4e3 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/Condition.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1da99894524baa749b93f9f38ff2acac +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Models/Mission/Condition/CollectMissionConditionData.cs b/Assets/Scripts/REFACTORING/Models/Mission/Condition/CollectMissionConditionData.cs new file mode 100644 index 00000000..e051255d --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/Condition/CollectMissionConditionData.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +[Serializable] +public class CollectMissionConditionData : MissionConditionData +{ + public CollectMissionConditionData(MissionCondition missionCondition) : base(missionCondition.Type) + { + RequiredElements.Clear(); + + foreach (RequiredSubject requiredSubject in missionCondition.RequiredElements) + { + RequiredElements.Add(new CollectRequiredSubjectData((CollectRequiredSubject)requiredSubject)); + } + } + + public override MissionCondition MapDataToObject(string prefarbAssetName) + { + throw new NotImplementedException(); + } + + public override MissionCondition MapDataToObject() + { + var mappedCondition = new MissionCondition(Type); + + foreach(var requiredElement in RequiredElements) + { + mappedCondition.RequiredElements.Add(requiredElement.MapDataToObject()); + } + + return mappedCondition; + } +} + diff --git a/Assets/Scripts/REFACTORING/Models/Mission/Condition/CollectMissionConditionData.cs.meta b/Assets/Scripts/REFACTORING/Models/Mission/Condition/CollectMissionConditionData.cs.meta new file mode 100644 index 00000000..b471940a --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/Condition/CollectMissionConditionData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 81b8d315cf1ee3444b5630663cf64616 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Models/Mission/Condition/KillMissionConditionData.cs b/Assets/Scripts/REFACTORING/Models/Mission/Condition/KillMissionConditionData.cs new file mode 100644 index 00000000..148e4f33 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/Condition/KillMissionConditionData.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +[Serializable] +public class KillMissionConditionData : MissionConditionData +{ + public KillMissionConditionData(MissionCondition missionCondition) : base(missionCondition.Type) + { + RequiredElements.Clear(); + + foreach (RequiredSubject requiredSubject in missionCondition.RequiredElements) + { +/* var abc = new KillRequiredSubjectData((KillRequiredSubject)requiredSubject); + + + var converter = TypeDescriptor.GetConverter(typeof(KillRequiredSubjectData)); + + + var def = converter.ConvertFrom(abc); + + Debug.Log(def);*/ + + RequiredElements.Add(new KillRequiredSubjectData((KillRequiredSubject)requiredSubject)); + } + } + + public override MissionCondition MapDataToObject(string prefarbAssetName) + { + throw new NotImplementedException(); + } + + public override MissionCondition MapDataToObject() + { + var mappedCondition = new MissionCondition(Type); + + foreach (var requiredElement in RequiredElements) + { + mappedCondition.RequiredElements.Add(requiredElement.MapDataToObject()); + } + + return mappedCondition; + } +} diff --git a/Assets/Scripts/REFACTORING/Models/Mission/Condition/KillMissionConditionData.cs.meta b/Assets/Scripts/REFACTORING/Models/Mission/Condition/KillMissionConditionData.cs.meta new file mode 100644 index 00000000..53eaf1f4 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/Condition/KillMissionConditionData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0fa8be7390fbc1a4dad8aee8ac024e06 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Models/Mission/Condition/MissionConditionData.cs b/Assets/Scripts/REFACTORING/Models/Mission/Condition/MissionConditionData.cs new file mode 100644 index 00000000..74d55c77 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/Condition/MissionConditionData.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +[Serializable] +//abstract - changed for Unity Inspector visualisation requirements +public class MissionConditionData : IModelMapper +{ + [SerializeField] + public MissionTypeEnum Type; + + [SerializeField] + public List RequiredElements = new List(); + + /// + /// Constructor implemented to create object in children classes in main purpose + /// + /// We DON'T implement 'RequiredElements' list here because its MUST be FILLED by objects in specific subtyped (not base one) !!! + /// + /// + protected MissionConditionData(MissionTypeEnum type) + { + Type = type; + } + + // abstract + public virtual MissionCondition MapDataToObject(string prefarbAssetName) { return new MissionCondition(Type); } + + // abstract + public virtual MissionCondition MapDataToObject() { return new MissionCondition(Type); } + + /// + /// Function copied from MissionCondition::Build() + /// + //public abstract MissionConditionData Build(T missionCondition); + // + + public static MissionConditionData Build(MissionCondition missionCondition) + { + switch (missionCondition.Type) + { + case MissionTypeEnum.Kill: + { + Debug.Log("Build - KillMissionCondionData"); + + return new KillMissionConditionData(missionCondition); + } + case MissionTypeEnum.Collect: + { + Debug.Log("Build - CollectMissionConditionData"); + + return new CollectMissionConditionData(missionCondition); + } + default: + { + throw new NotImplementedException("Mission Collection data - constructor"); + } + } + } +} diff --git a/Assets/Scripts/REFACTORING/Models/Mission/Condition/MissionConditionData.cs.meta b/Assets/Scripts/REFACTORING/Models/Mission/Condition/MissionConditionData.cs.meta new file mode 100644 index 00000000..7a4d3da9 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/Condition/MissionConditionData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 572ebb9d86c6e3942bfb6c32249af4db +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Models/Mission/Dialogue/MissionDialogueData.cs b/Assets/Scripts/REFACTORING/Models/Mission/Dialogue/MissionDialogueData.cs index 8e14c6e4..a2063928 100644 --- a/Assets/Scripts/REFACTORING/Models/Mission/Dialogue/MissionDialogueData.cs +++ b/Assets/Scripts/REFACTORING/Models/Mission/Dialogue/MissionDialogueData.cs @@ -4,7 +4,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -class MissionDialogueData : DialogueData +[Serializable] +public class MissionDialogueData : DialogueData { /// /// build Data model based on Object @@ -24,6 +25,5 @@ class MissionDialogueData : DialogueData DialogueStepModelDataList.Add(new DialogueStepData(dialogueStepModelData.WasDisplayed)); } } - } diff --git a/Assets/Scripts/REFACTORING/Models/Mission/Dialogue/MissionDialogueStepData.cs b/Assets/Scripts/REFACTORING/Models/Mission/Dialogue/MissionDialogueStepData.cs deleted file mode 100644 index af7d5266..00000000 --- a/Assets/Scripts/REFACTORING/Models/Mission/Dialogue/MissionDialogueStepData.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -class MissionDialogueStepData -{ - -} - diff --git a/Assets/Scripts/REFACTORING/Models/Mission/MissionData.cs b/Assets/Scripts/REFACTORING/Models/Mission/MissionData.cs index 968c786b..cd6a6e8b 100644 --- a/Assets/Scripts/REFACTORING/Models/Mission/MissionData.cs +++ b/Assets/Scripts/REFACTORING/Models/Mission/MissionData.cs @@ -6,8 +6,14 @@ using System.Threading.Tasks; using UnityEngine; [Serializable] -class MissionData : ModelData +public class MissionData : IModelMapper { + [SerializeField] + public string MissionName; + + [SerializeField] + public string SpeakerName; + [SerializeField] public MissionStatusEnum Status = MissionStatusEnum.None; @@ -17,18 +23,41 @@ class MissionData : ModelData [SerializeField] public List MissionStepsDataList = new List(); - public override Mission MapDataToObject(string prefarbAssetName) + /// + /// build Data model based on Object + /// + /// + public MissionData(Mission mission) + { + MissionName = mission.MissionName; + SpeakerName = mission.SpeakerName; + + Status = mission.Status; + CurrentStep = mission.CurrentStep; + + MissionStepsDataList.Clear(); + + foreach (MissionStepModel missionStepModelData in mission.MissionStepsList) + { + /* + * pass WasDisplayed value from model to data representative class + */ + MissionStepsDataList.Add(new MissionStepData(missionStepModelData)); + } + } + + #region NotImplemented + /* + * we dont want to map it here, we will mark fields in NpcDialogfeManager after each loading and fetching dialogue + */ + public Mission MapDataToObject(string prefarbAssetName) { throw new NotImplementedException(); } - public override Mission MapDataToObject() - { - throw new NotImplementedException(); - } - - protected override Mission TryFindResource(string modelName) + public Mission MapDataToObject() { throw new NotImplementedException(); } + #endregion } diff --git a/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject.meta b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject.meta new file mode 100644 index 00000000..5c9939f1 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 726174bbf90a7ed44808fa10277f88bd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/CollectRequiredSubjectData.cs b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/CollectRequiredSubjectData.cs new file mode 100644 index 00000000..08e6af58 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/CollectRequiredSubjectData.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +[Serializable] +public class CollectRequiredSubjectData : RequiredSubjectData +{ + protected override string MODEL_LOCALIZATION => "Items/"; + + public CollectRequiredSubjectData(int requiredAmount) : base(requiredAmount) { } + + public CollectRequiredSubjectData(int requiredAmount, string requiredObjectName) : base(requiredAmount, requiredObjectName) { } + + public CollectRequiredSubjectData(CollectRequiredSubject requiredSubject) : base(requiredSubject) { } + + + + public override RequiredSubject MapDataToObject(string prefarbAssetName) + { + var newCollectRequirement = new CollectRequiredSubject(RequiredAmount); + + newCollectRequirement.RequiredObject = newCollectRequirement.FindObjectInResource(prefarbAssetName); + + return newCollectRequirement; + } + + public override RequiredSubject MapDataToObject() + { + return new CollectRequiredSubject(RequiredAmount, RequiredObjectName); + } +} diff --git a/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/CollectRequiredSubjectData.cs.meta b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/CollectRequiredSubjectData.cs.meta new file mode 100644 index 00000000..54ca0cac --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/CollectRequiredSubjectData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2ed2e7fa34b0c2948aa8c87d1fafc0ff +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/KillRequiredSubjectData.cs b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/KillRequiredSubjectData.cs new file mode 100644 index 00000000..81c4c2f9 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/KillRequiredSubjectData.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +[Serializable] +/*[TypeConverter(typeof(KillRequiredSubjectDataTypeConverter))] +*/public class KillRequiredSubjectData : RequiredSubjectData +{ + protected override string MODEL_LOCALIZATION => "Enemies/"; + + [SerializeField] + public int CurrentAmount = 0; + + + public KillRequiredSubjectData(int requiredAmount, string requiredObjectName) : base(requiredAmount, requiredObjectName) { } + + public KillRequiredSubjectData(int requiredAmount, string requiredObjectName, int currentAmount) : base(requiredAmount, requiredObjectName) + { + CurrentAmount = currentAmount; + } + + public KillRequiredSubjectData(int requiredAmount, int currentAmount) : base(requiredAmount) { CurrentAmount = currentAmount; } + + + public KillRequiredSubjectData(KillRequiredSubject requiredSubject) : base(requiredSubject) { CurrentAmount = requiredSubject.CurrentAmount; } + + + public override RequiredSubject MapDataToObject(string prefarbAssetName) + { + var newKillRequirement = new KillRequiredSubject(RequiredAmount, CurrentAmount); + + newKillRequirement.RequiredObject = newKillRequirement.FindObjectInResource(prefarbAssetName); + + return newKillRequirement; + } + + public override RequiredSubject MapDataToObject() + { + return new KillRequiredSubject(RequiredAmount, RequiredObjectName, CurrentAmount); + } +} + + +/*[TypeConverter(typeof(KillRequiredSubjectDataTypeConverter))] +public class KillRequiredSubjectDataTypeConverter : TypeConverter +{ + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(RequiredSubjectData) || base.CanConvertFrom(context, sourceType); + } + + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + var castedFrom = value as RequiredSubjectData; + + return castedFrom != null + ? new KillRequiredSubjectData(castedFrom.RequiredAmount, castedFrom.RequiredObjectName) + : base.ConvertFrom(context, culture, value) + ; + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + var castedTo = value as KillRequiredSubjectData; + + return destinationType == typeof(RequiredSubjectData) && castedTo != null + ? new RequiredSubjectData(castedTo.RequiredAmount, castedTo.RequiredObjectName) + : base.ConvertTo(context, culture, value, destinationType) + ; + } +}*/ + diff --git a/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/KillRequiredSubjectData.cs.meta b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/KillRequiredSubjectData.cs.meta new file mode 100644 index 00000000..6155e441 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/KillRequiredSubjectData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f1f1d299662039c4eaf78d604b8c76bd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/RequiredSubjectData.cs b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/RequiredSubjectData.cs new file mode 100644 index 00000000..3bf67625 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/RequiredSubjectData.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +[Serializable] +//abstract - changed for Unity Inspector visualisation requirements +public class RequiredSubjectData : IModelMapper +{ + protected virtual string SPRITE_LOCALIZATION => "Sprites/Object Sprites/"; + protected virtual string MODEL_LOCALIZATION => ""; + + [SerializeField] + public int RequiredAmount; + + [SerializeField] + public string RequiredObjectName; + + public RequiredSubjectData(int requiredAmount) + { + RequiredAmount = requiredAmount; + } + + public RequiredSubjectData(int requiredAmount, string requiredObjectName) + { + RequiredAmount = requiredAmount; + + RequiredObjectName = requiredObjectName; + } + + public RequiredSubjectData(RequiredSubject requiredSubject) + { + RequiredAmount = requiredSubject.RequiredAmount; + + RequiredObjectName = requiredSubject.RequiredObject.name; // NAME of the PREFAB + } + + // abstract + public virtual RequiredSubject MapDataToObject(string prefarbAssetName) { return new RequiredSubject(0); } // { return new RequiredSubject(RequiredAmount, RequiredObjectName); } + + // abstarct + public virtual RequiredSubject MapDataToObject() { return new RequiredSubject(0); } // { return new RequiredSubject(RequiredAmount, RequiredObjectName); } +} diff --git a/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/RequiredSubjectData.cs.meta b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/RequiredSubjectData.cs.meta new file mode 100644 index 00000000..0f987a05 --- /dev/null +++ b/Assets/Scripts/REFACTORING/Models/Mission/RequiredSubject/RequiredSubjectData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3af6b21b3495e5742ab61a3a61e8854f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/REFACTORING/Models/Mission/Step/MissionStepData.cs b/Assets/Scripts/REFACTORING/Models/Mission/Step/MissionStepData.cs index 8371c195..18b0e665 100644 --- a/Assets/Scripts/REFACTORING/Models/Mission/Step/MissionStepData.cs +++ b/Assets/Scripts/REFACTORING/Models/Mission/Step/MissionStepData.cs @@ -3,14 +3,24 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using UnityEngine; - -class MissionStepData : IModelMapper +[Serializable] +public class MissionStepData : IModelMapper { - MissionStepStatusEnum Status; + [SerializeField] + public MissionStepStatusEnum Status; - MissionDialogueData MissionDialogueData; + [SerializeField] + public MissionDialogueData MissionDialogueData; + public MissionStepData(MissionStepModel missionStepModel) + { + Status = missionStepModel.Status; + + MissionDialogueData = new MissionDialogueData(missionStepModel.DialogueStep); + } + public MissionStepModel MapDataToObject(string prefarbAssetName) { throw new NotImplementedException(); diff --git a/Assets/Scripts/SaveController.cs b/Assets/Scripts/SaveController.cs index 7602adde..2b0317cd 100644 --- a/Assets/Scripts/SaveController.cs +++ b/Assets/Scripts/SaveController.cs @@ -74,4 +74,13 @@ public class SaveController : MonoBehaviour if (MultiDialogueDataManager.Instance) MultiDialogueDataManager.Instance.SaveDynamicData(); } + + public void SaveMissions() + { + if (MissionDataManager.Instance ) //&& MissionConditionDataManager.Instance + { + MissionDataManager.Instance.SaveDynamicData(); + MissionConditionDataManager.Instance.SaveDynamicData(); + } + } }