chrisgregan
11 years ago
13 changed files with 184 additions and 28 deletions
@ -0,0 +1,15 @@
|
||||
using UnityEditor; |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
|
||||
[CustomEditor (typeof(SetVariableCommand))] |
||||
public class SetVariableCommandEditor : FungusCommandEditor |
||||
{ |
||||
public override void DrawCommandInspectorGUI() |
||||
{ |
||||
SetVariableCommand t = target as SetVariableCommand; |
||||
|
||||
t.variableKey = EditorGUILayout.TextField(new GUIContent("Variable Key", "The name of the variable to set"), t.variableKey); |
||||
t.booleanValue = EditorGUILayout.Toggle(new GUIContent("Boolean Value", "The boolean value to set the variable with"), t.booleanValue); |
||||
} |
||||
} |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: d0cbb7e4ccb4a41db8ced7c87070df1d |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
Binary file not shown.
@ -0,0 +1,40 @@
|
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class CompareCommand : FungusCommand |
||||
{ |
||||
public string variableKey; |
||||
|
||||
public bool booleanValue; |
||||
|
||||
public Sequence trueSequence; |
||||
|
||||
public Sequence falseSequence; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
Variable v = parentSequenceController.GetVariable(variableKey); |
||||
if (v != null) |
||||
{ |
||||
if (v.booleanValue == booleanValue) |
||||
{ |
||||
if (trueSequence != null) |
||||
{ |
||||
ExecuteSequence(trueSequence); |
||||
return; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
if (falseSequence != null) |
||||
{ |
||||
ExecuteSequence(falseSequence); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
|
||||
Finish(); |
||||
} |
||||
} |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 050fb9e6e72f442b3b883da8a965bdeb |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
@ -0,0 +1,51 @@
|
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class SetVariableCommand : FungusCommand |
||||
{ |
||||
public string variableKey; |
||||
|
||||
public string stringValue; |
||||
|
||||
public int integerValue; |
||||
|
||||
public bool booleanValue; |
||||
|
||||
public float floatValue; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
if (variableKey.Length == 0) |
||||
{ |
||||
Finish(); |
||||
return; |
||||
} |
||||
|
||||
Variable v = parentSequenceController.GetVariable(variableKey); |
||||
if (v == null) |
||||
{ |
||||
Debug.LogError("Variable " + variableKey + " not defined."); |
||||
} |
||||
else |
||||
{ |
||||
switch (v.type) |
||||
{ |
||||
case VariableType.String: |
||||
v.stringValue = stringValue; |
||||
break; |
||||
case VariableType.Integer: |
||||
v.integerValue = integerValue; |
||||
break; |
||||
case VariableType.Float: |
||||
v.floatValue = floatValue; |
||||
break; |
||||
case VariableType.Boolean: |
||||
v.booleanValue = booleanValue; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
Finish(); |
||||
} |
||||
} |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: fb77d0ce495044f6e9feb91b31798e8c |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
@ -0,0 +1,23 @@
|
||||
using UnityEngine; |
||||
using System; |
||||
using System.Collections; |
||||
|
||||
public enum VariableType |
||||
{ |
||||
Boolean, |
||||
Integer, |
||||
Float, |
||||
String |
||||
}; |
||||
|
||||
[Serializable] |
||||
public class Variable |
||||
{ |
||||
public string key; |
||||
public VariableType type; |
||||
|
||||
public string stringValue; |
||||
public int integerValue; |
||||
public float floatValue; |
||||
public bool booleanValue; |
||||
} |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 2f3853d313cd94fe184e3478cefc11f2 |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
Loading…
Reference in new issue