private void DrawGraph(RuntimeStateGraph graph)
        {
            DrawConnections(graph);
            DrawNodes(graph);
            GUI.EndScrollView();

            ProcessEvents(Event.current);
            var sideRect = new Rect(position.width - Border, 0, Border - 10, position.height);

            _scrollPosition1 = GUI.BeginScrollView(sideRect, _scrollPosition1, new Rect(0, 0, Border, MaxRectSize));
            EditorGUILayout.LabelField("IsActive " + graph.IsActive);
            EditorGUILayout.LabelField("Current " + graph.Current != null ? graph.Current.Node.name : "null");
            EditorGUILayout.LabelField(" ");
            EditorGUILayout.LabelField("-Variables-");
            foreach (var valueVariable in graph.Variables)
            {
                EditorGUILayout.LabelField(valueVariable.Key + ": ");
                EditorGUILayout.LabelField(valueVariable.Value.ToString());
            }
            EditorGUILayout.LabelField(" ");
            EditorGUILayout.LabelField("-Triggers-");
            foreach (string trigger in graph.TriggerLog.InOrder())
            {
                EditorGUILayout.LabelField(graph.TriggerLog.GetTime(trigger).ToString("F3") + ": ");
                EditorGUILayout.LabelField(trigger);
            }
            GUI.EndScrollView();
            Repaint();
        }
 private void DrawConnections(RuntimeStateGraph graph)
 {
     for (int i = 0; i < graph.OriginalGraph.Count; i++)
     {
         var node = graph.OriginalGraph[i];
         for (int c = 0; c < node.OutPoints.Count; c++)
         {
             var connectOut = node.OutPoints[c];
             if (connectOut.Target == null)
             {
                 continue;
             }
             var connectIn = connectOut.Target.GetConnectionInPointById(connectOut.TargetId);
             Handles.DrawBezier(
                 connectIn.Rect.center,
                 connectOut.Rect.center,
                 connectIn.Rect.center + Vector2.left * 50f,
                 connectOut.Rect.center - Vector2.left * 50f,
                 Color.white,
                 null,
                 2f
                 );
         }
     }
 }
예제 #3
0
 public RuntimeNode(EventNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _originalNode = node;
     if (_originalNode.Loop)
     {
         _loopCondition = _originalNode.LoopCondition.GetRuntime();
     }
 }
예제 #4
0
 public RuntimeStateGraph(RuntimeStateGraph parent, StateGraph graph, Entity entity)
 {
     GlobalTriggers = parent.GlobalTriggers;
     Variables      = parent.Variables;
     OriginalGraph  = graph;
     ParentGraph    = parent;
     Entity         = entity;
     SetupGraph();
 }
예제 #5
0
 public RuntimeNode(SwitchExternalNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _originalNode   = node;
     _externalGraphs = new RuntimeStateGraph[node.Graphs.Length];
     for (int i = 0; i < _externalGraphs.Length; i++)
     {
         _externalGraphs[i]             = node.Graphs[i].GetRuntimeGraph(graph, graph.Entity);
         _externalGraphs[i].OnComplete += ExternalGraphCompleted;
     }
 }
예제 #6
0
 public override RuntimeStateNode GetRuntimeNode(RuntimeStateGraph graph)
 {
     if (InstancedIndex >= 0)
     {
         return(new InstancedRuntimeAnimationNode(this, graph));
     }
     if (Animation.IsDirectional)
     {
         return(new DirectionalRuntimeAnimationNode(this, graph));
     }
     return(new RuntimeSpriteAnimationNode(this, graph));
 }
예제 #7
0
 public RuntimeNode(SetSpriteNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _spriteNode = node;
     if (_spriteNode.InstancedIndex >= 0)
     {
         _simpleRenderer = Graph.Entity.Get <SpriteSimpleRendererComponent>();
     }
     else
     {
         _spriteRenderer = Graph.Entity.Get <SpriteRendererComponent>();
     }
 }
예제 #8
0
 protected RuntimeStateNode(StateGraphNode node, RuntimeStateGraph graph)
 {
     Node  = node;
     Graph = graph;
     for (int i = 0; i < Node.Conditions.Count; i++)
     {
         var runtime = node.Conditions[i].GetRuntime();
         if (runtime != null)
         {
             Conditions.Add(runtime);
         }
     }
 }
        private void DrawNodes(RuntimeStateGraph graph)
        {
            if (graph == null)
            {
                return;
            }
            var currentNode = graph.Current?.Node;

            for (int i = 0; i < graph.OriginalGraph.Count; i++)
            {
                var node     = graph.OriginalGraph.Nodes[i];
                var maxWidth = node.Rect.x * 0.8f;
                var style    = node == currentNode ? _nodeSelectedStyle : _nodeStyle;
                GUILayout.BeginArea(node.Rect, style);
                GUILayout.Space(10);
                GUILayout.Label(node.Title, _nodeTextStyle, GUILayout.MaxWidth(maxWidth));
                GUILayout.Label("ID: " + node.Id, _nodeTextStyle, GUILayout.MaxWidth(maxWidth));
                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                GUILayout.Label("Enter");
                EditorGUILayout.LabelField(node.EnterEvent);
                GUILayout.Label("Exit");
                EditorGUILayout.LabelField(node.ExitEvent);
                GUILayout.Space(20);
                GUILayout.EndHorizontal();
                GUILayout.Label(graph.GetRuntimeNode(node.Id).DebugInfo);
                GUILayout.EndArea();
                var inSpacing = Mathf.Clamp(0.8f / node.InPoints.Count, 0.02f, 1);
                for (int c = 0; c < node.InPoints.Count; c++)
                {
                    if (node.InPoints[c] == null)
                    {
                        node.InPoints.RemoveAt(c);
                        break;
                    }
                    StateGraphExtensions.DrawConnectionPoint(node.InPoints[c], c, inSpacing, null, null);
                }
                var outSpacing = Mathf.Clamp(0.8f / node.OutPoints.Count, 0.02f, 1);
                for (int c = 0; c < node.OutPoints.Count; c++)
                {
                    if (node.OutPoints[c] == null)
                    {
                        node.OutPoints.RemoveAt(c);
                        break;
                    }
                    StateGraphExtensions.DrawConnectionPoint(node.OutPoints[c], c, outSpacing, null, null);
                }
            }
        }
 public AnimationGraphComponent(RuntimeStateGraph value)
 {
     Value = value;
 }
예제 #11
0
 public RuntimeConditionNode(ConditionNode node, RuntimeStateGraph graph) : base(node, graph)
 {
 }
예제 #12
0
 public InstancedRuntimeAnimationNode(SpriteAnimationNode node, RuntimeStateGraph graph) : base
         (node, graph)
 {
     _simpleRenderer = graph.Entity.Get <SpriteSimpleRendererComponent>();
 }
예제 #13
0
 public override RuntimeStateNode GetRuntimeNode(RuntimeStateGraph graph)
 {
     return(new GlobalConditionRuntimeNode(this, graph));
 }
예제 #14
0
 public RuntimeNode(WeaponBobNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _node      = node;
     _component = graph.Entity.Get <WeaponBobComponent>();
 }
예제 #15
0
 public abstract RuntimeStateNode GetRuntimeNode(RuntimeStateGraph graph);
예제 #16
0
 public RuntimeNode(ReloadStateNode node, RuntimeStateGraph graph) : base(node, graph)
 {
 }
예제 #17
0
 public RuntimeNode(MoveFpPivotNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _node = node;
 }
예제 #18
0
 public RuntimeSpriteAnimationNode(SpriteAnimationNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _animNode = node;
 }
예제 #19
0
 public DirectionalRuntimeAnimationNode(SpriteAnimationNode node, RuntimeStateGraph graph) : base
         (node, graph)
 {
     _billboard = graph.Entity.Get <SpriteBillboardComponent>();
 }
예제 #20
0
 public RuntimeSpriteAnimationNode(SpriteAnimationNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     AnimNode = node;
     Renderer = graph.Entity.Get <SpriteRendererComponent>();
     Animator = graph.Entity.Get <SpriteAnimatorComponent>();
 }
예제 #21
0
//
//        public StateGraphNode GetConnectionEndpoint(ConnectionPoint point) {
//            for (int i = 0; i < Connections.Count; i++) {
//                if (Connections[i].GetIn().Id == point.Id) {
//                    return Connections[i].OutNode;
//                }
//            }
//            return null;
//        }
//
//        public void FillConnectionList(StateGraphNode node, List<Connection> connectList) {
//            for (int i = 0; i < Connections.Count; i++) {
//                if (Connections[i].InNode == node || Connections[i].OutNode == node) {
//                    connectList.Add(Connections[i]);
//                }
//            }
//        }

        public RuntimeStateGraph GetRuntimeGraph(Entity entity)
        {
            var runtime = new RuntimeStateGraph(this, entity);

            return(runtime);
        }
예제 #22
0
 public override RuntimeStateNode GetRuntimeNode(RuntimeStateGraph graph)
 {
     return(new RuntimeNode(this, graph));
 }
예제 #23
0
        public RuntimeStateGraph GetRuntimeGraph(RuntimeStateGraph parent, Entity entity)
        {
            var runtime = new RuntimeStateGraph(parent, this, entity);

            return(runtime);
        }
예제 #24
0
 public RuntimeNode(BlockDamageNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _originalNode = node;
 }
예제 #25
0
 public RuntimeSequenceNode(SequenceNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _sequence = node.Sequence.GetRuntimeSequence(graph.Entity);
 }
예제 #26
0
 public RuntimeNode(CompletedGraphNode node, RuntimeStateGraph graph) : base(node, graph)
 {
 }
예제 #27
0
 public RuntimeNode(MusclePoseNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _originalNode = node;
 }
예제 #28
0
 public RuntimeNode(ChangeEquipmentNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _changeNode = node;
 }
예제 #29
0
 public GlobalConditionRuntimeNode(GlobalConditionNode node, RuntimeStateGraph graph) : base(node, graph)
 {
 }
예제 #30
0
 public RuntimeNode(WaitChargeNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _originalNode = node;
 }