Esempio n. 1
0
        EventGraphWindowItem NewItem(INodedEvent theEvent)
        {
            EventGraphWindowItem newItem = new EventGraphWindowItem(theEvent, RemoveItem, this);

            items.Add(newItem);
            return(newItem);
        }
        public void DrawLinks()
        {
            Handles.BeginGUI();

            for (int i = 0; i < moments.Count; i++)
            {
                BaseMoment moment = moments[i].moment;
                for (int u = 0; u < moment.iEvents.Count; u++)
                {
                    UnityEngine.Object otherNode = moment.iEvents[u];
                    if (otherNode is INodedEvent)
                    {
                        INodedEvent otherDisplay = otherNode as INodedEvent;
                        Rect        targetRect   = otherDisplay.WindowRect;
                        DrawBezierRight(WindowRect.position + moments[i].lastDrawnPos,
                                        new Vector2(targetRect.xMin, targetRect.y + 28));
                    }
                    else
                    {
                        Debug.LogWarning("Le moment apparenant a: " + NodeLabel + " a un lien vers un IEvent qui n'est pas IEventDisplay."
                                         + " Destruction du lien.");
                        moment.RemoveNulls();
                        break;
                    }
                }
            }

            Handles.EndGUI();
        }
Esempio n. 3
0
        private void RemoveAllLinksTo(IBaseEvent theEvent, Object on)
        {
            FieldInfo[] fields = on.GetType().GetFields();

            for (int i = 0; i < fields.Length; i++)
            {
                if (fields[i].FieldType.IsSubclassOf(typeof(BaseMoment)))
                {
                    BaseMoment moment = fields[i].GetValue(on) as BaseMoment;
                    moment.RemoveIEvent(theEvent.AsObject());
                }
            }


            if (on is INodedEvent)
            {
                INodedEvent onDisplay = on as INodedEvent;

                BaseMoment[] additionalMoments;
                string[]     additionalNames;
                onDisplay.GetAdditionalMoments(out additionalMoments, out additionalNames);

                if (additionalMoments != null)
                {
                    for (int i = 0; i < additionalMoments.Length; i++)
                    {
                        additionalMoments[i].RemoveIEvent(theEvent.AsObject());
                    }
                }
            }
        }
Esempio n. 4
0
 void ClearItems(bool repaint = true)
 {
     ongoingLink.source = null;
     items         = null;
     lastHilighted = null;
     copyNode      = null;
     Repaint();
 }
Esempio n. 5
0
 void Copy()
 {
     if (lastHilighted == null)
     {
         Debug.Log("Cannot copy. No selected node.");
     }
     else
     {
         copyNode = lastHilighted.myEvent;
     }
 }
Esempio n. 6
0
        public INodedEvent AddEvent(INodedEvent existingEvent)
        {
            events.Add(existingEvent.AsObject());
            existingEvent.Graph = this;

            if (onEventsAddedOrRemoved != null)
            {
                onEventsAddedOrRemoved();
            }
            return(existingEvent);
        }
Esempio n. 7
0
        void NewVirtualEvent(INodedEvent newEvent, string name)
        {
            newEvent.name = name;
            newEvent.MoveToPos(contextMenuMousePos);

            if (ongoingLink.source != null)
            {
                ongoingLink.BuildLink(newEvent.AsObject());
            }

            newEvent.LinkToGraph();

            MarkSceneAsDirty();
        }
        public EventGraphWindowItem(INodedEvent myEvent, Action <EventGraphWindowItem> removeRequest, EventGraphWindow window)
        {
            this.myEvent = myEvent;
            if (myEvent == null)
            {
                throw new Exception("my event == null");
            }

            this.removeRequest = removeRequest;
            this.parentWindow  = window;

            BuildEntryTypes();
            BuildNamedMoments();
        }
Esempio n. 9
0
        public void RemoveEvent(INodedEvent theEvent)
        {
            if (theEvent is IBaseEvent)
            {
                RemoveAllLinksTo(theEvent as IBaseEvent);
            }

            if (events.Remove(theEvent.AsObject()))
            {
                if (onEventsAddedOrRemoved != null)
                {
                    onEventsAddedOrRemoved();
                }
            }
        }
Esempio n. 10
0
        void Paste()
        {
            if (copyNode == null || copyNode.AsObject() == null)
            {
                Debug.Log("Cannot paste. No copied node.");
            }
            else
            {
                INodedEvent newEvent = Instantiate(copyNode.AsObject()) as INodedEvent;

                newEvent.LinkToGraph();
                newEvent.MoveToPos(copyNode.WindowRect.position + Vector2.one * 75);

                MarkSceneAsDirty();
            }
        }
Esempio n. 11
0
        void NewVirtualEvent(Type type, string name)
        {
            INodedEvent newEvent = ScriptableObject.CreateInstance(type) as INodedEvent;

            NewVirtualEvent(newEvent, name);
        }
Esempio n. 12
0
 public bool ContainsEvent(INodedEvent existingEvent)
 {
     return(events.Contains(existingEvent.AsObject()));
 }