16 changed files with 171 additions and 153 deletions
@ -0,0 +1,47 @@
|
||||
using UnityEditor; |
||||
using UnityEditorInternal; |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
|
||||
[CustomEditor (typeof(AddOptionCommand))] |
||||
public class AddOptionCommandEditor : FungusCommandEditor |
||||
{ |
||||
public override void DrawCommandInspectorGUI() |
||||
{ |
||||
AddOptionCommand t = target as AddOptionCommand; |
||||
|
||||
EditorGUI.BeginChangeCheck(); |
||||
|
||||
string newText = EditorGUILayout.TextField(new GUIContent("Text", "Text to display on option button"), t.text); |
||||
Sequence newSequence = SequenceEditor.SequenceField(new GUIContent("Sequence", "Sequence to execute when this option is selected"), |
||||
t.GetParentFungusScript(), |
||||
t.sequence); |
||||
AddOptionCommand.Condition newCondition = (AddOptionCommand.Condition)EditorGUILayout.EnumPopup(new GUIContent("Condition", "Conditions for when this option is displayed"), t.condition); |
||||
|
||||
if (EditorGUI.EndChangeCheck()) |
||||
{ |
||||
Undo.RecordObject(t, "Set AddOption command"); |
||||
|
||||
t.text = newText; |
||||
t.sequence = newSequence; |
||||
t.condition = newCondition; |
||||
} |
||||
|
||||
if (t.condition == AddOptionCommand.Condition.ShowOnBoolean || |
||||
t.condition == AddOptionCommand.Condition.HideOnBoolean) |
||||
{ |
||||
string newBooleanVariableKey = EditorGUILayout.TextField(new GUIContent("Boolean Variable Key", "Boolean variable to check for condition"), t.booleanVariableKey); |
||||
if (newBooleanVariableKey != t.booleanVariableKey) |
||||
{ |
||||
Undo.RecordObject(t, "Set Boolean Variable"); |
||||
t.booleanVariableKey = newBooleanVariableKey; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2 |
||||
guid: f4a1d934106ae48ab9c8cc28424bd27e |
||||
guid: a20371077211a4cc394cb2192fdc4417 |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
Binary file not shown.
@ -0,0 +1,47 @@
|
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
|
||||
public class AddOptionCommand : FungusCommand |
||||
{ |
||||
public enum Condition |
||||
{ |
||||
AlwaysShow, |
||||
HideOnVisited, |
||||
ShowOnBoolean, |
||||
HideOnBoolean |
||||
} |
||||
|
||||
public string text; |
||||
public Sequence sequence; |
||||
public Condition condition; |
||||
public string booleanVariableKey; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
Dialog dialog = Game.GetInstance().dialog; |
||||
if (dialog != null && |
||||
sequence != null) |
||||
{ |
||||
dialog.AddOption(text, () => { |
||||
Stop(); |
||||
parentFungusScript.ExecuteSequence(sequence); |
||||
}); |
||||
} |
||||
Continue(); |
||||
} |
||||
|
||||
public override void GetConnectedSequences(ref List<Sequence> connectedSequences) |
||||
{ |
||||
if (sequence != null) |
||||
{ |
||||
connectedSequences.Add(sequence); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 1f96fe7b67189415a9884c596c55e96c |
||||
guid: 74826d5144cf64adeb6dd522f32dfb94 |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
@ -1,53 +0,0 @@
|
||||
using UnityEngine; |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
|
||||
public class IfBooleanCommand : FungusCommand |
||||
{ |
||||
public string key; |
||||
|
||||
public Sequence trueSequence; |
||||
public Sequence falseSequence; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
if (Variables.GetBoolean(key)) |
||||
{ |
||||
ExecuteSequence(trueSequence); |
||||
} |
||||
else |
||||
{ |
||||
ExecuteSequence(falseSequence); |
||||
} |
||||
} |
||||
|
||||
public void OnDrawGizmos() |
||||
{ |
||||
if (trueSequence == null || falseSequence == null) |
||||
{ |
||||
errorMessage = "Please select true and false Sequence objects"; |
||||
} |
||||
else |
||||
{ |
||||
errorMessage = ""; |
||||
} |
||||
} |
||||
|
||||
public override void GetConnectedSequences(ref List<Sequence> connectedSequences) |
||||
{ |
||||
if (trueSequence != null) |
||||
{ |
||||
connectedSequences.Add(trueSequence); |
||||
} |
||||
if (falseSequence != null) |
||||
{ |
||||
connectedSequences.Add(falseSequence); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,22 +0,0 @@
|
||||
using UnityEngine; |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
|
||||
public class SetBooleanCommand : FungusCommand |
||||
{ |
||||
public string key; |
||||
|
||||
public bool value; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
Variables.SetBoolean(key, value); |
||||
Finish(); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue