Fix dialogue modifications

This commit is contained in:
kabix09 2022-12-04 18:42:34 +01:00
parent fb692e1bb8
commit 20f5ebe048
84 changed files with 625 additions and 360 deletions

View File

@ -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: 45b41589283138641ba006c2243b0637, type: 3}
m_Name: BossThugDialPl
m_EditorClassIdentifier:
CurrentDialogue: 0
MultiWayDialogue:
- Key: 0
Value:
- WasDisplayed: 0
ListOfSentences:
- Sentence: Who are you? Hod did you get past my guards?!
Buttons: []
- Sentence: Don't answer. I don't care anyway. You're dead to me/.
Buttons: []
EndOfDialogueStepAction:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 5064228440392526989, guid: df6c42c9616028a4badca81953f003ab, type: 3}
m_TargetAssemblyTypeName: NpcDialogueManager, Assembly-CSharp
m_MethodName: DialogueEndAction
m_Mode: 3
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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b47b2441f5e5f9e4ab687bf2a2fddbfa
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 77f7d32936a4c7e4eb701860aa12e1dd guid: 90d7448077899e542a82198b14160cc1
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -13,7 +13,7 @@ GameObject:
- component: {fileID: 482428332992622010} - component: {fileID: 482428332992622010}
- component: {fileID: 482428332992622011} - component: {fileID: 482428332992622011}
- component: {fileID: 482428332992622007} - component: {fileID: 482428332992622007}
- component: {fileID: 5064228440392526989} - component: {fileID: 4267060477434669900}
- component: {fileID: 482428332992622006} - component: {fileID: 482428332992622006}
- component: {fileID: 482428332992622001} - component: {fileID: 482428332992622001}
- component: {fileID: -4365747932373452915} - component: {fileID: -4365747932373452915}
@ -35,6 +35,7 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -2.5, y: 75, z: 10} m_LocalPosition: {x: -2.5, y: 75, z: 10}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
@ -50,6 +51,7 @@ SpriteRenderer:
m_CastShadows: 0 m_CastShadows: 0
m_ReceiveShadows: 0 m_ReceiveShadows: 0
m_DynamicOccludee: 1 m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1 m_MotionVectors: 1
m_LightProbeUsage: 1 m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1 m_ReflectionProbeUsage: 1
@ -153,7 +155,7 @@ CircleCollider2D:
m_Offset: {x: 0, y: -0.5} m_Offset: {x: 0, y: -0.5}
serializedVersion: 2 serializedVersion: 2
m_Radius: 1.2 m_Radius: 1.2
--- !u!114 &5064228440392526989 --- !u!114 &4267060477434669900
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -162,159 +164,22 @@ MonoBehaviour:
m_GameObject: {fileID: 482428332992622009} m_GameObject: {fileID: 482428332992622009}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f5e03e1acc0dd994786778db1f72ce69, type: 3} m_Script: {fileID: 11500000, guid: 2bd5e7fa2661ee649861ce0b80373740, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
DialogueStepsList: DialogueTemplate: {fileID: 11400000, guid: b47b2441f5e5f9e4ab687bf2a2fddbfa, type: 2}
- WasDisplayed: 0 Dialogue: {fileID: 0}
ListOfSentences: EndactionEventList:
- Sentence: Who are you? How did you get past my guards?! - Key:
Buttons: [] Key: 0
- Sentence: Don't answer, I don't care anyway. You're dead to me. Value: 0
Buttons: []
Rewards: []
EndOfDialogueStepAction:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 482428332992622001}
m_TargetAssemblyTypeName: BossThug, Assembly-CSharp
m_MethodName: ChanegStatusToAttack
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
CurrentDialogue: 0
MultiWayDialogue:
- Key: 0
Value: Value:
- WasDisplayed: 0
ListOfSentences:
- Sentence: test
Buttons: []
- Sentence: test 1.1
Buttons:
- ButtonName: Ok
Type: 1
ButtonActions:
m_PersistentCalls: m_PersistentCalls:
m_Calls: m_Calls:
- m_Target: {fileID: 5064228440392526989} - m_Target: {fileID: 4267060477434669900}
m_TargetAssemblyTypeName: NpcDialogueManager, Assembly-CSharp m_TargetAssemblyTypeName: NpcDialogueManager, Assembly-CSharp
m_MethodName: GoToNextSentence m_MethodName: DialogueEndAction
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 1
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
Rewards: []
EndOfDialogueStepAction:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 5064228440392526989}
m_TargetAssemblyTypeName: NpcDialogueManager, Assembly-CSharp
m_MethodName: TestEndAction
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
- WasDisplayed: 0
ListOfSentences:
- Sentence: test 1.2
Buttons: []
- Sentence: test 1.2.3
Buttons:
- ButtonName: way 1.2
Type: 1
ButtonActions:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 5064228440392526989}
m_TargetAssemblyTypeName: NpcDialogueManager, Assembly-CSharp
m_MethodName: SetNextDialogue
m_Mode: 3 m_Mode: 3
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 1
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
Rewards: []
EndOfDialogueStepAction:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 482428332992622001}
m_TargetAssemblyTypeName: BossThug, Assembly-CSharp
m_MethodName: BreakConversation
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
- Key: 1
Value:
- WasDisplayed: 0
ListOfSentences:
- Sentence: test 2
Buttons:
- ButtonName: test 2.1 ans
Type: 1
ButtonActions:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 5064228440392526989}
m_TargetAssemblyTypeName: NpcDialogueManager, 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
- Sentence: test 2.1
Buttons: []
Rewards: []
EndOfDialogueStepAction:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 482428332992622001}
m_TargetAssemblyTypeName: BossThug, Assembly-CSharp
m_MethodName: ChanegStatusToAttack
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: 482428332992622001}
m_TargetAssemblyTypeName: BossThug, Assembly-CSharp
m_MethodName: SetEndConversation
m_Mode: 1
m_Arguments: m_Arguments:
m_ObjectArgument: {fileID: 0} m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
@ -381,10 +246,10 @@ MonoBehaviour:
newController: {fileID: 0} newController: {fileID: 0}
isAfterConversation: 0 isAfterConversation: 0
isDuringConversation: 0 isDuringConversation: 0
state: 1 state: 0
--- !u!95 &-4365747932373452915 --- !u!95 &-4365747932373452915
Animator: Animator:
serializedVersion: 3 serializedVersion: 4
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
@ -397,6 +262,7 @@ Animator:
m_UpdateMode: 0 m_UpdateMode: 0
m_ApplyRootMotion: 0 m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0 m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage: m_WarningMessage:
m_HasTransformHierarchy: 1 m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1 m_AllowConstantClipSamplingOptimization: 1

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: bb36c2a18afa1a7489740405a40119b2 guid: 15d4a2b0037a59742b016f2c5de5b086
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -194,7 +194,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0} m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0} m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 75} m_AnchoredPosition: {x: 0, y: 81.5}
m_SizeDelta: {x: 800, y: 665} m_SizeDelta: {x: 800, y: 665}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2835830911057077562 --- !u!222 &2835830911057077562

View File

@ -4,7 +4,7 @@ using UnityEngine;
[System.Serializable] [System.Serializable]
public class Dialogue public class DialogueNpcTest
{ {
public string name; public string name;
public string[] sentences; public string[] sentences;

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: c476500c7ecfac541965f502f56b3df1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,19 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/*public class NPCDialogue : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
*/

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f061cf69f5299d0479086e9e07c3152b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f5e03e1acc0dd994786778db1f72ce69
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,61 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class PanelTest : MonoBehaviour
{
[SerializeField] bool Custom = true;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void CustomPanel()
{
Debug.Log("Accept press");
}
private void QuestionPanel()
{
Debug.Log("Reject press");
}
private void EndDialogue()
{
Debug.Log("End dialogue :D");
}
}
public class NPCDialogue2 : MonoBehaviour
{
/* List<DialogueStepModel> DialogueStepsList;
public void Start()
{
DialogueController DialogueStep = new DialogueController();
DialogueStep.AddSentence(new DialogueModel("lorem ipsum"));
*//* DialogueStep.AddSentence(new QuestionDialogueModel("tolore dolore?",
new List<Tuple<string, Action>> {
new Tuple<string, Action>("AcceptButton", CustomPanel),
new Tuple<string, Action>("RejectButton", QuestionPanel)
}));*//*
DialogueStep.SetActionAfterDialogueEnds(() => { });
DialogueStepModel dialogueStepModel = new DialogueStepModel(DialogueStep);
DialogueStepsList = new List<DialogueStepModel> { dialogueStepModel };
}
public void ShowStep()
{
DialogueStepsList[0].DialogueController.Show(DialogueStepsList[0].DialogueController.listOfDialogue.Dequeue());
}*/
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 994cbfd834e92c5409d3e3df4664e86e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -35,15 +35,15 @@ public class DoorBehaviour : MonoBehaviour
PlayerPrefs.SetFloat("gateway.respawnCoords.z", gateway.respawnCoords.z); PlayerPrefs.SetFloat("gateway.respawnCoords.z", gateway.respawnCoords.z);
// 1. Save all before change scene // 1. Save all before change scene
SaveController.GetComponent<SaveController>().SaveItems(); SaveController.GetComponent<SaveController>().SavePlayerEquipmentItems();
SaveController.GetComponent<SaveController>().SaveQuests(); SaveController.GetComponent<SaveController>().SavePlayerQuests();
SaveController.GetComponent<SaveController>().SaveInventory(); SaveController.GetComponent<SaveController>().SavePlayerInventory();
SaveController.GetComponent<SaveController>().SaveHealth(); SaveController.GetComponent<SaveController>().SaveHealth();
// 1. Save all befor change scene // 1. Save all befor change scene
// SaveController.GetComponent<SaveController>().SaveItems(); // SaveController.GetComponent<SaveController>().SavePlayerEquipmentItems();
SaveController.GetComponent<SaveController>().SaveQuests(); SaveController.GetComponent<SaveController>().SavePlayerQuests();
// SaveController.GetComponent<SaveController>().SaveInventory(); // SaveController.GetComponent<SaveController>().SavePlayerInventory();
// 2. Change scene // 2. Change scene
SceneManager.LoadScene(gateway.nextMapName); SceneManager.LoadScene(gateway.nextMapName);

View File

@ -92,6 +92,10 @@ public class BossThug : MonoBehaviour
public void ChanegStatusToAttack() public void ChanegStatusToAttack()
{ {
BreakConversation();
SetEndConversation();
state = BossThugEnum.Attacking; state = BossThugEnum.Attacking;
} }
@ -100,40 +104,38 @@ public class BossThug : MonoBehaviour
{ {
if (other.tag == "Player" && state == BossThugEnum.Talking && !isAfterConversation && !isDuringConversation) if (other.tag == "Player" && state == BossThugEnum.Talking && !isAfterConversation && !isDuringConversation)
{ {
Debug.Log("OnTriggerEnter2D");
//gameObject.GetComponent<CircleCollider2D>().enabled = false; //gameObject.GetComponent<CircleCollider2D>().enabled = false;
//gameObject.GetComponent<CircleCollider2D>().radius = 2f; //gameObject.GetComponent<CircleCollider2D>().radius = 2f;
isDuringConversation = true; isDuringConversation = true;
gameObject.GetComponent<NpcDialogueManager>().StartDialogue(); gameObject.GetComponent<NpcDialogueManager>().Dialogue.StartDialogue();
} }
} }
public void OnTriggerStay2D(Collider2D other) /*public void OnTriggerStay2D(Collider2D other)
{ {
if (other.tag == "Player" && state == BossThugEnum.Talking && !isAfterConversation && !isDuringConversation) if (other.tag == "Player" && state == BossThugEnum.Talking && !isAfterConversation && !isDuringConversation)
{ {
isDuringConversation = true; isDuringConversation = true;
gameObject.GetComponent<NpcDialogueManager>().StartDialogue(); gameObject.GetComponent<NpcDialogueManager>().Dialogue.StartDialogue();
}
} }
}*/
public void OnTriggerExit2D(Collider2D other) public void OnTriggerExit2D(Collider2D other)
{ {
if (other.tag == "Player" && state == BossThugEnum.Talking && !isAfterConversation && isDuringConversation) if (other.tag == "Player" && state == BossThugEnum.Talking && !isAfterConversation && isDuringConversation)
{ {
Debug.Log("break dialogue");
//gameObject.GetComponent<CircleCollider2D>().enabled = true; //gameObject.GetComponent<CircleCollider2D>().enabled = true;
//gameObject.GetComponent<CircleCollider2D>().radius = 2f; //gameObject.GetComponent<CircleCollider2D>().radius = 2f;
isDuringConversation = false; isDuringConversation = false;
gameObject.GetComponent<NpcDialogueManager>().BreakDialogue(); gameObject.GetComponent<NpcDialogueManager>().Dialogue.BreakDialogue();
//TODO break dialogue after leaving collider range!!! //TODO break dialogue after leaving collider range!!!
} }
@ -147,6 +149,9 @@ public class BossThug : MonoBehaviour
isDuringConversation = false; isDuringConversation = false;
} }
/// <summary>
/// Mark conversation as finished
/// </summary>
public void SetEndConversation() public void SetEndConversation()
{ {
isAfterConversation = true; isAfterConversation = true;

View File

@ -11,17 +11,17 @@ public class NPCDialogue : MonoBehaviour
public Text nameText2; public Text nameText2;
public Text dialogueText; public Text dialogueText;
//first dialogue //first dialogue
public Dialogue dialogue; public DialogueNpcTest dialogue;
//dialogue during quest //dialogue during quest
public Dialogue dialogueWQuest; public DialogueNpcTest dialogueWQuest;
//dialotgue after quest //dialotgue after quest
public Dialogue dialogueAQuest; public DialogueNpcTest dialogueAQuest;
//first dialogue //first dialogue
public Dialogue dialoguePolish; public DialogueNpcTest dialoguePolish;
//dialogue during quest //dialogue during quest
public Dialogue dialogueWQuestPolish; public DialogueNpcTest dialogueWQuestPolish;
//dialotgue after quest //dialotgue after quest
public Dialogue dialogueAQuestPolish; public DialogueNpcTest dialogueAQuestPolish;
private string language; private string language;
@ -218,7 +218,7 @@ public class NPCDialogue : MonoBehaviour
} }
public void StartDialogue(Dialogue dialogue) public void StartDialogue(DialogueNpcTest dialogue)
{ {
nameText.text = dialogue.name; nameText.text = dialogue.name;
nameText1.text = dialogue.name; nameText1.text = dialogue.name;

View File

@ -1,6 +1,5 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor.Build.Content;
using UnityEngine; using UnityEngine;
[System.Serializable] [System.Serializable]
public class Node public class Node

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 3f046684cddc2ca4c8d476952e4f48cf guid: 9d8ad5f0a8e5a4341b7122164fdcfe6f
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -1,16 +1,12 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
[Serializable] [Serializable]
public class NpcDialogueManager : MonoBehaviour [CreateAssetMenu(fileName = "New Dialogue", menuName = "Dialogue/New Dialogue")]
public class Dialogue : ScriptableObject
{ {
[SerializeField]
public List<DialogueStepModel> DialogueStepsList;
[SerializeField] [SerializeField]
int CurrentDialogue = 0; int CurrentDialogue = 0;
@ -47,8 +43,8 @@ public class NpcDialogueManager : MonoBehaviour
DialogueStepsList = new List<DialogueStepModel> { dialogueStepModel }; DialogueStepsList = new List<DialogueStepModel> { dialogueStepModel };
*/ */
if(MultiWayDialogue.Count > 0) /*if (MultiWayDialogue.Count > 0)
BuildDialogue(MultiWayDialogue.Where(el => el.Key == CurrentDialogue).First().Value); BuildDialogue(MultiWayDialogue.Where(el => el.Key == CurrentDialogue).First().Value);*/
} }
public void StartDialogue() public void StartDialogue()
@ -64,16 +60,19 @@ public class NpcDialogueManager : MonoBehaviour
{ {
// 1. Find first yet undisplayed for player anbd show // 1. Find first yet undisplayed for player anbd show
DialogueStepsList = MultiWayDialogue.Where(el => el.Key == CurrentDialogue).ToArray().First().Value; var dialogueStepsList = MultiWayDialogue.Where(el => el.Key == CurrentDialogue).ToArray().First().Value;
foreach (var DialogueStep in DialogueStepsList) foreach (var DialogueStep in dialogueStepsList)
{ {
Debug.Log($"List of dialogue count: {DialogueStep.DialogueController.listOfDialogue.Count}");
if (!DialogueStep.WasDisplayed && DialogueStep.DialogueController.listOfDialogue.Count != 0) if (!DialogueStep.WasDisplayed && DialogueStep.DialogueController.listOfDialogue.Count != 0)
{ {
Debug.Log("Break Dialogue - close panel");
DialogueStep.DialogueController.CloseCurrentPanel(); // close panel DialogueStep.DialogueController.CloseCurrentPanel(); // close panel
break; break;
} }
Debug.Log("a");
} }
} }
@ -89,11 +88,11 @@ public class NpcDialogueManager : MonoBehaviour
{ {
// 1. Find first yet undisplayed for player anbd show // 1. Find first yet undisplayed for player anbd show
DialogueStepsList = MultiWayDialogue.Where(el => el.Key == CurrentDialogue).ToArray().First().Value; var dialogueStepsList = MultiWayDialogue.Where(el => el.Key == CurrentDialogue).ToArray().First().Value;
foreach (var DialogueStep in DialogueStepsList) foreach (var DialogueStep in dialogueStepsList)
{ {
if(!DialogueStep.WasDisplayed && DialogueStep.DialogueController.listOfDialogue.Count != 0) if (!DialogueStep.WasDisplayed && DialogueStep.DialogueController.listOfDialogue.Count != 0)
{ {
DialogueStep.DialogueController.Show(DialogueStep.DialogueController.listOfDialogue.Dequeue()); // create panel DialogueStep.DialogueController.Show(DialogueStep.DialogueController.listOfDialogue.Dequeue()); // create panel
@ -116,9 +115,9 @@ public class NpcDialogueManager : MonoBehaviour
{ {
// 1. Find first yet undisplayed for player anbd show // 1. Find first yet undisplayed for player anbd show
DialogueStepsList = MultiWayDialogue.Where(el => el.Key == CurrentDialogue).ToArray().First().Value; var dialogueStepsList = MultiWayDialogue.Where(el => el.Key == CurrentDialogue).ToArray().First().Value;
foreach (var DialogueStep in DialogueStepsList) foreach (var DialogueStep in dialogueStepsList)
{ {
if (!DialogueStep.WasDisplayed) if (!DialogueStep.WasDisplayed)
{ {
@ -176,17 +175,6 @@ public class NpcDialogueManager : MonoBehaviour
ShowStep(); ShowStep();
} }
/// <summary>
/// Build each step of dialogue
/// </summary>
private void BuildDialogue()
{
foreach(var dialogueStep in DialogueStepsList)
{
dialogueStep.Build();
}
}
/// <summary> /// <summary>
/// Build each step of dialogue /// Build each step of dialogue
/// </summary> /// </summary>
@ -198,8 +186,17 @@ public class NpcDialogueManager : MonoBehaviour
} }
} }
public void TestEndAction() public (int, int) DialogueStepStatus()
{ {
Debug.Log("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"); var currentDialogueStepIndex = MultiWayDialogue
.Where(el => el.Key == CurrentDialogue)
.Select(el => el.Value)
.First()
.Where(step => step.WasDisplayed == true)
.ToArray()
.Count()
;
return(CurrentDialogue, currentDialogueStepIndex);
} }
} }

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 45b41589283138641ba006c2243b0637
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -68,7 +68,7 @@ public class DialogueController
if (listOfDialogue.Count == 0) if (listOfDialogue.Count == 0)
{ {
CloseCurrentPanel(parentDialController); CloseCurrentPanel(parentDialController);
FinishDialogue(); FinishDialoguStep();
return false; return false;
} }
@ -91,12 +91,13 @@ public class DialogueController
public void CloseCurrentPanel() public void CloseCurrentPanel()
{ {
Debug.Log(CurrentPanel);
MonoBehaviour.Destroy(CurrentPanel); MonoBehaviour.Destroy(CurrentPanel);
} }
// if palyer click last dialogue panel's "continue" button then ShowNextPanel // if palyer click last dialogue panel's "continue" button then ShowNextPanel
// function invoke this method whioch contain external action :D - MAGIC // function invoke this method whioch contain external action :D - MAGIC
public void FinishDialogue() public void FinishDialoguStep()
{ {
// set uoe everything whats is needed to change after finish dialogue // set uoe everything whats is needed to change after finish dialogue
// eg. // eg.

View File

@ -14,9 +14,6 @@ public class DialogueStepModel
[SerializeField] // list to map to queue in DialogueController [SerializeField] // list to map to queue in DialogueController
public List<DialogueModel> ListOfSentences = new List<DialogueModel>(); public List<DialogueModel> ListOfSentences = new List<DialogueModel>();
[SerializeField]
public List<GameObject> Rewards;
[SerializeField] [SerializeField]
public UnityEvent EndOfDialogueStepAction = new UnityEvent(); public UnityEvent EndOfDialogueStepAction = new UnityEvent();
@ -50,6 +47,11 @@ public class DialogueStepModel
} }
// 3. Bind finishing action // 3. Bind finishing action
// 3.1 Add marked step as displayed action
EndOfDialogueStepAction.AddListener(() => WasDisplayed = true);
// 3.2 Bind actions
DialogueController.SetActionAfterDialogueEnds(EndOfDialogueStepAction); DialogueController.SetActionAfterDialogueEnds(EndOfDialogueStepAction);
} }
} }

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e4639c29041f29a4884b02fd01acf48f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: a977b11a47df30d4d8eaf12b6b2c5841 guid: bc9eb520a472ac94a936fca330546191
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 278e9b2867c25a34a83c1ee671b92ff2 guid: b7c3ffe7db8284f44a7fdff82b15299b
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 800b3a20b12cb1344be0f4be6737c5d5 guid: 098377c3594ac364d87eac3b64e34340
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 9580a39674501e74cb88f9f62e5fbbcf guid: 8b8e1058c2b92f44485fdaae1fd02248
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: fbfba9fa41a482749a828a0dd7f8dee0 guid: 0329f79b337290544b14678405bb5894
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -4,7 +4,7 @@ using UnityEngine;
public static class DialoguePanelsPrefabsList public static class DialoguePanelsPrefabsList
{ {
private static string SourcePath = "Dialogue/"; private static string SourcePath = "UiPanels/Dialogue/";
public static GameObject GetPanel() public static GameObject GetPanel()
{ {
return Resources.Load<GameObject>(SourcePath + "DialoguePanel"); return Resources.Load<GameObject>(SourcePath + "DialoguePanel");

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 4e51f6b74b445b749b8c3fd09e73e243 guid: 0dcf380149f6f2345872b529e1d7c5e3
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: c8ee24f14ee70a947a098b04569c5ecc guid: 29ac04dbf1f8dfe49a0e1cc77cf3403a
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 6c2b7cdb65cfa2a4795b404433a2b1d8 guid: e9ca731c930aca040930cc708f416db0
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ea5a5d0b0eb26a444bf56ff4a28c2c29
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[Serializable]
[CreateAssetMenu(fileName = "New Mission", menuName = "Mission/New Mission")]
public class Mission : ScriptableObject
{
[SerializeField]
public MissionStatusEnum Status = MissionStatusEnum.None;
[SerializeField]
int CurrentStep = 0;
[SerializeField]
public List<MissionStepModel> MissionStepsList;
public void CheckIfComplete()
{
Debug.Log("Checkl if complete");
}
public void Accept()
{
Status = MissionStatusEnum.Accepted;
}
public void Reject()
{
Status = MissionStatusEnum.Rejected;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0a3bcdd1e2dba0c4791bcb151c0df6c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,40 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[System.Serializable]
public class MissionReward
{
[SerializeField]
public List<EquippableItem> Items = new List<EquippableItem>();
[SerializeField]
public int Cash = 0;
public MissionReward() { }
public MissionReward(List<EquippableItem> _items, int _cash)
{
Items = _items;
Cash = _cash;
}
public void SetCash(int newValue)
{
Cash = newValue;
}
public void IncreaseCash(int amountToAdd)
{
Cash += amountToAdd;
}
public void AddItemToRewards(Item _item)
{
Items.Add((EquippableItem)_item);
}
public void AddItemToRewards(EquippableItem _item)
{
Items.Add(_item);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e35a0f698c14dea40966c6593bcd9837
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4e699112181b4f8458f6a6bcbce888f0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,46 @@
using UnityEditor;
using System.Collections;
using UnityEngine;
using System.Collections.Generic;
using System;
[Serializable]
public class MissionStepModel
{
[SerializeField] // this flag tell whatewer dialoge ware already display to user
public MissionStepStatusEnum Status = MissionStepStatusEnum.None;
[SerializeField]
public DialogueStepModel DialogueStep;
[SerializeField]
public MissionReward Reward;
public MissionStepModel() { }
// Copied from DialogueStepModel
public virtual void Build()
{
DialogueStep.EndOfDialogueStepAction.AddListener(GiveReward);
DialogueStep.Build();
}
// Assign geting reward as Model End Action
public void GiveReward()
{
var Player = GameObject.FindGameObjectWithTag("Player");
if (!Player)
Debug.LogError("MissionStepModel::GetReward - There is no player on scene!!!");
Player.GetComponent<PlayerActions>().GetReward(Reward);
}
}
// TODO
// zapobieganie zniuknieciu itemow po otrzymaniu nagrody z poanelu gracza - WYKONANIE SAVE PO ZAKOŃCZENIU STEPU:
// -- zapisanie postępu misji w pliku z misjami
// -- zapisanie statusu panelu gracza (lista misji / content ekwipunku / magazynu)

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 30a5cd2238c18504bb14e855774f87a2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,33 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//[Serializable]
//[CreateAssetMenu(fileName = "New Mission", menuName = "Mission/New Mission")]
public class NpcMissionManager : ScriptableObject
{
public Mission mission = null;
private void BuildMission()
{
//mission.Status = MissionStatusEnum.Available;
foreach(var missionStep in mission.MissionStepsList)
{
missionStep.Build();
}
}
public void ShowStep()
{
foreach (var MissionStep in mission.MissionStepsList)
{
if (MissionStep.Status != MissionStepStatusEnum.Finished && MissionStep.DialogueStep.ListOfSentences.Count != 0)
{
MissionStep.DialogueStep.DialogueController.Show(MissionStep.DialogueStep.DialogueController.listOfDialogue.Dequeue()); // create panel
break;
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 39fff781183ce9c4c8b22d77e405596f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 831de04b47054494c8d0af0f6427c146
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,71 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Events;
[Serializable]
public class NpcDialogueManager : MonoBehaviour
{
[SerializeField]
public Dialogue DialogueTemplate;
/* We user object CLONED TO PREVENT overwritting changes in main object inassets */
[SerializeField]
public Dialogue Dialogue;
// List<Key<dialogue No, dialogue step No>, Value : UnityEvent>
public List<IndexValuePair<IndexValuePair<int, int>, UnityEvent>> EndactionEventList;
public void Start()
{
Dialogue = Instantiate(DialogueTemplate);
}
public void Update() { }
/// <summary>
/// Function to invoke actions declared in manager on object from scene not onto asset
///
/// Used in Dialogue ScriptableObject Template
/// </summary>
/// <param name="dialogueIndex"></param>
public void DialogueEndAction(int dialogueIndex)
{
GameObject.FindObjectsOfType<NpcDialogueManager>().Where(obj => obj.name == gameObject.name).First().GetComponent<NpcDialogueManager>().InvokeDialogueEndAction(dialogueIndex);
}
/// <summary>
/// Function to invoke actions declared in manager (on current object)
///
/// Use this to invoke actions which we want to occured after specific Dialogue
/// </summary>
/// <param name="dialogueIndex"></param>
protected void InvokeDialogueEndAction(int dialogueIndex)
{
EndactionEventList.Where(el => el.Key.Key == dialogueIndex).ToList().ForEach(el => el.Value.Invoke());
}
/// <summary>
/// Function to invoke actions declared in manager on object from scene not onto asset
///
/// Used in Dialogue ScriptableObject Template
/// </summary>
public void StepEndAction()
{
GameObject.FindObjectsOfType<NpcDialogueManager>().Where(obj => obj.name == gameObject.name).First().GetComponent<NpcDialogueManager>().InvokeStepEndAction();
}
/// <summary>
/// Function to invoke actions declared in manager (on current object)
///
/// Use this to invoke actions which we want to occured after specific Dialogue Step
/// </summary>
protected void InvokeStepEndAction()
{
var dialogueProgress = Dialogue.DialogueStepStatus();
EndactionEventList.Where(el => el.Key.Key == dialogueProgress.Item1 & el.Key.Value == dialogueProgress.Item2).ToList().ForEach(el => el.Value.Invoke());
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f1cb992f960963c43b7a857b977c281a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,34 @@
using System.Collections;
using UnityEngine;
public class PlayerActions : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void GetReward(MissionReward reward)
{
// 1. Add items to equipment
foreach(var item in reward.Items)
{
InventoryUIManager.Instance.Add(item);
}
GameObject.FindObjectOfType<SaveController>().SavePlayerEquipmentItems();
GameObject.FindObjectOfType<SaveController>().SavePlayerInventory();
// 2. Add cach
//cash += reward.Cash;
//GameObject.FindObjectOfType<SaveController>().SavePlayerBankAccount();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b706d33712b371949b5623cdf98fc4a4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: acc5048ecadde0b429d7a951a88be15b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,39 @@
using UnityEditor;
using UnityEngine;
[System.Serializable]
public enum MissionStatusEnum
{
None,
Available,
Rejected,
Accepted,
InProggress,
Finished
}
/*
* None - raw status
* mostly as deffault value for models saved in assets or in files
* also for code class constructors (deffault value is required to pass new instanes and save object in binnary files - not sure last one heh)
*
*
* Available - mission is avaiable for player
* system is waiting on player decision, he must reject or accept tast offered by NPC
*
*
* Rejected - mission has been rejected by Player
* Player dont want to participate in this adventure :(
*
*
* Accepted - player want to do the job
* change status to 'InProggress'
*
*
* InProggress - player is carrying out the task
* this status will be persist to complete all quest (mission)
*
*
* Finished - mission has been compleeted by player
* most importantly finish action were invoked!!
*/

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8d1920d282403b24487be27311492292
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,30 @@
[System.Serializable]
public enum MissionStepStatusEnum
{
None,
Pending,
Active,
Finished
}
/*
* None - raw status
* mostly as deffault value for models saved in assets or in files
* also for code class constructors (deffault value is required to pass new instanes and save object in binnary files - not sure last one heh)
*
*
* Pending - mission is loaded
* step has not been started
* just loaded, step is still waiting in queue on its turn
*
* change status from None -> Pending during building step!!!
*
*
* Active - step is currently in proggress
* when status is pending we are interesten in dikalogue step model list and status each of step inside
*
*
* Finished - step was finished
* (most important finish action were invoked)
* we can freely iterate through (skip) step and go forward to next one
*/

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 61ca24d1b5f7786479bf70a674872f4e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -16,6 +16,11 @@ public struct IndexValuePair<T>
} }
} }
/// <summary>
/// Alias for ValueTouple class, pure touple (V, T) and also KeyValuePair
/// </summary>
/// <typeparam name="V"></typeparam>
/// <typeparam name="T"></typeparam>
[System.Serializable] [System.Serializable]
public struct IndexValuePair<V, T> public struct IndexValuePair<V, T>
{ {

View File

@ -25,19 +25,19 @@ public class SaveController : MonoBehaviour
player.GetComponent<Player>().SaveCheckpoint(); player.GetComponent<Player>().SaveCheckpoint();
} }
public void SaveItems() // toDO change name to save Equipment - save items will save items on map eg after drops public void SavePlayerEquipmentItems() // toDO change name to save Equipment - save items will save items on map eg after drops
{ {
EquipmentDataManager.Instance.SaveDynamicData(); EquipmentDataManager.Instance.SaveDynamicData();
} }
public void SaveQuests() public void SavePlayerQuests()
{ {
SceneTaskDataManager.Instance.SaveDynamicData(); SceneTaskDataManager.Instance.SaveDynamicData();
// right now, we dont need to save dynamic list :D // right now, we dont need to save dynamic list :D
} }
public void SaveInventory() public void SavePlayerInventory()
{ {
SceneInventoryDataManager.Instance.SaveDynamicData(); SceneInventoryDataManager.Instance.SaveDynamicData();
} }