Esempio n. 1
0
                public RemoveSliceCommand(SliceList list, int index)
                {
                    this.mNode          = list.mNode;
                    this.mSliceList     = list.mSlices;
                    this.mIndex         = index;
                    this.mAP            = list.mNode.mSliceAnchors[index];
                    this.mSlice         = list.mSlices[index];
                    this.mSelectedEdges = new List <DGEdge>();
                    this.mActions       = new IEdgeAction[this.mAP.Edges.Count];
                    this.mCount         = 0;
                    DGNode      node;
                    IEdgeAction action;

                    foreach (DGEdge edge in this.mAP.Edges)
                    {
                        if (edge.Selected)
                        {
                            this.mSelectedEdges.Add(edge);
                        }
                        node = edge.DstNode;
                        if (node == this.mNode)
                        {
                            node = edge.SrcNode;
                        }
                        action = node.RemoveEdge(edge);
                        if (action != null)
                        {
                            this.mActions[this.mCount++] = action;
                        }
                    }
                    this.mLabel = "Remove Slice from Random Node";
                }
Esempio n. 2
0
                public ClearSlicesCommand(SliceList list)
                {
                    this.mNode      = list.mNode;
                    this.mSliceList = list.mSlices;
                    this.mAPs       = new AnchorPoint[list.mNode.mSliceCount];
                    Array.Copy(list.mNode.mSliceAnchors, 0, this.mAPs, 0,
                               list.mNode.mSliceCount);
                    this.mSlices        = list.mSlices.ToArray();
                    this.mSelectedEdges = new List <DGEdge>();
                    this.mActions       = new List <IEdgeAction>();
                    DGNode      node;
                    IEdgeAction action;

                    for (int i = this.mAPs.Length - 1; i >= 0; i--)
                    {
                        foreach (DGEdge edge in this.mAPs[i].Edges)
                        {
                            if (edge.Selected)
                            {
                                this.mSelectedEdges.Add(edge);
                            }
                            node = edge.DstNode;
                            if (node == this.mNode)
                            {
                                node = edge.SrcNode;
                            }
                            action = node.RemoveEdge(edge);
                            if (action != null)
                            {
                                this.mActions.Add(action);
                            }
                        }
                    }
                    this.mLabel = "Clear Slices from Random Node";
                }
Esempio n. 3
0
 public SliceTargetAction(bool add, DGEdge edge,
                          int sliceIndex, int targetIndex, DGRandNode node)
 {
     this.bAdd         = add;
     this.mEdge        = edge;
     this.mSliceIndex  = sliceIndex;
     this.mTargetIndex = targetIndex;
     this.mNode        = node;
 }
Esempio n. 4
0
 public SliceList(DGRandNode node)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     this.mNode   = node;
     this.mSlices = node.mRandomNode.Slices;
 }
Esempio n. 5
0
        private DGNode InitDGN(DGNode src, DecisionGraphNode dgn)
        {
            int    i;
            DGNode dst = null;

            for (i = this.mDGraph.NodeCount - 1; i >= 0; i--)
            {
                dst = this.mDGraph.NodeAt(i);
                if (dst.DGN == dgn)
                {
                    break;
                }
            }
            if (i < 0)
            {
                int                 j;
                DGEdge              edge;
                AnchorPoint         ap;
                DecisionGraphNode[] dgns;
                DGMulticastNode     dgmcn = null;
                switch (dgn.ChunkType)
                {
                case NextStateNode.ResourceType:
                    NextStateNode nsn = dgn as NextStateNode;
                    dst = new DGSnSnNode(nsn, this);
                    this.mDGraph.AddNode(dst);
                    dst.SetParent(this);
                    break;

                case RandomNode.ResourceType:
                    RandomNode rand = dgn as RandomNode;
                    DGRandNode dgrn = new DGRandNode(rand, this);
                    this.mDGraph.AddNode(dgrn);
                    dgrn.SetParent(this);
                    List <RandomNode.Slice> slices = rand.Slices;
                    if (slices.Count > 0)
                    {
                        for (i = 0; i < slices.Count; i++)
                        {
                            ap   = dgrn.GetSliceAnchor(i);
                            dgns = slices[i].Targets.ToArray();
                            for (j = 0; j < dgns.Length; j++)
                            {
                                dst  = this.InitDGN(dgrn, dgns[j]);
                                edge = new DGEdge(dgrn, dst, false);
                                ap.Edges.Add(edge);
                                dst.EntryAnchor.Edges.Add(edge);
                                this.mDGraph.AddEdge(edge);
                                edge.SetParent(this);
                            }
                        }
                    }
                    dst = dgrn;
                    break;

                case SelectOnDestinationNode.ResourceType:
                    SelectOnDestinationNode sodn
                        = dgn as SelectOnDestinationNode;
                    DGSoDnNode dgsodn
                        = new DGSoDnNode(sodn, this);
                    this.mDGraph.AddNode(dgsodn);
                    dgsodn.SetParent(this);
                    if (sodn.CaseCount > 0)
                    {
                        SelectOnDestinationNode.Case[] cases = sodn.Cases;
                        for (i = 0; i < cases.Length; i++)
                        {
                            ap   = dgsodn.GetCaseAnchorAt(i);
                            dgns = cases[i].Targets;
                            for (j = 0; j < dgns.Length; j++)
                            {
                                dst  = this.InitDGN(dgsodn, dgns[j]);
                                edge = new DGEdge(dgsodn, dst, false);
                                ap.Edges.Add(edge);
                                dst.EntryAnchor.Edges.Add(edge);
                                this.mDGraph.AddEdge(edge);
                                edge.SetParent(this);
                            }
                        }
                    }
                    dst = dgsodn;
                    break;

                case SelectOnParameterNode.ResourceType:
                    SelectOnParameterNode sopn
                        = dgn as SelectOnParameterNode;
                    DGSoPnNode dgsopn
                        = new DGSoPnNode(sopn, this);
                    this.mDGraph.AddNode(dgsopn);
                    dgsopn.SetParent(this);
                    if (sopn.CaseCount > 0)
                    {
                        SelectOnParameterNode.Case[] cases = sopn.Cases;
                        for (i = 0; i < cases.Length; i++)
                        {
                            ap   = dgsopn.GetCaseAnchorAt(i);
                            dgns = cases[i].Targets;
                            for (j = 0; j < dgns.Length; j++)
                            {
                                dst  = this.InitDGN(dgsopn, dgns[j]);
                                edge = new DGEdge(dgsopn, dst, false);
                                ap.Edges.Add(edge);
                                dst.EntryAnchor.Edges.Add(edge);
                                this.mDGraph.AddEdge(edge);
                                edge.SetParent(this);
                            }
                        }
                    }
                    dst = dgsopn;
                    break;

                case CreatePropNode.ResourceType:
                    CreatePropNode cpn   = dgn as CreatePropNode;
                    DGPropNode     dgcpn = new DGPropNode(cpn, this);
                    this.mDGraph.AddNode(dgcpn);
                    dgcpn.SetParent(this);
                    dgmcn = dgcpn;
                    break;

                case ActorOperationNode.ResourceType:
                    ActorOperationNode aon   = dgn as ActorOperationNode;
                    DGAcOpNode         dgaon = new DGAcOpNode(aon, this);
                    this.mDGraph.AddNode(dgaon);
                    dgaon.SetParent(this);
                    dgmcn = dgaon;
                    break;

                case StopAnimationNode.ResourceType:
                    StopAnimationNode san   = dgn as StopAnimationNode;
                    DGStopNode        dgsan = new DGStopNode(san, this);
                    this.mDGraph.AddNode(dgsan);
                    dgsan.SetParent(this);
                    dgmcn = dgsan;
                    break;

                case PlayAnimationNode.ResourceType:
                    PlayAnimationNode pan   = dgn as PlayAnimationNode;
                    DGPlayNode        dgpan = new DGPlayNode(pan, this);
                    this.mDGraph.AddNode(dgpan);
                    dgpan.SetParent(this);
                    dgmcn = dgpan;
                    break;
                }
                if (dgmcn != null)
                {
                    MulticastDecisionGraphNode mcn
                        = dgn as MulticastDecisionGraphNode;
                    if (mcn.TargetCount > 0)
                    {
                        ap   = dgmcn.TargetAnchor;
                        dgns = mcn.Targets;
                        for (i = 0; i < dgns.Length; i++)
                        {
                            dst  = this.InitDGN(dgmcn, dgns[i]);
                            edge = new DGEdge(dgmcn, dst, false);
                            ap.Edges.Add(edge);
                            dst.EntryAnchor.Edges.Add(edge);
                            this.mDGraph.AddEdge(edge);
                            edge.SetParent(this);
                        }
                    }
                    dst = dgmcn;
                }
            }
            return(dst);
        }