コード例 #1
0
 public void Trigger()
 {
     Fungus.Variable v = null;
     if (!flowchart)
     {
         flowchart = FindFlowchartWithVariable(variableName, out v);
     }
     else
     {
         v = FindVariable(flowchart, variableName);
     }
     if (v.GetType() == typeof(Fungus.StringVariable))
     {
         flowchart.SetStringVariable(variableName, flowchart.GetStringVariable(variableName) + variableValue);
     }
     if (v.GetType() == typeof(Fungus.FloatVariable))
     {
         flowchart.SetFloatVariable(variableName, flowchart.GetFloatVariable(variableName) + System.Single.Parse(variableValue));
     }
     if (v.GetType() == typeof(Fungus.IntegerVariable))
     {
         flowchart.SetIntegerVariable(variableName, flowchart.GetIntegerVariable(variableName) + System.Int32.Parse(variableValue));
     }
     if (v.GetType() == typeof(Fungus.BooleanVariable))
     {
         flowchart.SetBooleanVariable(variableName, !flowchart.GetBooleanVariable(variableName));
     }
 }
コード例 #2
0
        /// <summary>
        /// Adds the passed variable to the passed list if it can be cast to the correct type.
        ///
        /// TBase: Base type encapsulated by the variable
        ///
        /// TSVarType: This save system's serializable container for the variable
        /// TNSVariableType: Fungus's built-in flowchart-only container for the variable
        /// </summary>
        protected virtual void TrySetVariable <TBase, TSVarType, TNSVariableType>(BaseFungus.Variable varToSet,
                                                                                  IList <TSVarType> varList)
            where TSVarType : Var <TBase>, new()
            where TNSVariableType : BaseFungus.VariableBase <TBase>
        {
            var fungusBaseVar = varToSet as TNSVariableType;

            if (fungusBaseVar != null)
            {
                var toAdd = new TSVarType();
                toAdd.Key   = fungusBaseVar.Key;
                toAdd.Value = fungusBaseVar.Value;
                varList.Add(toAdd);
            }
        }
コード例 #3
0
 public static Fungus.Flowchart FindFlowchartWithVariable(string variableName, out Fungus.Variable foundVariable)
 {
     Fungus.Flowchart   flowchart = null;
     Fungus.Flowchart[] flows     = GameObject.FindObjectsOfType <Fungus.Flowchart>();
     foundVariable = null;
     for (var f = 0; f < flows.Length && foundVariable == null; ++f)
     {
         flowchart     = flows[f]; // check to see if the variable in question is in this flowchart
         foundVariable = FindVariable(flowchart, variableName);
     }
     if (!flowchart)
     {
         Debug.LogError("Could not find flowchart with variable \"" + variableName + "\"");
     }
     return(flowchart);
 }
コード例 #4
0
ファイル: Command.cs プロジェクト: nullsquid/Diviner
 public virtual bool HasReference(Variable variable)
 {
     return false;
 }
コード例 #5
0
 public override bool HasReference(Variable variable)
 {
     return(_amount.vector3Ref == variable || base.HasReference(variable));
 }
コード例 #6
0
 public override bool HasReference(Variable variable)
 {
     return(startLabel.stringRef == variable || base.HasReference(variable));
 }
コード例 #7
0
ファイル: Conversation.cs プロジェクト: JE-00/j-esquerra
 public override bool HasReference(Variable variable)
 {
     return clearPrevious.booleanRef == variable || waitForInput.booleanRef == variable || 
         waitForSeconds.floatRef == variable || fadeWhenDone.booleanRef == variable ||
         base.HasReference(variable);
 }
コード例 #8
0
ファイル: ToInt.cs プロジェクト: ines3000/inkfungus-template
 public override bool HasReference(Variable variable)
 {
     return(variable == inValue.floatRef || variable == outValue.integerRef);
 }
コード例 #9
0
ファイル: SetVariable.cs プロジェクト: KRUR/NotJustASheep
 public override bool HasReference(Variable variable)
 {
     return (variable == this.variable);
 }
コード例 #10
0
ファイル: RandomInteger.cs プロジェクト: aidenstorey/ggj16
 public override bool HasReference(Variable variable)
 {
     return(variable == this.variable);
 }
コード例 #11
0
ファイル: IfEditor.cs プロジェクト: bursaar/TheFacility
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            If t = target as If;

            FungusScript fungusScript = t.GetFungusScript();

            if (fungusScript == null)
            {
                return;
            }

            VariableEditor.VariableField(variableProp,
                                         new GUIContent("Variable", "Variable to use in operation"),
                                         t.GetFungusScript(),
                                         null);

            if (variableProp.objectReferenceValue == null)
            {
                serializedObject.ApplyModifiedProperties();
                return;
            }

            Variable selectedVariable = variableProp.objectReferenceValue as Variable;

            System.Type variableType = selectedVariable.GetType();

            List <GUIContent> operatorList = new List <GUIContent>();

            operatorList.Add(new GUIContent("=="));
            operatorList.Add(new GUIContent("!="));
            if (variableType == typeof(IntegerVariable) ||
                variableType == typeof(FloatVariable))
            {
                operatorList.Add(new GUIContent("<"));
                operatorList.Add(new GUIContent(">"));
                operatorList.Add(new GUIContent("<="));
                operatorList.Add(new GUIContent(">="));
            }

            compareOperatorProp.enumValueIndex = EditorGUILayout.Popup(new GUIContent("Compare", "The comparison operator to use when comparing values"),
                                                                       compareOperatorProp.enumValueIndex,
                                                                       operatorList.ToArray());

            if (variableType == typeof(BooleanVariable))
            {
                EditorGUILayout.PropertyField(booleanValueProp);
            }
            else if (variableType == typeof(IntegerVariable))
            {
                EditorGUILayout.PropertyField(integerValueProp);
            }
            else if (variableType == typeof(FloatVariable))
            {
                EditorGUILayout.PropertyField(floatValueProp);
            }
            else if (variableType == typeof(StringVariable))
            {
                EditorGUILayout.PropertyField(stringValueProp);
            }

            serializedObject.ApplyModifiedProperties();
        }
コード例 #12
0
 public override bool HasReference(Variable variable)
 {
     return(variable == _amount.vector3Ref);
 }
コード例 #13
0
 public override bool HasReference(Variable variable)
 {
     return(variable == integer.integerRef || base.HasReference(variable));
 }
コード例 #14
0
        static public void VariableField(SerializedProperty property,
                                         GUIContent label,
                                         Flowchart flowchart,
                                         Func <Variable, bool> filter,
                                         Func <string, int, string[], int> drawer = null)
        {
            List <string>   variableKeys    = new List <string>();
            List <Variable> variableObjects = new List <Variable>();

            variableKeys.Add("<None>");
            variableObjects.Add(null);

            List <Variable> variables     = flowchart.variables;
            int             index         = 0;
            int             selectedIndex = 0;

            Variable selectedVariable = property.objectReferenceValue as Variable;

            foreach (Variable v in variables)
            {
                if (filter != null)
                {
                    if (!filter(v))
                    {
                        continue;
                    }
                }

                variableKeys.Add(v.key);
                variableObjects.Add(v);

                index++;

                if (v == selectedVariable)
                {
                    selectedIndex = index;
                }
            }

            Flowchart[] fsList = GameObject.FindObjectsOfType <Flowchart>();
            foreach (Flowchart fs in fsList)
            {
                if (fs == flowchart)
                {
                    continue;
                }

                List <Variable> publicVars = fs.GetPublicVariables();
                foreach (Variable v in publicVars)
                {
                    variableKeys.Add(fs.name + " / " + v.key);
                    variableObjects.Add(v);

                    index++;

                    if (v == selectedVariable)
                    {
                        selectedIndex = index;
                    }
                }
            }

            if (drawer == null)
            {
                selectedIndex = EditorGUILayout.Popup(label.text, selectedIndex, variableKeys.ToArray());
            }
            else
            {
                selectedIndex = drawer(label.text, selectedIndex, variableKeys.ToArray());
            }

            property.objectReferenceValue = variableObjects[selectedIndex];
        }
コード例 #15
0
        protected virtual void OnEnable()
        {
            Variable t = target as Variable;

            t.hideFlags = HideFlags.HideInInspector;
        }
コード例 #16
0
 public override bool HasReference(Variable variable)
 {
     return(a.floatRef == variable || b.floatRef == variable || percentage.floatRef == variable ||
            outValue.floatRef == variable);
 }
コード例 #17
0
 public override bool HasReference(Variable variable)
 {
     return (variable == stringVariable);
 }
コード例 #18
0
ファイル: FungusScript.cs プロジェクト: bursaar/TheFacility
		/**
		 * Returns a new variable key that is guaranteed not to clash with any existing variable in the list.
		 */
		public string GetUniqueVariableKey(string originalKey, Variable ignoreVariable = null)
		{
			int suffix = 0;
			string baseKey = originalKey;

			// Only letters and digits allowed
			char[] arr = baseKey.Where(c => (char.IsLetterOrDigit(c) || c == '_')).ToArray(); 
			baseKey = new string(arr);

			// No leading digits allowed
			baseKey = baseKey.TrimStart('0','1','2','3','4','5','6','7','8','9');

			// No empty keys allowed
			if (baseKey.Length == 0)
			{
				baseKey = "Var";
			}

			string key = baseKey;
			while (true)
			{
				bool collision = false;
				foreach(Variable variable in variables)
				{
					if (variable == ignoreVariable ||
					    variable.key == null)
					{
						continue;
					}

					if (variable.key.Equals(key, StringComparison.CurrentCultureIgnoreCase))
					{
						collision = true;
						suffix++;
						key = baseKey + suffix;
					}
				}
				
				if (!collision)
				{
					return key;
				}
			}
		}
コード例 #19
0
ファイル: WaitFrames.cs プロジェクト: csantacruza/Reporte
 public override bool HasReference(Variable variable)
 {
     return(frameCount.integerRef == variable || base.HasReference(variable));
 }