From 09058f1451fb4391cf21dd0fea201797a6008cbe Mon Sep 17 00:00:00 2001 From: kabix09 Date: Sun, 16 Oct 2022 19:40:44 +0200 Subject: [PATCH] Add Panels and Dialogue module --- Assets/Resources/Dialogue/AcceptButton.prefab | 199 +++++++++++++++ Assets/Resources/Dialogue/BaseButton.prefab | 183 ++++++++++++++ .../Resources/Dialogue/ContinueButton.prefab | 183 ++++++++++++++ .../Resources/Dialogue/DialoguePanel.prefab | 237 ++++++++++++++++++ Assets/Resources/Dialogue/RejectButton.prefab | 199 +++++++++++++++ .../Domain/Dialogue/DialogueController.cs | 88 +++++++ .../Domain/Dialogue/Model/DialogueModel.cs | 31 +++ .../Dialogue/Model/DialogueStepModel.cs | 55 ++++ .../Domain/DialoguePanel/AbstractPanel.cs | 28 +++ .../DialoguePanel/Enum/PanelButtonEnum.cs | 10 + .../Factory/PanelComponentFactory.cs | 96 +++++++ .../DialoguePanel/Factory/PanelFactory.cs | 128 ++++++++++ Assets/Scripts/Domain/DialoguePanel/IPanel.cs | 6 + .../Loader/DialoguePanelsPrefabsLoader.cs | 34 +++ .../DialoguePanel/Model/ButtonPanelModel.cs | 34 +++ .../Model/PanelButtonStepModel.cs | 27 ++ Assets/Scripts/Domain/DialoguePanel/Panel.cs | 56 +++++ .../Domain/DialoguePanel/QuestionPanel.cs | 92 +++++++ Assets/Scripts/Domain/Npc/NPCDialogue.cs | 19 ++ Assets/Scripts/Domain/NpcDialogueManager.cs | 60 +++++ Assets/Scripts/Domain/PanelTest.cs | 61 +++++ ProjectSettings/TagManager.asset | 1 + 22 files changed, 1827 insertions(+) create mode 100644 Assets/Resources/Dialogue/AcceptButton.prefab create mode 100644 Assets/Resources/Dialogue/BaseButton.prefab create mode 100644 Assets/Resources/Dialogue/ContinueButton.prefab create mode 100644 Assets/Resources/Dialogue/DialoguePanel.prefab create mode 100644 Assets/Resources/Dialogue/RejectButton.prefab create mode 100644 Assets/Scripts/Domain/Dialogue/DialogueController.cs create mode 100644 Assets/Scripts/Domain/Dialogue/Model/DialogueModel.cs create mode 100644 Assets/Scripts/Domain/Dialogue/Model/DialogueStepModel.cs create mode 100644 Assets/Scripts/Domain/DialoguePanel/AbstractPanel.cs create mode 100644 Assets/Scripts/Domain/DialoguePanel/Enum/PanelButtonEnum.cs create mode 100644 Assets/Scripts/Domain/DialoguePanel/Factory/PanelComponentFactory.cs create mode 100644 Assets/Scripts/Domain/DialoguePanel/Factory/PanelFactory.cs create mode 100644 Assets/Scripts/Domain/DialoguePanel/IPanel.cs create mode 100644 Assets/Scripts/Domain/DialoguePanel/Loader/DialoguePanelsPrefabsLoader.cs create mode 100644 Assets/Scripts/Domain/DialoguePanel/Model/ButtonPanelModel.cs create mode 100644 Assets/Scripts/Domain/DialoguePanel/Model/PanelButtonStepModel.cs create mode 100644 Assets/Scripts/Domain/DialoguePanel/Panel.cs create mode 100644 Assets/Scripts/Domain/DialoguePanel/QuestionPanel.cs create mode 100644 Assets/Scripts/Domain/Npc/NPCDialogue.cs create mode 100644 Assets/Scripts/Domain/NpcDialogueManager.cs create mode 100644 Assets/Scripts/Domain/PanelTest.cs diff --git a/Assets/Resources/Dialogue/AcceptButton.prefab b/Assets/Resources/Dialogue/AcceptButton.prefab new file mode 100644 index 00000000..4c0461b8 --- /dev/null +++ b/Assets/Resources/Dialogue/AcceptButton.prefab @@ -0,0 +1,199 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &7804396124948926029 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7804396124948926028} + - component: {fileID: 7804396124948926030} + - component: {fileID: 7804396124948926031} + - component: {fileID: 2630723174740830644} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7804396124948926028 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7804396124948926029} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.95, y: 4.5, z: 1} + m_Children: [] + m_Father: {fileID: 7804396125553486711} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 1, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7804396124948926030 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7804396124948926029} + m_CullTransparentMesh: 1 +--- !u!114 &7804396124948926031 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7804396124948926029} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.63529414, g: 0.44705883, b: 0.2901961, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 12800000, guid: 6b506a7e42917d6489d0e806d6b4f62d, type: 2} + m_FontSize: 0 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 0 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: << yes >> +--- !u!114 &2630723174740830644 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7804396124948926029} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a7c996be5c675ec4eb062e7ae1509118, type: 3} + m_Name: + m_EditorClassIdentifier: + textEnglish: << yes >> + textPolish: << tak >> + displayText: {fileID: 7804396124948926031} +--- !u!1 &7804396125553486708 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7804396125553486711} + - component: {fileID: 7804396125553486665} + - component: {fileID: 7804396125553486710} + m_Layer: 5 + m_Name: AcceptButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7804396125553486711 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7804396125553486708} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7804396124948926028} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 90, y: 270} + m_SizeDelta: {x: 100, y: 80} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7804396125553486665 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7804396125553486708} + m_CullTransparentMesh: 1 +--- !u!114 &7804396125553486710 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7804396125553486708} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 0} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 0} + m_TargetAssemblyTypeName: NPCDialogue, Assembly-CSharp + m_MethodName: QuestAccepted + 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/Dialogue/BaseButton.prefab b/Assets/Resources/Dialogue/BaseButton.prefab new file mode 100644 index 00000000..5bb0c91b --- /dev/null +++ b/Assets/Resources/Dialogue/BaseButton.prefab @@ -0,0 +1,183 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &5110571134455525712 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5110571134455525713} + - component: {fileID: 5110571134455525715} + - component: {fileID: 5110571134455525714} + m_Layer: 5 + m_Name: BaseButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &5110571134455525713 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5110571134455525712} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 5110571134592049265} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 105, y: 155} + m_SizeDelta: {x: 130, y: 80} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &5110571134455525715 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5110571134455525712} + m_CullTransparentMesh: 1 +--- !u!114 &5110571134455525714 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5110571134455525712} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 0} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 0} + m_TargetAssemblyTypeName: NPCDialogue, Assembly-CSharp + m_MethodName: EndDialogue + 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 +--- !u!1 &5110571134592049264 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5110571134592049265} + - component: {fileID: 5110571134592049267} + - component: {fileID: 5110571134592049266} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &5110571134592049265 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5110571134592049264} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.95, y: 4.5, z: 1} + m_Children: [] + m_Father: {fileID: 5110571134455525713} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 130, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &5110571134592049267 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5110571134592049264} + m_CullTransparentMesh: 1 +--- !u!114 &5110571134592049266 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5110571134592049264} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.63529414, g: 0.44705883, b: 0.2901961, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 12800000, guid: 6b506a7e42917d6489d0e806d6b4f62d, type: 2} + m_FontSize: 0 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 0 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: diff --git a/Assets/Resources/Dialogue/ContinueButton.prefab b/Assets/Resources/Dialogue/ContinueButton.prefab new file mode 100644 index 00000000..432f76ee --- /dev/null +++ b/Assets/Resources/Dialogue/ContinueButton.prefab @@ -0,0 +1,183 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1848719199912094900 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1848719199912094899} + - component: {fileID: 1848719199912094897} + - component: {fileID: 1848719199912094898} + m_Layer: 5 + m_Name: ContinueButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1848719199912094899 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1848719199912094900} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1.2, y: 1.2, z: 1} + m_Children: + - {fileID: 1848719200192448991} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 0} + m_AnchoredPosition: {x: -100, y: 150} + m_SizeDelta: {x: 115, y: 90} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &1848719199912094897 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1848719199912094900} + m_CullTransparentMesh: 1 +--- !u!114 &1848719199912094898 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1848719199912094900} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 0} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 0} + m_TargetAssemblyTypeName: NPCDialogue, Assembly-CSharp + m_MethodName: DisplayNextSentence + 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 +--- !u!1 &1848719200192448960 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1848719200192448991} + - component: {fileID: 1848719200192448989} + - component: {fileID: 1848719200192448990} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1848719200192448991 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1848719200192448960} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.95, y: 4.5, z: 1} + m_Children: [] + m_Father: {fileID: 1848719199912094899} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &1848719200192448989 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1848719200192448960} + m_CullTransparentMesh: 1 +--- !u!114 &1848719200192448990 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1848719200192448960} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.63529414, g: 0.44705883, b: 0.2901961, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 12800000, guid: 6b506a7e42917d6489d0e806d6b4f62d, type: 2} + m_FontSize: 0 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 0 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: continue >> diff --git a/Assets/Resources/Dialogue/DialoguePanel.prefab b/Assets/Resources/Dialogue/DialoguePanel.prefab new file mode 100644 index 00000000..ac6e838c --- /dev/null +++ b/Assets/Resources/Dialogue/DialoguePanel.prefab @@ -0,0 +1,237 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2835830909972040042 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2835830909972040045} + - component: {fileID: 2835830909972040047} + - component: {fileID: 2835830909972040044} + m_Layer: 5 + m_Name: Header + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2835830909972040045 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2835830909972040042} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1.2, y: 6, z: 1} + m_Children: [] + m_Father: {fileID: 2835830911057077560} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 140, y: -154.71451} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2835830909972040047 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2835830909972040042} + m_CullTransparentMesh: 1 +--- !u!114 &2835830909972040044 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2835830909972040042} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: 6b506a7e42917d6489d0e806d6b4f62d, type: 2} + m_Color: {r: 0.63529414, g: 0.44705886, b: 0.2901961, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 12800000, guid: 6b506a7e42917d6489d0e806d6b4f62d, type: 2} + m_FontSize: 0 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 0 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: NPC NAME +--- !u!1 &2835830910843601523 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2835830910843601522} + - component: {fileID: 2835830910843601524} + - component: {fileID: 2835830910843601525} + m_Layer: 5 + m_Name: Content + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2835830910843601522 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2835830910843601523} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 5, z: 1} + m_Children: [] + m_Father: {fileID: 2835830911057077560} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 394, y: -412} + m_SizeDelta: {x: 700, y: 60} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2835830910843601524 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2835830910843601523} + m_CullTransparentMesh: 1 +--- !u!114 &2835830910843601525 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2835830910843601523} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Here is what the dialogue says +--- !u!1 &2835830911057077561 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2835830911057077560} + - component: {fileID: 2835830911057077562} + - component: {fileID: 2835830911057077563} + m_Layer: 5 + m_Name: DialoguePanel + m_TagString: UIPanel + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2835830911057077560 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2835830911057077561} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.95, y: 0.2, z: 1} + m_Children: + - {fileID: 2835830909972040045} + - {fileID: 2835830910843601522} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0} + m_AnchorMax: {x: 0.5, y: 0} + m_AnchoredPosition: {x: 0, y: 75} + m_SizeDelta: {x: 800, y: 665} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2835830911057077562 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2835830911057077561} + m_CullTransparentMesh: 1 +--- !u!114 &2835830911057077563 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2835830911057077561} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 99ef742ea21894b4d995d1bc6209bd91, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 diff --git a/Assets/Resources/Dialogue/RejectButton.prefab b/Assets/Resources/Dialogue/RejectButton.prefab new file mode 100644 index 00000000..a59f74e7 --- /dev/null +++ b/Assets/Resources/Dialogue/RejectButton.prefab @@ -0,0 +1,199 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &3843350996313346458 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3843350996313346459} + - component: {fileID: 3843350996313346457} + - component: {fileID: 3843350996313346456} + - component: {fileID: 9050739336549364503} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3843350996313346459 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3843350996313346458} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.95, y: 4.5, z: 1} + m_Children: [] + m_Father: {fileID: 3843350996714111163} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 130, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &3843350996313346457 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3843350996313346458} + m_CullTransparentMesh: 1 +--- !u!114 &3843350996313346456 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3843350996313346458} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.63529414, g: 0.44705883, b: 0.2901961, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 12800000, guid: 6b506a7e42917d6489d0e806d6b4f62d, type: 2} + m_FontSize: 0 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 0 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: << not now >> +--- !u!114 &9050739336549364503 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3843350996313346458} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a7c996be5c675ec4eb062e7ae1509118, type: 3} + m_Name: + m_EditorClassIdentifier: + textEnglish: << not now >> + textPolish: << nie teraz >> + displayText: {fileID: 3843350996313346456} +--- !u!1 &3843350996714111162 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3843350996714111163} + - component: {fileID: 3843350996714111161} + - component: {fileID: 3843350996714111160} + m_Layer: 5 + m_Name: RejectButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3843350996714111163 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3843350996714111162} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 3843350996313346459} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 105, y: 155} + m_SizeDelta: {x: 130, y: 80} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &3843350996714111161 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3843350996714111162} + m_CullTransparentMesh: 1 +--- !u!114 &3843350996714111160 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3843350996714111162} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 0} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 0} + m_TargetAssemblyTypeName: NPCDialogue, Assembly-CSharp + m_MethodName: EndDialogue + 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/Scripts/Domain/Dialogue/DialogueController.cs b/Assets/Scripts/Domain/Dialogue/DialogueController.cs new file mode 100644 index 00000000..20ee95e9 --- /dev/null +++ b/Assets/Scripts/Domain/Dialogue/DialogueController.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; + +[Serializable] +public class DialogueController +{ + public Queue listOfDialogue = new Queue(); + + private UnityEvent EndOfDialogueStepAction = new UnityEvent(); + + [SerializeField] + public GameObject CurrentPanel; + + /// + /// Set panel info (panel, coords, text, buttons) + /// + /// + public void AddSentence(DialogueModel dialogueModel) + { + listOfDialogue.Enqueue(dialogueModel); + } + +/* + * TODO add endpoints to setup button sctions via others scripyts ! ! ! + public void AddButton(PanelButtonStepModel _buttonModel) + { + Buttons.Add(_buttonModel); + } + + public void SetButtons(List _buttonsModelList) + { + Buttons = _buttonsModelList; + } +*/ + + + public void SetActionAfterDialogueEnds(UnityEvent _endOfDialogueStepAction) + { + EndOfDialogueStepAction = _endOfDialogueStepAction; + } + public void SetActionAfterDialogueEnds(Action _finishDialogueAction) + { + EndOfDialogueStepAction.AddListener( new UnityAction( _finishDialogueAction)); + } + + public void Show(DialogueModel panelModel) + { + Panel panelDis = panelModel.Panel("Kabix", panelModel); + panelDis.PanelInstance = panelDis.BuildPanel(); + panelDis.SetContinueButtonAction(ShowNextPanel, this); + + CurrentPanel = panelDis.PanelInstance; + } + + + private void ShowNextPanel(DialogueController parentDialController) + { + if (listOfDialogue.Count == 0) + { + MonoBehaviour.Destroy(parentDialController.CurrentPanel); + FinishDialogue(); + } + else + { + MonoBehaviour.Destroy(parentDialController.CurrentPanel); + + DialogueModel nextPanel = parentDialController.listOfDialogue.Dequeue(); + + Show(nextPanel); + } + } + + // if palyer click last dialogue panel's "continue" button then ShowNextPanel + // function invoke this method whioch contain external action :D - MAGIC + public void FinishDialogue() + { + // set uoe everything whats is needed to change after finish dialogue + // eg. + // - add task to list + // - get reward + // - mark quest as completed :D + + EndOfDialogueStepAction.Invoke(); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Domain/Dialogue/Model/DialogueModel.cs b/Assets/Scripts/Domain/Dialogue/Model/DialogueModel.cs new file mode 100644 index 00000000..d4692a6e --- /dev/null +++ b/Assets/Scripts/Domain/Dialogue/Model/DialogueModel.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[Serializable] +public class DialogueModel // where TPanel : AbstractPanel +{ + public Func Panel = PanelFactory.BasePanel; + + [SerializeField] + public string Sentence; // { get; set; } // make set private but this will block inspector + + [SerializeField] + public List Buttons = new List(); + + + public DialogueModel() { } + + public DialogueModel(string _sentence) + { + Sentence = _sentence; + } + + public DialogueModel(string _sentence, List _buttonsModelsList) + { + Sentence = _sentence; + + Buttons = _buttonsModelsList; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Domain/Dialogue/Model/DialogueStepModel.cs b/Assets/Scripts/Domain/Dialogue/Model/DialogueStepModel.cs new file mode 100644 index 00000000..e7c42a1b --- /dev/null +++ b/Assets/Scripts/Domain/Dialogue/Model/DialogueStepModel.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; + +// change to "mission step" model in future +[Serializable] +public class DialogueStepModel +{ + [SerializeField] // this flag tell whatewer dialoge ware already display to user + public bool WasDisplayed = false; + + [SerializeField] // list to map to queue in DialogueController + public List ListOfSentences = new List(); + + [SerializeField] + public List Rewards; + + [SerializeField] + public UnityEvent EndOfDialogueStepAction = new UnityEvent(); + + + + // for displaying set of sentences in one display + public DialogueController DialogueController { get; protected set; } + + + public DialogueStepModel() { } + + public DialogueStepModel(DialogueController _dialogueController) + { + DialogueController = _dialogueController; + } + + /// + /// Just convert list to queue structure :D + /// + public virtual void Build() + { + // 1. Clear previous setups + + // 2. Map first structur into second + DialogueController = new DialogueController(); + + foreach (DialogueModel DialogueModel in ListOfSentences) + { + // Pass data to builded panel (name, sentence, buttons) + DialogueController.AddSentence(DialogueModel); + } + + // 3. Bind finishing action + DialogueController.SetActionAfterDialogueEnds(EndOfDialogueStepAction); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Domain/DialoguePanel/AbstractPanel.cs b/Assets/Scripts/Domain/DialoguePanel/AbstractPanel.cs new file mode 100644 index 00000000..a2193ea2 --- /dev/null +++ b/Assets/Scripts/Domain/DialoguePanel/AbstractPanel.cs @@ -0,0 +1,28 @@ +using UnityEngine; + +public abstract class AbstractPanel : IPanel +{ + // Panel data + public Vector3 Position { get; set; } + public Vector2 Size { get; set; } + public Vector3 Scale { get; set; } + + public AbstractPanel() { } + + public AbstractPanel(Vector3 _position, Vector2 _size, Vector3 _scale) + { + Position = _position; + Size = _size; + Scale = _scale; + } + + /// + /// Must be overwritten in childern class + /// + /// + public virtual GameObject BuildPanel() + { + throw new System.NotImplementedException(); + } +} + diff --git a/Assets/Scripts/Domain/DialoguePanel/Enum/PanelButtonEnum.cs b/Assets/Scripts/Domain/DialoguePanel/Enum/PanelButtonEnum.cs new file mode 100644 index 00000000..5cfe7f77 --- /dev/null +++ b/Assets/Scripts/Domain/DialoguePanel/Enum/PanelButtonEnum.cs @@ -0,0 +1,10 @@ +// if you want to add new button and new button prefab you must: +// - add button mark to this enum +// - add new compose function to PanelComponentFactory class +public enum PanelButtonEnum +{ + Continue = 0, + Base = 1, // no type button + Accept = 2, + Reject = 3 +} \ No newline at end of file diff --git a/Assets/Scripts/Domain/DialoguePanel/Factory/PanelComponentFactory.cs b/Assets/Scripts/Domain/DialoguePanel/Factory/PanelComponentFactory.cs new file mode 100644 index 00000000..3f25c35b --- /dev/null +++ b/Assets/Scripts/Domain/DialoguePanel/Factory/PanelComponentFactory.cs @@ -0,0 +1,96 @@ +using UnityEngine; +using UnityEngine.UI; + +public static class PanelComponentFactory +{ + /// + /// + /// + /// + /// + /// + /// + public static GameObject BuildCustomPanel(Vector3 position, Vector2 size, Vector3 scale) + { + var panel = DialoguePanelsPrefabsList.GetPanel(); + + panel.GetComponent().position = position; + panel.GetComponent().localScale = scale; + panel.GetComponent().sizeDelta = size; + + + GameObject prefab = MonoBehaviour.Instantiate(panel, panel.GetComponent().localPosition, panel.transform.rotation) as GameObject; + prefab.name = "DialoguePanel"; + + prefab.transform.SetParent(GameObject.FindGameObjectWithTag("GUI").transform, false); + + GameObject continueButton = BuildContinueButton(new Vector3(-100, 150, 0), new Vector2(115, 90), new Vector3(1.2f, 1.2f, 1)); + continueButton.transform.SetParent(prefab.transform, false); + + return prefab; + } + + public static GameObject BuildCustomButton(ButtonPanelModel answerModel) + { + var panel = DialoguePanelsPrefabsList.GetBaseButton(); + + panel.GetComponent().position = answerModel.Position; + panel.GetComponent().localScale = answerModel.Scale; + panel.GetComponent().sizeDelta = answerModel.Size; + + GameObject prefab = MonoBehaviour.Instantiate(panel, panel.GetComponent().localPosition, panel.transform.rotation) as GameObject; + prefab.name = answerModel.Response; + + // Assign content + prefab.transform.Find("Text").GetComponent().text = answerModel.Response; + + // Assign actions + prefab.GetComponent