private void OnEnable() { numberOfItems = 3; list = new ReorderableList(serializedObject, serializedObject.FindProperty("eventAction"),true,true,true,true); list.drawHeaderCallback = (Rect rect) => { GUI.Label(rect, "Event Actions"); }; list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { //get property var element = list.serializedProperty.GetArrayElementAtIndex(index); rect = new Rect(rect.x,rect.y, rect.width,EditorGUIUtility.singleLineHeight); //layout shit DrawEventActionPopup(element, rect); rect.y = rect.y + gap; DrawPlaybackActions(element, rect); DrawMixerActions(element, rect); rect.y = rect.y + gap; if (element.FindPropertyRelative("bypassEvent").boolValue) { rect.y = rect.y + gap; GUI.color = Color.green; DrawSwitchStatePopup(element, rect); GUI.color = Color.white; } }; eNode = target as EventNode; }
public void AddAction(string entry) { this.treeViewDebuggerEvents.BeginUpdate(); EventNode node = new EventNode(entry); this._model.Nodes.Add(node); this.treeViewDebuggerEvents.EndUpdate(); }
/// <summary> /// 根据一个id去掉一个消息 /// </summary> /// <param name="id"></param> /// <param name="mono"></param> public void UnRegisterMsg(ushort id, IMonoBase mono) { if (!eventTree.ContainsKey(id)) { Debug.Log("不存在这个消息ID: " + id); } else { //释放消息分三种情况,头部、中部、尾部释放 EventNode head = eventTree[id]; if (head.data == mono)//头部 { //头部后面还有节点 if (head.next != null) { eventTree[id] = head.next; head.next = null; } else//头部后面没有节点 { eventTree.Remove(id); } } else//去掉尾部和中间 { EventNode temp = head; while (temp.next != null && temp.next.data != mono) { temp = temp.next; } //表示已经找到目标节点temp.next if (temp.next.next != null)//目标节点是中部节点 { EventNode targetNode = temp.next; temp.next = targetNode.next; targetNode.next = null; } else//目标节点是尾部节点 { temp.next = null; } } } }
/// <summary> /// 注销一个消息 /// 去掉一个消息链表 /// </summary> /// <param name="id"></param> /// <param name="node"></param> public void UnRegistMsg(ushort id, MonoBase node) { if (!EventTree.ContainsKey(id)) { Debug.LogError("no contains is == " + id); return; } else { EventNode temp = EventTree[id]; if (temp.data == node)//去掉头部,包含两种情况 { EventNode header = temp; //已经存在这个消息 if (header.next != null) //后面有多个节点 { header.data = temp.next.data; header.next = temp.next.next; } else//只有一个节点 { EventTree.Remove(id); } } else//去掉尾部和中间的部分 { while (temp.next != null && temp.next.data != null) { temp = temp.next; }//走完这个循环,表示已经找到该节点 //没有引用会自动释放 if (temp.next != null)//去掉中间的 { temp.next = temp.next.next; } else//去掉尾部的 { temp.next = null; } } } }
/// <summary> /// 去掉一个消息链表 /// </summary> /// <param name="id"></param> /// <param name="node"></param> public void UnRegistMsg(ushort id, MonoBase node) { if (!eventTree.ContainsKey(id)) { Debug.LogWarning("Not contain id ==" + id); return; } else { EventNode temp = eventTree[id]; if (temp.data == node)//去掉头部的节点,包含两种情况 { EventNode header = temp; //已经存在这个 消息 if (header.NextNode != null) { //header.data = temp.NextNode.data; //header.NextNode = temp.NextNode.NextNode; eventTree[id] = temp.NextNode; } else//只有一个节点的情况 { eventTree.Remove(id); } } else//去掉尾部和中间的节点 { while (temp.NextNode != null && temp.NextNode.data == node) { temp = temp.NextNode; }//找到需要修改的节点 if (temp.NextNode.NextNode != null) { temp.NextNode = temp.NextNode.NextNode; } else { temp.NextNode = null; } } } }
private void WriteEventTag(StreamWriter writer, EventNode sourceNode, EventNode currentNode) { foreach (var child in currentNode.Children) { if (sourceNode.Name == child.Name && null != child.Tags && 0 != child.Tags.Count) { var builder = new StringBuilder(); var tags = child.Tags; foreach (var tag in tags) { builder.Append(tag.FormattedValue); builder.Append(spliter_); } writer.WriteLine(builder.ToString()); } WriteEventTag(writer, sourceNode, child as EventNode); } }
private bool AddAction(Type?type) { if (type == null) { return(false); } Vector2 spawnPos = Cam.WorldViewCenter; spawnPos.Y = -spawnPos.Y; EventNode newNode = new EventNode(type, type.Name) { ID = CreateID() }; newNode.Position = spawnPos - newNode.Size / 2; nodeList.Add(newNode); return(true); }
/// <summary> /// 注册一个消息 /// </summary> /// <param name="id">msg id</param> /// <param name="eventNode">链表</param> public void RegistMsg(ushort id, EventNode eventNode) { //数据链路里面没有这个消息 if (!EventTree.ContainsKey(id)) { EventTree.Add(id, eventNode); } else { EventNode tempNode = EventTree[id]; //找到最后一个 while (tempNode.next != null) { tempNode = tempNode.next; } //直接挂到最后一个 tempNode.next = eventNode; } }
public int FindNode(Point point, ThreadScroll scroll, out EventFrame eventFrame, out EventNode eventNode) { ITick tick = scroll.PixelToTime(point.X); int index = Data.Utils.BinarySearchExactIndex(EventData.Events, tick.Start); EventFrame resultFrame = null; EventNode resultNode = null; int resultLevel = -1; if (index >= 0) { EventFrame frame = EventData.Events[index]; int desiredLevel = (int)(point.Y / RenderParams.BaseHeight); GetTree(frame).ForEachChild((node, level) => { if (level > desiredLevel || resultFrame != null) { return(false); } if (level == desiredLevel) { EventNode evNode = (node as EventNode); if (evNode.Entry.Intersect(tick.Start)) { resultFrame = frame; resultNode = evNode; resultLevel = level; return(false); } } return(true); }); } eventFrame = resultFrame; eventNode = resultNode; return(resultLevel); }
/// <summary> /// /// </summary> /// <param name="id">根据msgid</param> /// <param name="node">node 链表</param> public void RegistMsg(ushort id, EventNode node) { //数据链路里 没有这个消息id if (!enventTree.ContainsKey(id)) { enventTree.Add(id, node); } else { EventNode tmp = enventTree[id]; //找到最后一个节点 while (tmp.next != null) { tmp = tmp.next; } //直接挂到最后一个节点 tmp.next = node; } }
private void DeleteNode() { //所有现有node断开与其的连接 EventGroup.ListNodes.ForEach(node => { node.Selections.ForEach(selection => { if (selection.NextEventID == _selectedNode.ID) { selection.NextEventID = 0; } }); }); //所有暂存Transition移除相关连接 _listTransitions.RemoveAll(transition => transition.StartNode == _selectedNode.ID || transition.EndNode == _selectedNode.ID); //删除node EventGroup.ListNodes.Remove(_selectedNode); _selectedNode = null; }
public void FocusOn(EventFrame frame, EventNode node) { if (!IsFrameVisible(frame)) { double minRange = frame.Duration * FocusFrameExtent; if (Range < minRange) { Range = minRange; } Position = Durable.TicksToMs(frame.Header.Start - timeRange.Start) + (frame.Duration - Range) / 2; } FocusedFrame = frame; FocusedNode = node; UpdateBar(); Refresh(); }
void BuildMeshNode(DirectX.DynamicMesh builder, ThreadScroll scroll, EventNode node, int level) { if (level == MaxDepth) { return; } Interval interval = scroll.TimeToUnit(node.Entry); double y = (double)level / MaxDepth; double h = 1.0 / MaxDepth; builder.AddRect(new Rect(interval.Left, y, interval.Width, h), node.Description.Color); foreach (EventNode child in node.Children) { BuildMeshNode(builder, scroll, child, level + 1); } }
/// <summary> /// 来了消息之后,通知整个消息链表 , 找到对应的 Mono 脚本去执行这个消息 /// </summary> /// <param name="msg"></param> public override void ProcessEvent(MsgBase msg) { if (!nodeDic.ContainsKey(msg.msgId)) { Debug.LogError("没有注册" + msg.msgId); Debug.LogError(msg.GetManager() + "这个管理器出的问题"); return; } // 字典里有 : 从链表里找到 EventNode tempNode = nodeDic[msg.msgId]; do { // 通过 msg.msgId 找到对应的链表 , 全部通知 // 链表里注册了 msg.msgId 这个消息的 mono , 都要执行这个方法 tempNode.mono.ProcessEvent(msg); tempNode = tempNode.next; }while (tempNode != null); }
public void RegistMsg(ushort id, EventNode node) { //数据链路里面没有这个消息的ID if (!eventTree.ContainsKey(id)) { eventTree.Add(id, node); } else { EventNode temp = eventTree[id]; //找到最后一个车厢 while (temp.NextNode != null) { temp = temp.NextNode; } temp.NextNode = node; } }
public override void OnMouseClick(Point point, ThreadScroll scroll) { EventNode node = null; EventFrame frame = null; int level = FindNode(point, scroll, out frame, out node); if (EventNodeSelected != null) { ITick tick = scroll.PixelToTime(point.X); if (frame == null) { frame = FindFrame(tick); } if (frame != null) { EventNodeSelected(this, frame, node); } } }
public override void ProcessEvent(MessageBase msg) { if (!eventTreeDic.ContainsKey(msg.msgId)) { Debug.LogError("字典里没有该信息" + msg); Debug.LogError("Msg Manager ==" + msg.GetManagerId()); return; } else { EventNode tempNode = eventTreeDic[msg.msgId]; do { // 策略模式 tempNode.data.ProcessEvent(msg); }while (tempNode != null); } }
public override void ProcessEvent(MsgBase msg) { if (!eventTree.ContainsKey(msg.msgId)) { Debug.LogWarning("没有这个消息 ID: " + msg.msgId + "Msg Manager:" + msg.GetManagerID()); return; } else { EventNode headNode = eventTree[msg.msgId]; EventNode temp = headNode; //通过key找到链表通知这个链表上的所有节点 do { temp.data.ProcessEvent(msg); temp = temp.next; } while (temp != null); } }
// 랜덤한 종류의 노드를 생성해서 반환한다. public Node GetRandomNode() { Node node = null; NodeName rand = (NodeName)Random.Range((int)NodeName.StartNode, (int)NodeName.EndNode); switch (rand) { case NodeName.StartNode: node = new Node(nTree.Root); break; case NodeName.MonsterNode: node = new MonsterNode(nTree.Root); break; case NodeName.EliteMonstaerNode: node = new EliteMonsterNode(nTree.Root); break; case NodeName.EventNode: node = new EventNode(nTree.Root); break; case NodeName.FogNode: node = new FogNode(nTree.Root); break; case NodeName.ShopNode: node = new ShopNode(nTree.Root); break; case NodeName.CampNode: node = new CampNode(nTree.Root); break; default: Debug.Log("RandomNode Error"); break; } return(node); }
private void CreateNewNode(Vector2 createAt) { if (EventGroup.ListNodes == null) { EventGroup.ListNodes = new List <EventNode>(); _lastEventID = 1; } EventNode newNode = new EventNode(EventGroup.Config.Effects.Count) { ID = _lastEventID, Position = createAt }; for (int i = 0; i < EventGroup.Config.DefaultSelectionCount; i++) { AddNodeSelection(newNode); } EventGroup.ListNodes.Add(newNode); _lastEventID++; }
public ControlFlowGraph(IEventNode node) { var entryNode = new EventNode(-1, null) { NextEvent = node }; var terminalNode = new EventNode(-2, null); //var leaders = new HashSet<IEventNode> { entryNode, node, terminalNode }; // Entry and exit nodes are always leaders //FindLeaders(entryNode, leaders, terminalNode); BuildBlocks(entryNode, terminalNode);//, leaders); LinkBlocks(); Start = Blocks[entryNode]; if (!Blocks.ContainsKey(terminalNode)) { throw new InvalidOperationException("Invalid procedure: never exits"); } End = Blocks[terminalNode]; CombineBlocks(); }
/// <summary> /// 注册消息 /// </summary> /// <param name="msg">根据 msgId 保存的</param> /// <param name="node">node链表</param> public void RegistMsg(ushort msgId, EventNode node) { // 数据链路里面没有这个 消息 if (!nodeDic.ContainsKey(msgId)) { nodeDic.Add(msgId, node); } else // 如果字典里已经有的话 , 挂到最后一个链子上 { // 这个是 挂的第一个 EventNode tempNode = nodeDic[msgId]; // 如果不是最后一个,就一直往下找 while (tempNode.next != null) { tempNode = tempNode.next; } tempNode.next = node; // 把node挂到最后一个链子上 } }
public EventNode AddEvent(string eventName, string eventDescription, params OutputHook[] outputs) { EventNode eventNode = new EventNode() .SetPosition(new VectorPosition(0, 0)) .SetProgram(this) .SetName(eventName) .SetDesc(eventDescription) as EventNode; eventNode.SetOutputs(outputs); eventNode.Init(); eventNode.InitChildren(); foreach (OutputHook hook in outputs) { hook.SetProgram(this); hook.SetNode(eventNode); } return(AddEvent(eventNode)); }
private void AddListener(int ge, EventNode node) { // 如果第一次注册此类事件,需要创建对应链表 List <EventNode> list; if (!eventMap.TryGetValue(ge, out list)) { list = new List <EventNode>(); eventMap.Add(ge, list); } // 如果重复注册则返回 for (int i = 0; i < list.Count; ++i) { if (list[i].IsEqual(node)) { return; } } list.Add(node); }
public override void ProccessEvent(MsgBase tmpMsg) { if (!eventTree.ContainsKey(tmpMsg.msgId)) { Debug.LogError("msg not contain msgid==" + tmpMsg.msgId); Debug.LogError("Msg Manager" + tmpMsg.GetManager()); return; } else { if (eventTree.Count > 0) { EventNode tmp = eventTree[tmpMsg.msgId]; do { tmp.data.ProccessEvent(tmpMsg); tmp = tmp.next; }while (tmp != null); } } }
public void OnDataClick(FrameworkElement parent, int index) { if (Stats != null && 0 <= index && index < Stats.Samples.Count) { FunctionStats.Sample sample = Stats.Samples[index]; Entry maxEntry = null; double maxDuration = 0; sample.Entries.ForEach(e => { if (maxDuration < e.Duration) { maxDuration = e.Duration; maxEntry = e; } }); if (maxEntry != null) { EventNode maxNode = maxEntry.Frame.Root.FindNode(maxEntry); parent.RaiseEvent(new TimeLine.FocusFrameEventArgs(TimeLine.FocusFrameEvent, new EventFrame(maxEntry.Frame, maxNode), null)); } } }
public void FocusOn(EventFrame frame, EventNode node) { Group = frame.Group; SelectionList.Clear(); SelectionList.Add(new Selection() { Frame = frame, Node = node }); Interval interval = scroll.TimeToUnit(node != null ? (IDurable)node.Entry : (IDurable)frame); if (!scroll.ViewUnit.Intersect(interval)) { scroll.ViewUnit.Width = interval.Width * DefaultFrameZoom; scroll.ViewUnit.Left = interval.Left - (scroll.ViewUnit.Width - interval.Width) * 0.5; scroll.ViewUnit.Normalize(); UpdateBar(); } UpdateSurface(); }
/// <summary> /// Used to add a state to the state machine. /// </summary> /// <param name="state">The state for the state machine.</param> /// <returns>The state machine to provide a fluent api.</returns> /// <exception cref="DuplicateStateRegisterException<TState>"></exception> public PersistedStateMachine <TState, TEvent, TContext, TMessage> Add(IState <TState, TEvent, TContext, TMessage> state) { if (this.stateLookup.ContainsKey(state.State)) { throw new DuplicateStateRegisterException <TState>(state.State); } this.stateLookup[state.State] = state; foreach (var transitionInfo in state.SupportedTransitions) { EventNode node; if (!this.eventLookup.TryGetValue(transitionInfo.Event, out node)) { node = new EventNode(transitionInfo.Event); this.eventLookup[transitionInfo.Event] = node; } node.AddState(state.State, this.From(transitionInfo)); } return(this); }
// image drawing // advance the game by one time unit public void timerTick(double numSeconds) { EventNode currentEvent = this.currentEvent; EventNode newEvent = this.currentEvent.TimerTick(numSeconds); if (newEvent == null) { Application.Current.Shutdown(); return; } if (newEvent != currentEvent) { this.showEvent(newEvent); } Screen newScreen = newEvent.GetScreen(); if (newScreen != this.currentScreen) { this.setScreen(newScreen); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (this.StopProcessing || CMSContext.CurrentDocument == null || CMSContext.CurrentDocument.NodeClassName.ToLower() != "cms.bookingevent") { // Do nothing this.Visible = false; } else { // Get current event document EventNode = CMSContext.CurrentDocument; // Get event date, open from/to, capacity and possibility to register over capacity information eventDate = ValidationHelper.GetDateTime(EventNode.GetValue("EventDate"), DataHelper.DATETIME_NOT_SELECTED); openFrom = ValidationHelper.GetDateTime(EventNode.GetValue("EventOpenFrom"), DataHelper.DATETIME_NOT_SELECTED); openTo = ValidationHelper.GetDateTime(EventNode.GetValue("EventOpenTo"), DataHelper.DATETIME_NOT_SELECTED); capacity = ValidationHelper.GetInteger(EventNode.GetValue("EventCapacity"), 0); allowRegistrationOverCapacity = ValidationHelper.GetBoolean(EventNode.GetValue("EventAllowRegistrationOverCapacity"), false); // Display registration section DisplayRegistration(); // Display link to iCalendar file which adds this event to users Outlook if (this.AllowExportToOutlook) { TimeZoneInfo tzi = null; CMSContext.GetDateTimeForControl(this, DateTime.Now, out tzi); string timeZoneId = string.Empty; if (tzi != null) { timeZoneId = "&timezoneid=" + tzi.TimeZoneID; } lnkOutlook.NavigateUrl = "~/CMSModules/EventManager/CMSPages/AddToOutlook.aspx?eventid=" + EventNode.NodeID.ToString() + timeZoneId; lnkOutlook.Target = "_blank"; lnkOutlook.Text = GetString("eventmanager.exporttooutlook"); lnkOutlook.Visible = true; } } }
private void SampleFunction(EventFrame eventFrame, EventNode node, bool single) { List <Callstack> callstacks = new List <Callstack>(); FrameGroup group = eventFrame.Group; if (single) { Utils.ForEachInsideIntervalStrict(group.Threads[eventFrame.Header.ThreadIndex].Callstacks, node.Entry, callstack => callstacks.Add(callstack)); } else { EventDescription desc = node.Entry.Description; foreach (ThreadData thread in group.Threads) { HashSet <Callstack> accumulator = new HashSet <Callstack>(); foreach (EventFrame currentFrame in thread.Events) { List <Entry> entries = null; if (currentFrame.ShortBoard.TryGetValue(desc, out entries)) { foreach (Entry entry in entries) { Utils.ForEachInsideIntervalStrict(thread.Callstacks, entry, c => accumulator.Add(c)); } } } callstacks.AddRange(accumulator); } } if (callstacks.Count > 0) { SamplingFrame frame = new SamplingFrame(callstacks); Profiler.TimeLine.FocusFrameEventArgs args = new Profiler.TimeLine.FocusFrameEventArgs(Profiler.TimeLine.FocusFrameEvent, frame); RaiseEvent(args); } }
private void Flush() { EventDescription desc = FunctionSearchDataGrid.SelectedItem as EventDescription; if (desc != null) { if (Group != null) { double maxDuration = 0; EventFrame maxFrame = null; Entry maxEntry = null; foreach (ThreadData thread in Group.Threads) { foreach (EventFrame frame in thread.Events) { List <Entry> entries = null; if (frame.ShortBoard.TryGetValue(desc, out entries)) { foreach (Entry entry in entries) { if (entry.Duration > maxDuration) { maxFrame = frame; maxEntry = entry; maxDuration = entry.Duration; } } } } } if (maxFrame != null && maxEntry != null) { EventNode maxNode = maxFrame.Root.FindNode(maxEntry); RaiseEvent(new TimeLine.FocusFrameEventArgs(TimeLine.FocusFrameEvent, new EventFrame(maxFrame, maxNode), null)); } } } }
/// <summary> /// 挂载一个消息节点到当前节点上 /// </summary> /// <param name="node">消息节点</param> /// <returns>如果当前节点里面已经包含已经要添加的这个节点那么返回false</returns> public bool AttachEventNode(EventNode node) { if (node == null) { return false; } if (mNodeList.Contains(node)) return false; int pos = 0; for (int i = 0; i < mNodeList.Count; i++) { if (node.EventNodePriority > mNodeList[i].EventNodePriority) { break; } pos++; } mNodeList.Insert(pos, node); return true; }
void InitNode(EventNode node, double frameStartMS, int level) { double height = FrameHeightConverter.Convert(node.Entry.Duration); if (height < 6.0 && level != 0) return; Rectangle rect = new Rectangle(); rect.Width = double.NaN; rect.Height = height; rect.Fill = new SolidColorBrush(node.Entry.Description.Color); double startTime = (node.Entry.StartMS - frameStartMS); rect.Margin = new Thickness(0, FrameHeightConverter.Convert(startTime), 0, 0); rect.VerticalAlignment = VerticalAlignment.Top; LayoutRoot.Children.Add(rect); foreach (EventNode child in node.Children) { InitNode(child, frameStartMS, level + 1); } }
/// <summary> /// Constructor for the <c>InputElement</c> object. This /// is used to create an input node that will provide access to /// an XML element. All attributes associated with the element /// given are extracted and exposed via the attribute node map. /// </summary> /// <param name="parent"> /// this is the parent XML element for this /// </param> /// <param name="reader"> /// this is the reader used to read XML elements /// </param> /// <param name="node"> /// this is the XML element wrapped by this node /// </param> public InputElement(InputNode parent, NodeReader reader, EventNode node) { this.map = new InputNodeMap(this, node); this.reader = reader; this.parent = parent; this.node = node; }
internal EventNode(IQEvent qEvent, EventNode nextNode) { m_QEvent = qEvent; m_NextNode = nextNode; }
/// <summary> /// Removes the current head node from the linked list and returns its associated <see cref="QEvent"/>. /// </summary> /// <returns></returns> internal IQEvent RemoveHeadEvent() { IQEvent qEvent = null; if (m_HeadNode != null) { qEvent = m_HeadNode.QEvent; m_HeadNode = m_HeadNode.NextNode; m_Count--; } return qEvent; }
private void DoSequence(){ EditorGUIUtility.labelWidth=63; SerializedObject serializedObject = new SerializedObject (tweener); serializedObject.Update (); SerializedProperty sequenceArray = serializedObject.FindProperty ("sequences"); if(selectedSequenceIndex < sequenceArray.arraySize){ SerializedProperty sequenceProperty = sequenceArray.GetArrayElementAtIndex (selectedSequenceIndex); SerializedProperty sequenceName=sequenceProperty.FindPropertyRelative("name"); SerializedProperty playAutomatically=sequenceProperty.FindPropertyRelative("playAutomatically"); EditorGUILayout.PropertyField(sequenceName); EditorGUILayout.PropertyField(playAutomatically); SerializedProperty nodesArray = sequenceProperty.FindPropertyRelative ("nodes"); if(selectedNodeIndex < nodesArray.arraySize){ SerializedProperty nodeProperty = nodesArray.GetArrayElementAtIndex (selectedNodeIndex); EditorGUILayout.PropertyField(nodeProperty.FindPropertyRelative("startTime")); EditorGUILayout.PropertyField(nodeProperty.FindPropertyRelative("duration")); SerializedProperty fromProperty=null; SerializedProperty toProperty=null; if(selectedNode.PropertyType == typeof(float)){ fromProperty = nodeProperty.FindPropertyRelative("fromFloat"); toProperty = nodeProperty.FindPropertyRelative("toFloat"); }else if(selectedNode.PropertyType == typeof(Vector2)){ fromProperty = nodeProperty.FindPropertyRelative("fromVector2"); toProperty = nodeProperty.FindPropertyRelative("toVector2"); }else if(selectedNode.PropertyType == typeof(Vector3)){ fromProperty = nodeProperty.FindPropertyRelative("fromVector3"); toProperty = nodeProperty.FindPropertyRelative("toVector3"); }else if(selectedNode.PropertyType == typeof(Color)){ fromProperty = nodeProperty.FindPropertyRelative("fromColor"); toProperty = nodeProperty.FindPropertyRelative("toColor"); } if(fromProperty != null && toProperty != null){ EditorGUILayout.PropertyField(fromProperty, new GUIContent("From")); EditorGUILayout.PropertyField(toProperty, new GUIContent("To")); } EditorGUILayout.PropertyField(nodeProperty.FindPropertyRelative("ease")); } SerializedProperty eventsArray=sequenceProperty.FindPropertyRelative("events"); if(selectedEventIndex < eventsArray.arraySize){ SerializedProperty eventProperty = eventsArray.GetArrayElementAtIndex (selectedEventIndex); SerializedProperty methodProperty=eventProperty.FindPropertyRelative("method"); //SerializedProperty typeProperty=eventProperty.FindPropertyRelative("type"); SerializedProperty argumentsArray=eventProperty.FindPropertyRelative("arguments"); EventNode eventNode=sequence.events[selectedEventIndex]; if(GUILayout.Button(eventNode.SerializedType.Name+"."+methodProperty.stringValue,"DropDown")){ GenericMenu menu = new GenericMenu (); Component[] components=selectedGameObject.GetComponents<Component>(); List<Type> types = new List<Type> (); types.AddRange (components.Select (x => x.GetType ())); types.AddRange (GetSupportedTypes ()); foreach (Type type in types) { List<MethodInfo> functions= GetValidFunctions(type,!(type.IsSubclassOf(typeof(Component)) || type.IsSubclassOf(typeof(MonoBehaviour))) || selectedGameObject.GetComponent(type)==null); foreach(MethodInfo mi in functions){ if(mi != null){ EventNode node = new EventNode (); node.time = timeline.CurrentTime; node.SerializedType=type; node.method=mi.Name; node.arguments=GetMethodArguments(mi); node.time=eventNode.time; menu.AddItem(new GUIContent(type.Name+"/"+mi.Name),false,delegate() { sequence.events[selectedEventIndex]=node; EditorUtility.SetDirty(tweener); }); } } } menu.ShowAsContext (); } for(int i=0;i<argumentsArray.arraySize;i++){ SerializedProperty argumentProperty=argumentsArray.GetArrayElementAtIndex(i); EditorGUILayout.PropertyField(argumentProperty.FindPropertyRelative(eventNode.arguments[i].GetValueName()),new GUIContent("Parameter")); } } } serializedObject.ApplyModifiedProperties (); }
//public override void Step() //{ // base.Step(); // //triggered = false; //} //public override void Reset() //{ // //Debug.Log(string.Format("Reset EventNode {0} data {1} status ={2} ,triggered ={3}", this.name + (BrainEventEnum)eventType, data, status, triggered)); // triggered = false; // base.Reset(); //} /// <summary> /// clone /// </summary> /// <returns></returns> public IBehaviourNode Clone() { var behaviourNode = new EventNode(this.eventType); base.CopyToCompositeNode(behaviourNode); return behaviourNode; }
IEnumerator HandleEvent(GameObject goTarget) { //Debug.Log("Starting event!"); goTarget.SetActive(true); //We enable the frogs. yield return new WaitForSeconds(5.0f); //We wait for a moment. int layerMask = 1 << 11; // This would cast rays only against colliders in layer 11, the Memory Layer. // But instead we want to collide against everything except layer 11. The ~ operator does this, it inverts a bitmask. layerMask = ~layerMask; //Creating the event within the shared event graph. //1. We create the core event node. //2. We add all the large enemy frogs to the graph, and link them to the event. //3. We add the location of the event to the graph, and link it to the event. //4. We create the sub-event, and add it to the graph. //5. We link the sub-event to the location. //6. We add all the small enemy frogs to the graph, and link them to the sub event. //7. We then generate the personalised memories for all agents in the area. EventNode coreSharedEvent = new EventNode("FrogAttack", new int[] { 3 }, new string[] { "EVN_FrogAttack" }); MemoryGraphNode coreSharedEventNode = EventManager.Instance.SharedEventGraph.AddNamedNodeToGraph(coreSharedEvent); //We populate the shared event graph with info about the event. for (int i = 0; i < tLargeFrogs.Length; i++) { CharacterNode frogNode = new CharacterNode(tLargeFrogs[i].Tag); MemoryGraphNode frogEventNode = EventManager.Instance.SharedEventGraph.AddNamedNodeToGraph(frogNode); EventManager.Instance.SharedEventGraph.AddUndirectedEdge(coreSharedEventNode, frogEventNode, 11.0f); } LocationNode lNode = new LocationNode(Locations.SouthernPinnusula); MemoryGraphNode locationGraphNode = EventManager.Instance.SharedEventGraph.AddNamedNodeToGraph(lNode); EventManager.Instance.SharedEventGraph.AddUndirectedEdge(coreSharedEventNode, locationGraphNode, 11.0f); EventNode coreSharedSubEvent = new EventNode("SmallFrogEvent", new int[] { 17 }, new string[] { "Monsters" }); MemoryGraphNode coreSharedSubEventNode = EventManager.Instance.SharedEventGraph.AddNamedNodeToGraph(coreSharedSubEvent); EventManager.Instance.SharedEventGraph.AddUndirectedEdge(coreSharedEventNode, coreSharedSubEventNode, 11.0f); EventManager.Instance.SharedEventGraph.AddUndirectedEdge(coreSharedSubEventNode, locationGraphNode, 11.0f); for (int i = 0; i < tSmallFrogs.Length; i++) { CharacterNode frogNode = new CharacterNode(tSmallFrogs[i].Tag); MemoryGraphNode frogEventNode = EventManager.Instance.SharedEventGraph.AddNamedNodeToGraph(frogNode); EventManager.Instance.SharedEventGraph.AddUndirectedEdge(coreSharedSubEventNode, frogEventNode, 11.0f); } for (int i = 0; i < AgentManager.Instance.GetAgentCount(); i++) { CharacterDetails charDetails = AgentManager.Instance.GetAgent(i); MemoryGraph charGraph = charDetails.IsPlayer ? charDetails.PlayerAgent.MindsEye.MemoryGraph : charDetails.CognitiveAgent.MindsEye.MemoryGraph; EventNode coreEvent = new EventNode("FrogAttack", null, new string[] { "EVN_FrogAttack" }); MemoryGraphNode coreEventNode = charGraph.AddNamedNodeToGraph(coreEvent); string eventLocation = Locations.SouthernPinnusula.ToString(); bool sawEvent = false; int frogCount = 0; for (int x = 0; x < tLargeFrogs.Length; x++) { RaycastHit hit; Vector3 direction = tLargeFrogs[x].cTransform.position - charDetails.HeadTarget.position; if (Physics.Raycast(charDetails.HeadTarget.position, direction, out hit, Mathf.Infinity, layerMask)) { //Debug.Log(charDetails.CharCue.UniqueNodeID + " - " + hit.transform.name); EventTag eTag = hit.transform.GetComponent<EventTag>(); if (eTag != null && eTag.Tag == tLargeFrogs[x].Tag) ++frogCount; } } MemoryGraphNode largeFrogNode = null; if (frogCount > 0) { sawEvent = true; //Create Large Frogs sub-event! EventNode largeFrogEvent = new EventNode("LargeFrogEvent", new int[] { frogCount }, new string[] { "Monsters" }); largeFrogNode = charGraph.AddNamedNodeToGraph(largeFrogEvent); charGraph.AddUndirectedEdge(coreEventNode, largeFrogNode, 11.0f, 1.0f); //Creates a strong connection between the core event and the optional sub-event. } //Debug.Log(charDetails.name + " - I saw " + frogCount + " huge frogs!"); frogCount = 0; for (int x = 0; x < tSmallFrogs.Length; x++) { RaycastHit hit; Vector3 direction = tSmallFrogs[x].cTransform.position - charDetails.HeadTarget.position; if (Physics.Raycast(charDetails.HeadTarget.position, direction, out hit, direction.magnitude, layerMask)) { //Debug.Log(charDetails.CharCue.UniqueNodeID + " - " + hit.transform.name); EventTag eTag = hit.transform.GetComponent<EventTag>(); //if(eTag != null) //Debug.Log(charDetails.CharCue.UniqueNodeID + " : " + eTag.Tag); if (eTag != null && eTag.Tag == tSmallFrogs[x].Tag) ++frogCount; } } MemoryGraphNode smallFrogNode = null; if (frogCount > 0) { sawEvent = true; //Create small frogs sub-event! EventNode smallFrogEvent = new EventNode("SmallFrogEvent", new int[] { frogCount }, new string[] { "Monsters" }); smallFrogNode = charGraph.AddNamedNodeToGraph(smallFrogEvent); charGraph.AddUndirectedEdge(coreEventNode, smallFrogNode, 11.0f, 1.0f); //Creates a strong connection between the core event and the optional sub-event. } if (sawEvent) { MemoryGraphNode retainedMemory; if (charGraph.Contains(eventLocation) == false) retainedMemory = charGraph.AddNamedNodeToGraph(new LocationNode(Locations.SouthernPinnusula)); //This is a new memory! Add it to our memory graph. else retainedMemory = charGraph.GetNamedNodeFromGraph(eventLocation); charGraph.UpdateCueOpinion(retainedMemory.MemoryNode, -5.0f); //The agent will have a strong negative opinion about the area where they attack. charGraph.AddUndirectedEdge(coreEventNode, retainedMemory, 11.0f, 1.0f); //They will also make a strong connection between the area and the frogs. if (largeFrogNode != null) charGraph.AddDirectedEdge(largeFrogNode, retainedMemory, 11.0f, 1.0f); //Creates a strong (but one-way, since we already connect the core event) connection to the location. if (smallFrogNode != null) charGraph.AddDirectedEdge(smallFrogNode, retainedMemory, 11.0f, 1.0f); //Creates a strong (but one-way, since we already connect the core event) connection to the location. } } //We broadcast the Frog Sight Event and create the Shared Events and personalised Sub Events. //We also broadcast the start of the event (so people flee). yield return new WaitForSeconds(5.0f); //We broadcast the end of the event, and hide the frogs again. goTarget.SetActive(false); //Debug.Log("Ending event!"); //EventManager.Instance.SharedEventGraph.PrintGraph(); }
/// <summary> /// 卸载一个消息节点 /// </summary> /// <param name="node">消息节点</param> /// <returns>如果节点不存在那么返回false</returns> public bool DetachEventNode(EventNode node) { if (!mNodeList.Contains(node)) return false; mNodeList.Remove(node); return true; }
/// <summary> /// This is used to peek at the node from the document. This will /// scan through the document, ignoring any comments to find the /// next relevant XML event to acquire. Typically events will be /// the start and end of an element, as well as any text nodes. /// </summary> /// <returns> /// This returns the next event taken from the document. /// </returns> public virtual EventNode Peek() { if(peek == null) { peek = Next(); } return peek; }
private void ActivateCurveConfigPanel(EventNode eventNode) { this.MakeVisible(curveConfigBox); this.suspendPreview = true; this.lineTypeComboBox.Enabled = false; this.lineTypeComboBox.Parent = curveConfigBox; this.thicknessComboBox.Parent = curveConfigBox; this.lineColorPanel.Parent = curveConfigBox; if (eventNode.SupportVisibility) { this.visibleCheckBox.Parent = curveConfigBox; this.visibleCheckBox.Visible = true; this.visibleCheckBox.Checked = eventNode.Visible; } else { this.visibleCheckBox.Visible = false; } this.lineTypeComboBox.SelectedItem = eventNode.CurvePen.DashStyle.ToString(); this.thicknessComboBox.SelectedItem = (int)eventNode.CurvePen.Width; this.lineColorPanel.BackColor = eventNode.CurvePen.Color; this.curvePreviewLabel.Parent = this.curveConfigBox; this.previewPanel.Parent = this.curveConfigBox; this.suspendPreview = false; this.previewPanel.Refresh(); }
/// <summary> /// This is used to take the next node from the document. This will /// scan through the document, ignoring any comments to find the /// next relevant XML event to acquire. Typically events will be /// the start and end of an element, as well as any text nodes. /// </summary> /// <returns> /// This returns the next event taken from the source XML. /// </returns> public virtual EventNode Next() { EventNode next = peek; if(next == null) { next = Read(); } else { peek = null; } return next; }
/// <summary> /// Constructor for the <c>InputPosition</c> object. This is /// used to create a position description if the provided event /// is not null. This will return -1 if the specified event does /// not provide any location information. /// </summary> /// <param name="source"> /// this is the XML event to get the position of /// </param> public InputPosition(EventNode source) { this.source = source; }
internal LinkedEventList() { m_HeadNode = null; m_TailNode = null; m_Count = 0; }
private void OnAddEvent(){ AddTweener (Selection.activeGameObject); if (sequence == null) { AddSequence (tweener); } if (sequence.events == null) { sequence.events= new List<EventNode>(); } GenericMenu menu = new GenericMenu (); //Component[] components=selectedGameObject.GetComponents<Component>(); List<Type> types = new List<Type> (); //types.AddRange (components.Select (x => x.GetType ())); types.AddRange (GetSupportedTypes ()); foreach (Type type in types) { List<MethodInfo> functions= GetValidFunctions(type,!(type.IsSubclassOf(typeof(Component)) || type.IsSubclassOf(typeof(MonoBehaviour))) || selectedGameObject.GetComponent(type)==null); foreach(MethodInfo mi in functions){ if(mi != null){ EventNode node = new EventNode (); node.time = timeline.CurrentTime; node.SerializedType=type; node.method=mi.Name; node.arguments=GetMethodArguments(mi); menu.AddItem(new GUIContent(type.Name+"/"+mi.Name),false,AddEvent,node); } } } menu.ShowAsContext (); }
internal void InsertNewTail(IQEvent qEvent) { if (m_Count == 0) { // We create the first node in the linked list m_HeadNode = m_TailNode = new EventNode(qEvent, null); } else { EventNode newTail = new EventNode(qEvent, null); m_TailNode.NextNode = newTail; m_TailNode = newTail; } m_Count++; }
/// <summary> /// This is used to convert the start element to an input node. /// This will push the created input node on to the stack. The /// input node created contains a reference to this reader. so /// that it can be used to read child elements and values. /// </summary> /// <param name="from"> /// This is the parent element for the start event. /// </param> /// <param name="event"> /// This is the start element to be wrapped. /// </param> /// <returns> /// This returns an input node for the given element. /// </returns> public InputNode ReadStart(InputNode from, EventNode node) { InputElement input = new InputElement(from, this, node); if(node.IsStart()) { return stack.Push(input); } return input; }
/// <summary> /// This is used to determine the name of the node specified. The /// name of the node is determined to be the name of the element /// if that element is converts to a valid StAX start element. /// </summary> /// <param name="node"> /// This is the StAX node to acquire the name from. /// </param> /// <param name="name"> /// This is the name of the node to check against. /// </param> /// <returns> /// True if the specified node has the given local name. /// </returns> public bool IsName(EventNode node, String name) { String local = node.Name; if(local == null) { return false; } return local.Equals(name); }