public override void draw() { rect.height = 25f + ifStatements.Count * 100f + logicOperators.Count * 25f + 30f; drawInOutPoint(); titleRect = rect; titleRect.height = 20f; extendedRect = rect; extendedRect.y = rect.y + titleRect.height - 1f; extendedRect.height = rect.height - titleRect.height; GUILayout.BeginArea(titleRect, title, GUI.skin.box); GUILayout.EndArea(); GUILayout.BeginArea(extendedRect, GUI.skin.box); GUILayout.BeginVertical(); GUILayout.Space(5f); for (int i = 0; i < ifStatements.Count; i++) { if (i > 0) { logicOperators [i - 1] = (DSLogicGateType)EditorGUILayout.EnumPopup(logicOperators [i - 1]); } drawIfStatementBox(ifStatements [i]); } if (GUILayout.Button("+", GUILayout.Width(20f))) { if (ifStatements.Count > 0) { DSLogicGateType newOperator = DSLogicGateType.AND; logicOperators.Add(newOperator); } DSIfStatement newIf = new DSIfStatement(); ifStatements.Add(newIf); } GUILayout.EndVertical(); GUILayout.EndArea(); }
public static bool GetOutput(DSLogicGateType logicOperator, bool input1, bool input2) { switch (logicOperator) { case DSLogicGateType.AND: return(input1 && input2); case DSLogicGateType.OR: return(input1 || input2); default: return(true); } }