public bool validate(string oldFEN, out string newFEN, out ECheckState checkState, string move = "") { var foundFen = ""; var tmpCheckState = ECheckState.none; bool wait = true; var func = new Action<string>((s) => { if (s.Contains("Checkers: ") && s.Length > "Checkers: ".Length) tmpCheckState = ECheckState.check; if (s.Contains("Legal moves: ") && s.Length == "Legal moves: ".Length) tmpCheckState = ECheckState.mate; if (s.Contains("Fen: ")) { foundFen = s.Replace("Fen: ", ""); wait = false; } }); try { onNewLine += func; send("position fen " + oldFEN + (move == "" ? "" : " moves " + move)); send("d"); while (wait) System.Threading.Thread.Sleep(10); } finally { onNewLine -= func; } newFEN = foundFen; Console.WriteLine("Parsed FEN: " + foundFen); checkState = tmpCheckState; return oldFEN != newFEN || move == ""; //TODO }
protected override void DrawPropertyLayout(GUIContent label) { var property = this.Property; var attribute = this.Attribute; object pObjectFieldOwner = property.ParentValues[0]; bool bTargetIsMono = property.ParentValues[0] is MonoBehaviour; if (bTargetIsMono) { SCManagerGetComponent.DoUpdateGetComponentAttribute(property.ParentValues[0] as MonoBehaviour); } else { pObjectFieldOwner = property.ParentValues[0]; SCManagerGetComponent.DoUpdateGetComponentAttribute(property.Parent.ParentValues[0] as MonoBehaviour, property.ParentValues[0]); } PropertyContext <TitleContext> context; if (property.Context.Get(this, "Title", out context)) { context.Value = new TitleContext() { TitleHelper = new StringMemberHelper(property, const_strTitle), SubtitleHelper = new StringMemberHelper(property, const_strSubTitle), }; } if (property != property.Tree.GetRootProperty(0)) { EditorGUILayout.Space(); } SirenixEditorGUI.Title(const_strTitle, const_strSubTitle, TextAlignment.Left, true, true); GUI.enabled = false; GUIHelper.PushIndentLevel(EditorGUI.indentLevel + 1); foreach (var pPropertyChild in property.Children) { ChildRequireComponentAttribute pAttribute = pPropertyChild.Info.GetAttribute <ChildRequireComponentAttribute>(); if (pAttribute != null) { pPropertyChild.Label.text = "`" + pAttribute.strComponentName + "`"; ECheckState eCheckState = ECheckState.NotYet; eCheckState = CalculateCheckState(property, pPropertyChild); switch (eCheckState) { case ECheckState.NotYet: GUI.contentColor = Color.yellow; pPropertyChild.Label.image = EditorIcons.UnityWarningIcon; break; case ECheckState.Checked: GUI.contentColor = Color.green; pPropertyChild.Label.image = EditorIcons.Checkmark.Raw; break; case ECheckState.Fail: GUI.contentColor = Color.red; pPropertyChild.Label.image = EditorIcons.X.Raw; break; } } pPropertyChild.Draw(pPropertyChild.Label); } GUI.contentColor = Color.white; GUIHelper.PopIndentLevel(); GUI.enabled = true; }