public MainWindow() { InitializeComponent(); var logic = new LogicObject(); DataContext = logic.Collection; }
public void SaveData(string name, LogicObject lo) { MessageString ms = new MessageString(name, JsonUtils.ClassOrStructToJson(lo)); msData.mesList.Add(ms); EditorUtility.SetDirty(msData); }
public static void ShowCreateMenu(GenericMenu menu, LogicObject logic, Action <LogicNodeBase> add, Vector2 mousePos) { if (OnShowMenu == null) { SetMenu(logic); } OnShowMenu(menu, logic, add, mousePos); }
public override void OnInspectorGUI() { LogicObject lo = (LogicObject)target; if (EditorApplication.isPlaying) { if (!lo.ShowAttrs && GUILayout.Button("ShowAttributes")) { lo.ShowAttrs = true; } if (lo.ShowAttrs && GUILayout.Button("HideAttributes")) { lo.ShowAttrs = false; } } serializedObject.Update(); GUI.enabled = !EditorApplication.isPlaying; GUI.color = Color.white; serializedObject.ApplyModifiedProperties(); var agent = lo.so.GetComponent <AIAgent>(); if (agent != null) { BTAsset btAsset = agent.BehaviourTree as BTAsset; BehaviourTree btInstance = agent.GetBehaviourTree(); GUI.enabled = btAsset != null; if (EditorApplication.isPlaying && btInstance != null) { if (GUILayout.Button("Preview", GUILayout.Height(24.0f))) { BehaviourTreeEditor.OpenDebug(btAsset, btInstance); } } else { if (GUILayout.Button("Edit", GUILayout.Height(24.0f))) { BehaviourTreeEditor.Open(btAsset); } } } if (m_inspector != null) { BTEditorStyle.EnsureStyle(); m_inspector.DrawGUI(); Repaint(); } else { EditorGUILayout.HelpBox("There are no values to display!", MessageType.Error); } GUI.enabled = true; }
public override void OnAdd(SceneObjectBaseComponent c) { base.OnAdd(c); transformComponent = (TransformComponent)c; Outer = new GameObject(U3DSceneObject.SceneObject.ToString()); OuterTransform = Outer.transform; LogicObject = Outer.GetComponent <LogicObject>(true); LogicObject.ID = U3DSceneObject.SceneObject.Id; }
static public void CreateNewModel(MachineStateGUI msg) { LogicObject r = CreateLogicObject("新建逻辑模块", msg.position); LogicObjectBehaviour be = new LogicObjectBehaviour(); be.logicObj = r; msg.state.stateBaseBehaviours.Add(be); msg.name = r.name; }
static LogicObject CreateLogicObject(string name, Vector2 pos) { LogicObject r = new LogicObject(); r.name = name; r.id = GetMaxID(data.logicObjs); r.editorPos = pos; data.logicObjs.Add(r); return(r); }
void OnSelectionChange() { if (logicObject == null && Selection.activeTransform != null) { LogicObject temp = Selection.activeTransform.GetComponent <LogicObject>(); if (temp != null) { ShowLogicMap(temp); } } }
/// <summary> /// Internal function. Important: do not call this function manually! /// </summary> public static void BackReusedID(LogicObject obj) { if (!instance) { return; } if (instance.m_reuseIDs.Count < 1) { instance.m_reuseIDs.Enqueue(0); } instance.m_reuseIDs.Enqueue(obj.id); }
/// <summary> /// Add object to update list. /// Object will add to update list immediately, but will receive update event from next frame. /// If obj already in update list, it will be moved to the end of update list. /// </summary> /// <param name="obj"></param> /// <returns></returns> public bool _AddObject(LogicObject obj) { if (!obj) { return(false); } m_objects.Remove(obj); m_objects.Add(obj); return(true); }
void CreateItem(MessageString ms) { LogicObject lo = JsonUtils.JsonToClassOrStruct <LogicObject>(ms.value); MachineStateGUI msg = MachineDataController.AddNewMachineStateGUI(new Vector2(500, 450), lo.name, false); LogicObjectBehaviour be = new LogicObjectBehaviour(); be.logicObj = lo; msg.state.stateBaseBehaviours.Add(be); msg.name = lo.name; LogicSystemEditorWindow.AddLogicObject(lo); }
/// <summary> /// Start Game, must after Initialize() /// </summary> public static void Start() { LogicObject.CreateModules(); InputManager.Initialize(); AudioManager.Initialize(); onGameStarted?.Invoke(); started = true; // Game started Root.instance.AddEventListener(Events.APPLICATION_EXIT, () => started = false); LoadLevel(startLevel); // Enter first game scene }
public override void OnInspectorGUI() { targetObj = (LogicObjectBehaviour)target; logicObj = targetObj.logicObj; GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("ID :" + logicObj.id); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); //logicObj.name = EditorDrawGUIUtil.DrawBaseValue ("Name", logicObj.name).ToString(); if (LogicSystemEditorWindow.data != null) { isStartModel = LogicSystemEditorWindow.data.startId == logicObj.id; } stateGUI.NormalStateColor = isStartModel ? UnityEditor.Graphs.Styles.Color.Yellow : UnityEditor.Graphs.Styles.Color.Gray; if (!isStartModel) { bool oldState = logicObj.isSupportAlwaysActive; logicObj.isSupportAlwaysActive = (bool)EditorDrawGUIUtil.DrawBaseValue("是否支持永远激活状态", logicObj.isSupportAlwaysActive); if (oldState != logicObj.isSupportAlwaysActive && logicObj.isSupportAlwaysActive) { foreach (var item in stateGUI.FromArrowLines) { MachineDataController.DeleteStateTransitionArrowLine(item); } } if (logicObj.isSupportAlwaysActive) { stateGUI.NormalStateColor = UnityEditor.Graphs.Styles.Color.Red; } DrawNameAndClassListGUI("事件:", logicObj.events, LogicComponentType.Event); DrawNameAndClassListGUI("条件:", logicObj.conditions, LogicComponentType.Condition); } DrawNameAndClassListGUI("动作:", logicObj.actions, LogicComponentType.Action); string tempStr = ""; foreach (int ch in logicObj.childObjects) { tempStr += ch + ","; } GUILayout.Label("Child ID:" + tempStr); GUILayout.Label("Pos:" + targetObj.logicObj.editorPos); GUILayout.Space(6); SaveToBackupGUI(); }
public static void ShowLogicMap(LogicObject logic) { EditorWindow.GetWindow(typeof(LogicPanel)).titleContent = new GUIContent("逻辑图"); logicObject = logic; if (!Application.isPlaying) { logicObject.SetValue(); } string boxPath = AssetDatabase.GetAssetPath(logic.CurrentLogicBox); if (!string.IsNullOrEmpty(boxPath)) { string showName = boxPath.Substring(boxPath.LastIndexOf("/") + 1); showName = showName.Substring(0, showName.LastIndexOf(".")); logic.CurrentLogicBox.name = showName; } }
//public EditorWindow animatorWindow; static void Init() { data = LogicObjectDataController.GetDataFromFile(logicDataName); if (data.logicObjs.Count == 0) { LogicObject r = CreateLogicObject("开始", new Vector2(500, 400)); data.startId = r.id; } Dictionary <int, MachineStateGUI> allState = new Dictionary <int, MachineStateGUI>(); foreach (var item in data.logicObjs) { MachineStateGUI msg = MachineDataController.AddNewMachineStateGUI(item.editorPos, item.name); LogicObjectBehaviour be = new LogicObjectBehaviour(); msg.state.stateBaseBehaviours.Add(be); be.state = msg.state; be.logicObj = item; bool isStartModel = LogicSystemEditorWindow.data.startId == item.id; msg.NormalStateColor = isStartModel ? UnityEditor.Graphs.Styles.Color.Yellow : UnityEditor.Graphs.Styles.Color.Gray; if (!isStartModel && item.isSupportAlwaysActive) { msg.NormalStateColor = UnityEditor.Graphs.Styles.Color.Red; } allState.Add(item.id, msg); } foreach (var item in data.logicObjs) { foreach (var child in item.childObjects) { MachineDataController.AddNewTransitionGUI(allState[item.id].state, allState[child].state); } } StateMachineEditorWindow.OnDrawLeftPartGUI = OnGUI; StateMachineEditorWindow.OnCreateMachineStateGUI = CreateNewModel; internalValueTypeList.Add(typeof(string).FullName); internalValueTypeList.Add(typeof(int).FullName); internalValueTypeList.Add(typeof(float).FullName); internalValueTypeList.Add(typeof(Vector2).FullName); internalValueTypeList.Add(typeof(Vector3).FullName); internalValueTypeList.Add(typeof(bool).FullName); }
private void OnEnable() { if (EditorApplication.isPlaying) { LogicObject lo = (LogicObject)target; var aic = lo.so.GetComponent <AIAgent>(); if (aic != null) { AIAgent agent = aic; Blackboard blackboard = agent.Blackboard; IDictionary <string, object> dict = GetRuntimeValues(blackboard); if (dict != null) { m_inspector = new PlayTimeBlackboardInspector(dict); } } } else { m_inspector = new DesignTimeBlackboardInspector(serializedObject); } }
private static void SetMenu(LogicObject logic) { List <Action <GenericMenu, LogicObject, Action <LogicNodeBase>, Vector2> > setAct = new List <Action <GenericMenu, LogicObject, Action <LogicNodeBase>, Vector2> >(); foreach (Type type in typeof(LogicNodeBase).Assembly.GetTypes()) { if (!type.IsClass) { continue; } foreach (object item in type.GetCustomAttributes(typeof(LogicNodeAttribute), true)) { Type classType = type; if (item.GetType() == typeof(LogicNodeAttribute)) { LogicNodeAttribute node = item as LogicNodeAttribute; setAct.Add((menu, lo, add, mousePos) => menu.Add(logic, node.MenuText, classType, add, mousePos)); break; } } } OnShowMenu = (menu, lo, add, mousePos) => setAct.ForEach(x => x(menu, lo, add, mousePos)); }
private string StartLogicObjectHandler(string[] startTagComponents) { _logicObject = LogicObject.None; if (startTagComponents.Length == 1) { _logicObject = startTagComponents[0].Equals(LogicObject.Array.ToString(), StringComparison.InvariantCultureIgnoreCase) ? LogicObject.Array : startTagComponents[0].Equals(LogicObject.File.ToString(), StringComparison.InvariantCultureIgnoreCase) ? LogicObject.File : startTagComponents[0].Equals(LogicObject.List.ToString(), StringComparison.InvariantCultureIgnoreCase) ? LogicObject.List : startTagComponents[0].Equals(LogicObject.Map.ToString(), StringComparison.InvariantCultureIgnoreCase) ? LogicObject.Map : startTagComponents[0].Equals(LogicObject.Pff.ToString(), StringComparison.InvariantCultureIgnoreCase) ? LogicObject.Pff : startTagComponents[0].Equals(LogicObject.ValueSet.ToString(), StringComparison.InvariantCultureIgnoreCase) ? LogicObject.ValueSet : LogicObject.None; } if (startTagComponents.Length != 0 && _logicObject == LogicObject.None) { throw new Exception("The logic object domain must be a valid symbol type"); } return(""); }
void OnEnable() { logicObject = target as LogicObject; }
void OnGUI() { if (logicObject == null) { return; } if (logicBox == null) { return; } EditorGUIUtility.labelWidth = 60; windowRect = new Rect(20, 20, position.width - 40, position.height - 60); mousePos = Event.current.mousePosition; GUILayout.BeginHorizontal(); GUILayout.Label("逻辑图:" + logicBox.name); GUILayout.Space(40); LogicObject tempObj = EditorGUILayout.ObjectField("物体", logicObject, typeof(LogicObject), true, GUILayout.Width(200)) as LogicObject; GUILayout.Space(50); logicBox.BoxWidth = EditorGUILayout.FloatField("宽:", logicBox.BoxWidth); logicBox.BoxHeight = EditorGUILayout.FloatField("高:", logicBox.BoxHeight); logicRect = new Rect(0, 0, logicBox.BoxWidth, logicBox.BoxHeight); if (tempObj != logicObject) { ShowLogicMap(tempObj); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (logicObject == null) { return; } GUILayout.BeginArea(windowRect, "", "box"); scroll = GUI.BeginScrollView(new Rect(0, 0, position.width - 40, position.height - 60), scroll, logicRect); logicBox.OnGUI(); GUI.EndScrollView(); GUILayout.EndArea(); Event evt = Event.current; if (linkSelect != null) { Handles.DrawLine((Vector3)linkSelect.Pos - scroll + new Vector3(20, 20, 0), mousePos); } if (evt.type == EventType.MouseDown) { OnMonseDown(); } else if (evt.type == EventType.ContextClick) { OnContextClick(); } else if (evt.type == EventType.MouseUp) { moveSelect = null; } if (moveSelect != null) { moveSelect.Pos = mousePos + offset; } if (logicSelect != null && evt.control && evt.type == EventType.KeyUp && evt.keyCode == KeyCode.D) { LogicNodeBase node = LogicNodeBase.Create(logicObject, mousePos + scroll, logicSelect.GetType()); Add(node); } if (logicSelect != null && evt.type == EventType.KeyUp && evt.keyCode == KeyCode.Delete) { RemoveNode(logicSelect); } if (evt.type == EventType.KeyUp && evt.control && evt.keyCode == KeyCode.S) { Save(); } GUILayout.BeginArea(new Rect(0, position.height - 40, position.width, 60)); GUILayout.BeginVertical(); GUILayout.Label(AssetDatabase.GetAssetPath(logicBox)); if (GUILayout.Button("另存为模板")) { SaveAsTemplate(); } GUILayout.EndVertical(); GUILayout.EndArea(); }
public static void AddLogicObject(LogicObject r) { r.id = GetMaxID(data.logicObjs); data.logicObjs.Add(r); }
public static bool AddObject(LogicObject obj) { return(instance._AddObject(obj)); }
void OnDestroy() { Save(); logicObject = null; }
private static void Add(this GenericMenu menu, LogicObject logic, string text, Type type, Action <LogicNodeBase> add, Vector2 mousePos) { menu.AddItem(new GUIContent(text), false, () => { add(LogicNodeBase.Create(logic, mousePos, type)); }); }
public bool GetPdfNow(int id, int radno, string thenum, string company, DateTime combined) { try { using (var db = new ImportPermitEntities()) { var log = new LogicObject(); var appItems = (from t in db.ApplicationItems.Include("Application") where t.ApplicationId == id orderby t.EstimatedValue descending select t).ToList(); if (!appItems.Any()) { return(false); } var items = new List <DatabaseObject>(); appItems.ForEach(t => { var im = new DatabaseObject() { Id = t.Id, ApplicationItemId = t.Id, ApplicationItemProductName = t.Product.Name, ApplicationItemEstimatedQuantity = t.EstimatedQuantity, ApplicationItemEstimatedValue = t.EstimatedValue, }; var appCountries = db.ApplicationCountries.Where(a => a.ApplicationItemId == im.Id).Include("Country").ToList(); var depotList = db.ThroughPuts.Where(a => a.ApplicationItemId == im.Id).Include("Depot").ToList(); if (appCountries.Any() && depotList.Any()) { im.ApplicationItemPortOfOrigin = ""; appCountries.ForEach(c => { if (string.IsNullOrEmpty(im.ApplicationItemPortOfOrigin)) { im.ApplicationItemPortOfOrigin = c.Country.Name; } else { im.ApplicationItemPortOfOrigin += ", " + c.Country.Name; } }); im.ApplicationItemPortOfDischarge = ""; depotList.ForEach(d => { if (string.IsNullOrEmpty(im.ApplicationItemPortOfDischarge)) { im.ApplicationItemPortOfDischarge = d.Depot.Name; } else { im.ApplicationItemPortOfDischarge += ", " + d.Depot.Name; } }); items.Add(im); } }); PdfDocument pdf = new PdfDocument(); //Next step is to create a an Empty page. PdfPage pp = pdf.AddPage(); string path = System.IO.Path.Combine(Server.MapPath("~/PermDoc"), "permitup.pdf"); //Then create an XGraphics Object XGraphics gfx = XGraphics.FromPdfPage(pp); XImage image = XImage.FromFile(path); gfx.DrawImage(image, 0, 0); XFont font = new XFont("Calibri", 12, XFontStyle.Regular); XFont font2 = new XFont("Calibri", 10, XFontStyle.Regular); gfx.DrawString(thenum, font, XBrushes.Black, new XRect(392, 70, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); gfx.DrawString(DateTime.Now.ToString("dd/MM/yy"), font, XBrushes.Black, new XRect(390, 95, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); gfx.DrawString("", font, XBrushes.Black, new XRect(70, 125, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); gfx.DrawString("", font, XBrushes.Black, new XRect(70, 150, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); gfx.DrawString("", font, XBrushes.Black, new XRect(60, 175, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); gfx.DrawString(company, font, XBrushes.Black, new XRect(80, 218, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); gfx.DrawString("", font, XBrushes.Black, new XRect(92, 240, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document(); Section section = doc.AddSection(); var table = section.AddTable(); //table = section.AddTable(); table.Style = "Table"; table.Borders.Width = 0.25; table.Borders.Left.Width = 0.5; table.Borders.Right.Width = 0.5; table.Rows.LeftIndent = 0; Column column = table.AddColumn("4cm"); column.Format.Alignment = ParagraphAlignment.Center; column = table.AddColumn("4cm"); column.Format.Alignment = ParagraphAlignment.Center; column = table.AddColumn("4cm"); column.Format.Alignment = ParagraphAlignment.Center; column = table.AddColumn("4cm"); column.Format.Alignment = ParagraphAlignment.Center; // Create the header of the table Row row = table.AddRow(); //row = table.AddRow(); row.HeadingFormat = true; row.Format.Alignment = ParagraphAlignment.Center; row.Format.Font.Bold = true; row.Cells[0].AddParagraph("Type of Petroleum Product:"); row.Cells[0].Format.Alignment = ParagraphAlignment.Left; row.Cells[1].AddParagraph("Country of origin:"); row.Cells[1].Format.Alignment = ParagraphAlignment.Left; row.Cells[2].AddParagraph("Quantity/Weight (Metric Tones):"); row.Cells[2].Format.Alignment = ParagraphAlignment.Left; row.Cells[3].AddParagraph("Estimated Value($):"); row.Cells[3].Format.Alignment = ParagraphAlignment.Left; double total = 0; if (items.Any() && items.Count() <= 7) { foreach (var item in items.ToList()) { row = table.AddRow(); row.Cells[0].AddParagraph(item.ApplicationItemProductName); row.Cells[0].Format.Alignment = ParagraphAlignment.Left; total = total + item.ApplicationItemEstimatedValue; row.Cells[1].AddParagraph(item.ApplicationItemPortOfOrigin); row.Cells[1].Format.Alignment = ParagraphAlignment.Left; row.Cells[2].AddParagraph(item.ApplicationItemEstimatedQuantity.ToString()); row.Cells[2].Format.Alignment = ParagraphAlignment.Left; row.Cells[3].AddParagraph(item.ApplicationItemEstimatedValue.ToString()); row.Cells[3].Format.Alignment = ParagraphAlignment.Left; } } else if (items.Any() && items.Count() > 7) { foreach (var item in items.ToList()) { row = table.AddRow(); row.Format.Font.Size = 8; row.Cells[0].AddParagraph(item.ApplicationItemProductName); row.Cells[0].Format.Alignment = ParagraphAlignment.Left; total = total + item.ApplicationItemEstimatedValue; row.Cells[1].AddParagraph(item.ApplicationItemPortOfOrigin); row.Cells[1].Format.Alignment = ParagraphAlignment.Left; row.Cells[2].AddParagraph(item.ApplicationItemEstimatedQuantity.ToString()); row.Cells[2].Format.Alignment = ParagraphAlignment.Left; row.Cells[3].AddParagraph(item.ApplicationItemEstimatedValue.ToString()); row.Cells[3].Format.Alignment = ParagraphAlignment.Left; } } //convert total amount to words var amtWords = log.ChangeToWords(total.ToString(), true); const bool unicode = false; const PdfFontEmbedding embedding = PdfFontEmbedding.Always; PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding); // Associate the MigraDoc document with a renderer pdfRenderer.Document = doc; // Layout and render document to PDF pdfRenderer.RenderDocument(); var pathtable = System.IO.Path.Combine(Server.MapPath("~/PermDoc"), "table.pdf"); pdfRenderer.PdfDocument.Save(pathtable); XImage imagetable = XImage.FromFile(pathtable); gfx.DrawImage(imagetable, 0, 280); //rigid style XImage image2 = XImage.FromFile(System.IO.Path.Combine(Server.MapPath("~/PermDoc"), "permitdown.pdf")); gfx.DrawImage(image2, 0, 550); gfx.DrawString(amtWords, font2, XBrushes.Black, new XRect(135, 556, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); gfx.DrawString("", font, XBrushes.Black, new XRect(238, 593, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); gfx.DrawString("", font, XBrushes.Black, new XRect(220, 633, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); gfx.DrawString(DateTime.Now.ToString("dd/MM/yy"), font, XBrushes.Black, new XRect(100, 673, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); gfx.DrawString(combined.ToString("dd/MM/yy"), font, XBrushes.Black, new XRect(370, 673, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft); string path2 = System.IO.Path.Combine(Server.MapPath("~/PermDoc"), "permit" + radno + ".pdf"); //string path2 = System.IO.Path.Combine(Server.MapPath("~/PermDoc"), "permit.pdf"); pdf.Save(path2); return(true); } } catch (Exception ex) { return(false); } }