public void UpdateValue() { counter.text = parameter.PValue.ToString(); GetComponent <Button>().interactable = parameter.activating; if ((parameter.manualActivationWithState || parameter.withChange) && parameter.activating) { if (ExpressionSolver.CalculateBool(parameter.manualUsingCondition.conditionString, parameter.manualUsingCondition.Parameters)) { GetComponent <Button>().interactable = true; } else { GetComponent <Button>().interactable = false; } } if (parameter.PValue <= 0) { Destroy(gameObject); } if (parameter.PValue == 1) { counter.enabled = false; } else { counter.enabled = true; } }
public bool CheckCondition(Condition condition) { List <float> playerParameters = new List <float>(); foreach (Param p in condition.Parameters) { InitParam(p); playerParameters.Add(saveInfo.paramsDictionary[p.paramGUID]); Debug.Log(saveInfo.paramsDictionary[p.paramGUID]); } return(ExpressionSolver.CalculateBool(condition.conditionString, playerParameters)); }
public void SetParam(string name, float value, bool check = true) { if (check) { parameters.First(x => x.name == name).PValue = value; } else { parameters.First(x => x.name == name).pValue = value; } foreach (ConditionChange pch in parameters.First(x => x.name == name).autoActivatedChangesGUIDS) { if (ExpressionSolver.CalculateBool(pch.condition.conditionString, pch.condition.Parameters)) { foreach (ParamChanges pcha in pch.changes) { SetParam(pcha.aimParam.name, pcha.changeString, pcha.parameters, false); } } } OnParamChanging.Invoke(parameters.First(x => x.name == name)); }
private void DrawCondition(Path path) { EditorGUILayout.LabelField("condition:"); EditorGUILayout.BeginHorizontal(); GUI.backgroundColor = Color.white; try { List <float> pv = new List <float>(); foreach (Param p in path.condition.Parameters) { pv.Add(0); } ExpressionSolver.CalculateBool(path.condition.conditionString, pv); } catch { GUI.color = Color.red; } EditorGUI.BeginChangeCheck(); string conditionString = EditorGUILayout.TextField(path.condition.conditionString); GUI.color = Color.white; EditorGUILayout.EndHorizontal(); Param removingParam = null; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(p, "path condition string"); path.condition.conditionString = conditionString; } for (int i = 0; i < path.condition.Parameters.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("[p" + i + "]", GUILayout.Width(35)); if (!p.Game.parameters.Contains(path.condition.Parameters[i])) { if (p.Game.parameters.Count > 0) { path.condition.Parameters[i] = p.Game.parameters[0]; } else { removingParam = path.condition.Parameters[i]; continue; } } EditorGUI.BeginChangeCheck(); int paramIndex = EditorGUILayout.Popup(p.Game.parameters.IndexOf(path.condition.Parameters[i]), p.Game.parameters.Select(x => x.paramName).ToArray()); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(p, "set condition param"); path.condition.setParam(i, p.Game.parameters[paramIndex]); } GUI.color = Color.red; if (GUILayout.Button("", GUILayout.Height(15), GUILayout.Width(15))) { removingParam = path.condition.Parameters[i]; } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); } if (removingParam != null) { Undo.RecordObject(p, "removing condition param"); path.condition.RemoveParam(removingParam); } }