Skip to content

Commit

Permalink
Merge pull request #15 from Studio-23-xyz/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
BDeshiDev authored Feb 15, 2024
2 parents 9ecebfe + a627d35 commit b37956a
Show file tree
Hide file tree
Showing 16 changed files with 531 additions and 422 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace Studio23.SS2.DialogueSystem.Data
{
[CreateAssetMenu(menuName = "Studio-23/Dialogue System/New Dialogue Node",fileName ="Dialogue Node")]
[Serializable]

[Node.NodeTint("#7A009A"), CreateNodeMenu("Dialogue Line")]
public class BiWayDialogueNode: DialogueLineNodeBase
{
[Node.Input]
public int Entry;
[Node.Output]
public int Exit;
public DialogueLineNodeBase Entry;



}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@

namespace Studio23.SS2.DialogueSystem.Data
{
public abstract class DialogueChoiceNodeBase:BiWayDialogueNode
public abstract class DialogueChoiceNodeBase:DialogueLineNodeBase
{
[Node.Input]
public DialogueChoicesNode ParentChoice;

public int DialogueChoiceIndex { get; internal set; }

bool _taken;
public bool Taken => _taken;
public bool LastConditionEvaluationStatus { get; private set; }

public override object GetValue(NodePort port)
{
if (port.fieldName == "Exit")
{
return this;

}
return base.GetValue(port);
}
public bool CheckConditions()
{
LastConditionEvaluationStatus = CheckConditionsInternal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,28 @@

namespace Studio23.SS2.DialogueSystem.Data
{
[NodeTint("#AAAA00"), CreateNodeMenu("Dialogue Multi choice")]
[NodeTint("#AAAA00"), CreateNodeMenu("Dialogue Choice Branch")]
public class DialogueChoicesNode : DialogueNodeBase
{
[Input]
public int Entry;
public DialogueLineNodeBase Entry;
[Output]
public int Choices;
public DialogueChoicesNode Choices;

private int _lastChoiceIndex = -1;

protected List<DialogueChoiceNodeBase> _availableDialogueChoices;
public List<DialogueChoiceNodeBase> AvailableDialogueChoices => _availableDialogueChoices;

public override object GetValue(NodePort port)
{
if (port.fieldName == "Choices")
{
return this;
}
return base.GetValue(port);
}

protected virtual void PrepareDialogueChoices()
{
GetAvailableChoices();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ public abstract class DialogueLineNodeBase : DialogueNodeBase

private bool _canAdvanceDialogue;

[Output()]
public int Events;
[Node.Output(typeConstraint = TypeConstraint.Strict, connectionType = ConnectionType.Override)]
public DialogueLineNodeBase Exit;

[Output(typeConstraint = TypeConstraint.InheritedInverse)]
public EventNodeBase Events;

public override void HandleDialogueAdvance()
{
Expand Down Expand Up @@ -82,6 +85,18 @@ public override DialogueNodeBase GetNextNode()
}
return outputPort.Connection.node as DialogueNodeBase;
}

public override object GetValue(NodePort port)
{
if (port.fieldName == "Exit")
{
return this;
}else if (port.fieldName == "Events")
{
return null;
}
return base.GetValue(port);
}

public override void Initialize()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
using Cysharp.Threading.Tasks;
using XNode;

namespace Studio23.SS2.DialogueSystem.Data
{
[NodeTint("#006600"), CreateNodeMenu("DialogueStartNode")]
public class DialogueStartNode : DialogueLineNodeBase
{

[Output] public int Exit;

public override object GetValue(NodePort port)
{
if (port.fieldName == "Exit")
{
return this;

}
return base.GetValue(port);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ namespace Studio23.SS2.DialogueSystem.Data
{
public abstract class EventNodeBase : DialogueGraphNodeBase
{
[Input]
public int Entry;
[Input(typeConstraint = TypeConstraint.Strict)]
public EventNodeBase TriggeringNode;

public abstract void Invoke();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ namespace Studio23.SS2.DialogueSystem.Data
/// This is useful for dialogue trees that the player needs to fully exhaust
/// before being allowed to continue
/// </summary>
[CreateNodeMenu("Force Take All Choice Node"), NodeTint("#996600")]
public class ForceTakeAllChoiceNode:DialogueChoicesNode
[CreateNodeMenu("Must Take All Choices Branch Node"), NodeTint("#996600")]
public class MustTakeAllChoicesBranch:DialogueChoicesNode
{
[Output]
public int FinalChoice;
[Output(typeConstraint = TypeConstraint.Strict, connectionType = ConnectionType.Override)]
public DialogueChoicesNode FinalChoice;

protected override void GetAvailableChoices()
{
GetAllConnectedChoiceNodes();
Debug.Log(_availableDialogueChoices.Count);
AddFinalChoiceIfAvailable();
Debug.Log(_availableDialogueChoices.Count);
RemoveUnavailableChoices();
Debug.Log("RemoveUnavailableChoices " + _availableDialogueChoices.Count);
}

private void AddFinalChoiceIfAvailable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ MonoBehaviour:
m_Key: STAND BACK
m_Metadata:
m_Items: []
- m_Id: 9827534877667328
m_Key: FINAL CHOICE
m_Metadata:
m_Items: []
m_Metadata:
m_Items: []
m_KeyGenerator:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ MonoBehaviour:
m_Localized: STAND BACK I'M ABOUT TO LOOP
m_Metadata:
m_Items: []
- m_Id: 9827534877667328
m_Localized: FINAL CHOICE
m_Metadata:
m_Items: []
references:
version: 2
RefIds: []
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void Start()
//#TODO THE UI Shouldn't be responsible for loading the character table
CharacterTable = Resources.Load<CharacterTable>("DialogueSystem/CharacterTable");
ApplyConfiguration();
HideUI();
RegisterEvents();
}

Expand Down Expand Up @@ -113,6 +114,7 @@ private void ShowUI(DialogueGraph graph)
private void ShowUI()
{
UIRoot.SetActive(true);
BackgroundImage.gameObject.SetActive(true);
}

private void HideUI(DialogueGraph graph)
Expand All @@ -123,6 +125,7 @@ private void HideUI(DialogueGraph graph)
private void HideUI()
{
UIRoot.SetActive(false);
BackgroundImage.gameObject.SetActive(false);
}


Expand Down
Loading

0 comments on commit b37956a

Please sign in to comment.