From 97da432c35b8c7aaf9dd2c39e2aa4b1f55f36065 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 27 Jan 2021 16:15:06 +0800 Subject: +behaviour designer --- .../Runtime/Basic Tasks/String/BuildString.cs | 31 ++++++++++++++ .../Runtime/Basic Tasks/String/BuildString.cs.meta | 8 ++++ .../Runtime/Basic Tasks/String/CompareTo.cs | 30 ++++++++++++++ .../Runtime/Basic Tasks/String/CompareTo.cs.meta | 8 ++++ .../Runtime/Basic Tasks/String/Format.cs | 47 ++++++++++++++++++++++ .../Runtime/Basic Tasks/String/Format.cs.meta | 8 ++++ .../Runtime/Basic Tasks/String/GetLength.cs | 27 +++++++++++++ .../Runtime/Basic Tasks/String/GetLength.cs.meta | 8 ++++ .../Runtime/Basic Tasks/String/GetRandomString.cs | 28 +++++++++++++ .../Basic Tasks/String/GetRandomString.cs.meta | 8 ++++ .../Runtime/Basic Tasks/String/GetSubstring.cs | 37 +++++++++++++++++ .../Basic Tasks/String/GetSubstring.cs.meta | 8 ++++ .../Runtime/Basic Tasks/String/IsNullOrEmpty.cs | 22 ++++++++++ .../Basic Tasks/String/IsNullOrEmpty.cs.meta | 8 ++++ .../Runtime/Basic Tasks/String/Replace.cs | 34 ++++++++++++++++ .../Runtime/Basic Tasks/String/Replace.cs.meta | 8 ++++ .../Runtime/Basic Tasks/String/SetString.cs | 28 +++++++++++++ .../Runtime/Basic Tasks/String/SetString.cs.meta | 8 ++++ 18 files changed, 356 insertions(+) create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/BuildString.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/BuildString.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/CompareTo.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/CompareTo.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Format.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Format.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetLength.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetLength.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetRandomString.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetRandomString.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetSubstring.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetSubstring.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/IsNullOrEmpty.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/IsNullOrEmpty.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Replace.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Replace.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/SetString.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/SetString.cs.meta (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/String') diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/BuildString.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/BuildString.cs new file mode 100644 index 00000000..cf8e430f --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/BuildString.cs @@ -0,0 +1,31 @@ +using UnityEngine; +using System; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString +{ + [TaskCategory("Basic/String")] + [TaskDescription("Creates a string from multiple other strings.")] + public class BuildString : Action + { + [Tooltip("The array of strings")] + public SharedString[] source; + [Tooltip("The stored result")] + [RequiredField] + public SharedString storeResult; + + public override TaskStatus OnUpdate() + { + for (int i = 0; i < source.Length; ++i) { + storeResult.Value += source[i]; + } + + return TaskStatus.Success; + } + + public override void OnReset() + { + source = null; + storeResult = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/BuildString.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/BuildString.cs.meta new file mode 100644 index 00000000..771073df --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/BuildString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9373af75c434e1a4784c2a165ad3ce3b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/CompareTo.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/CompareTo.cs new file mode 100644 index 00000000..cb337705 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/CompareTo.cs @@ -0,0 +1,30 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString +{ + [TaskCategory("Basic/String")] + [TaskDescription("Compares the first string to the second string. Returns an int which indicates whether the first string precedes, matches, or follows the second string.")] + public class CompareTo : Action + { + [Tooltip("The string to compare")] + public SharedString firstString; + [Tooltip("The string to compare to")] + public SharedString secondString; + [Tooltip("The stored result")] + [RequiredField] + public SharedInt storeResult; + + public override TaskStatus OnUpdate() + { + storeResult.Value = firstString.Value.CompareTo(secondString.Value); + return TaskStatus.Success; + } + + public override void OnReset() + { + firstString = ""; + secondString = ""; + storeResult = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/CompareTo.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/CompareTo.cs.meta new file mode 100644 index 00000000..5c5500d2 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/CompareTo.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c752378530d87cb4c98ba15e55936abf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Format.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Format.cs new file mode 100644 index 00000000..96e57f85 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Format.cs @@ -0,0 +1,47 @@ +using UnityEngine; +using System; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString +{ + [TaskCategory("Basic/String")] + [TaskDescription("Stores a string with the specified format.")] + public class Format : Action + { + [Tooltip("The format of the string")] + public SharedString format; + [Tooltip("Any variables to appear in the string")] + public SharedGenericVariable[] variables; + [Tooltip("The result of the format")] + [RequiredField] + public SharedString storeResult; + + private object[] variableValues; + + public override void OnAwake() + { + variableValues = new object[variables.Length]; + } + + public override TaskStatus OnUpdate() + { + for (int i = 0; i < variableValues.Length; ++i) { + variableValues[i] = variables[i].Value.value.GetValue(); + } + + try { + storeResult.Value = string.Format(format.Value, variableValues); + } catch (Exception e) { + Debug.LogError(e.Message); + return TaskStatus.Failure; + } + return TaskStatus.Success; + } + + public override void OnReset() + { + format = ""; + variables = null; + storeResult = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Format.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Format.cs.meta new file mode 100644 index 00000000..4ddacf96 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Format.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d96c5da37483da346b96ef02fde824cb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetLength.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetLength.cs new file mode 100644 index 00000000..5c41ff2b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetLength.cs @@ -0,0 +1,27 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString +{ + [TaskCategory("Basic/String")] + [TaskDescription("Stores the length of the string")] + public class GetLength : Action + { + [Tooltip("The target string")] + public SharedString targetString; + [Tooltip("The stored result")] + [RequiredField] + public SharedInt storeResult; + + public override TaskStatus OnUpdate() + { + storeResult.Value = targetString.Value.Length; + return TaskStatus.Success; + } + + public override void OnReset() + { + targetString = ""; + storeResult = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetLength.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetLength.cs.meta new file mode 100644 index 00000000..61249d21 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetLength.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5ab3e7e038a50c14f9fa0b019399f3be +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetRandomString.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetRandomString.cs new file mode 100644 index 00000000..9d64210d --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetRandomString.cs @@ -0,0 +1,28 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString +{ + [TaskCategory("Basic/String")] + [TaskDescription("Randomly selects a string from the array of strings.")] + public class GetRandomString : Action + { + [Tooltip("The array of strings")] + public SharedString[] source; + [Tooltip("The stored result")] + [RequiredField] + public SharedString storeResult; + + public override TaskStatus OnUpdate() + { + storeResult.Value = source[Random.Range(0, source.Length)].Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + source = null; + storeResult = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetRandomString.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetRandomString.cs.meta new file mode 100644 index 00000000..b2ddfee1 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetRandomString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 355abdec2d73d2545b16d5e0d5f4c589 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetSubstring.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetSubstring.cs new file mode 100644 index 00000000..be5de33e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetSubstring.cs @@ -0,0 +1,37 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString +{ + [TaskCategory("Basic/String")] + [TaskDescription("Stores a substring of the target string")] + public class GetSubstring : Action + { + [Tooltip("The target string")] + public SharedString targetString; + [Tooltip("The start substring index")] + public SharedInt startIndex = 0; + [Tooltip("The length of the substring. Don't use if -1")] + public SharedInt length = -1; + [Tooltip("The stored result")] + [RequiredField] + public SharedString storeResult; + + public override TaskStatus OnUpdate() + { + if (length.Value != -1) { + storeResult.Value = targetString.Value.Substring(startIndex.Value, length.Value); + } else { + storeResult.Value = targetString.Value.Substring(startIndex.Value); + } + return TaskStatus.Success; + } + + public override void OnReset() + { + targetString = ""; + startIndex = 0; + length = -1; + storeResult = ""; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetSubstring.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetSubstring.cs.meta new file mode 100644 index 00000000..0849def5 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/GetSubstring.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6ce20430f88c32b418f29b42531eca4a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/IsNullOrEmpty.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/IsNullOrEmpty.cs new file mode 100644 index 00000000..b61c8eb1 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/IsNullOrEmpty.cs @@ -0,0 +1,22 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString +{ + [TaskCategory("Basic/String")] + [TaskDescription("Returns success if the string is null or empty")] + public class IsNullOrEmpty : Conditional + { + [Tooltip("The target string")] + public SharedString targetString; + + public override TaskStatus OnUpdate() + { + return string.IsNullOrEmpty(targetString.Value) ? TaskStatus.Success : TaskStatus.Failure; + } + + public override void OnReset() + { + targetString = ""; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/IsNullOrEmpty.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/IsNullOrEmpty.cs.meta new file mode 100644 index 00000000..9cb87727 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/IsNullOrEmpty.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f6f4d4c690c09bb48a388f36f4e30245 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Replace.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Replace.cs new file mode 100644 index 00000000..89db0f6e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Replace.cs @@ -0,0 +1,34 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString +{ + [TaskCategory("Basic/String")] + [TaskDescription("Replaces a string with the new string")] + public class Replace : Action + { + [Tooltip("The target string")] + public SharedString targetString; + [Tooltip("The old replace")] + public SharedString oldString; + [Tooltip("The new string")] + public SharedString newString; + [Tooltip("The stored result")] + [RequiredField] + public SharedString storeResult; + + public override TaskStatus OnUpdate() + { + storeResult.Value = targetString.Value.Replace(oldString.Value, newString.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetString = ""; + oldString = ""; + newString = ""; + storeResult = ""; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Replace.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Replace.cs.meta new file mode 100644 index 00000000..35f25181 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/Replace.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 30fc7adfdddc39245a433ea477c01adf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/SetString.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/SetString.cs new file mode 100644 index 00000000..4aca34d0 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/SetString.cs @@ -0,0 +1,28 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityString +{ + [TaskCategory("Basic/String")] + [TaskDescription("Sets the variable string to the value string.")] + public class SetString : Action + { + [Tooltip("The target string")] + [RequiredField] + public SharedString variable; + [Tooltip("The value string")] + public SharedString value; + + public override TaskStatus OnUpdate() + { + variable.Value = value.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + variable = ""; + value = ""; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/SetString.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/SetString.cs.meta new file mode 100644 index 00000000..5c2c6bc4 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/String/SetString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: da59105cbc94b5d4da3c805897f4a099 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: -- cgit v1.1-26-g67d0