void Awake()
 {
     isGamePaused   = false;
     nodeGroup      = gameObject.GetComponent <NodeGroup>();
     nodeConnection = gameObject.GetComponent <NodeConnections>();
     joystick.GetComponentInParent <Canvas>().enabled = false;
 }
Beispiel #2
0
        public FrmMain()
        {
            InitializeComponent();

            graph1.ShowDebugInfos = true;
            graph1.ShowGrid       = false;
            graph1.TimedRedraw    = true;

            Random rnd = new Random();

            int nodeY = 20;

            for (int i = 0; i < 5; i++)
            {
                nodeY += 20;
                Node node = new Node(graph1)
                {
                    Location = new FlowGraph.GraphLocation(0, nodeY), Title = "Test"
                };
                node.Add(new LabelItem()
                {
                    Size = new FlowGraph.GraphSize(node.Size.Width, 30)
                });
                graph1.AddElement(node);
            }

            NodeGroup group = new NodeGroup(graph1);

            group.Location = new FlowGraph.GraphLocation(0, 0);
            group.Size     = new FlowGraph.GraphSize(1000, 700);

            graph1.AddElement(group);
        }
Beispiel #3
0
        public NodeGroup LoadNodeGroupByJson(string path)
        {
            string content = "";

#if UNITY_EDITOR
            if (File.Exists(path))
            {
                content = File.ReadAllText(path);
            }
#else
            content = xc.DBManager.Instance.LoadDBFile(path.Replace("Assets/Res/", ""));
#endif
            if (string.IsNullOrEmpty(content) == true)
            {
                return(null);
            }
            NodeGroup             temp   = null;
            FullSerializer.fsData fsdata = FullSerializer.fsJsonParser.Parse(content);
            var serializer = new FullSerializer.fsSerializer();
            var processor  = new FileSerializerProcessor();
            serializer.AddProcessor(processor);
            serializer.TryDeserialize(fsdata, ref temp);
            if (temp != null)
            {
                RemoveNodeGroup(temp.Id);
                InitNodeGroup(temp);
                nodeGroups.Add(temp.Id, temp);
                return(temp);
            }
            return(null);
        }
Beispiel #4
0
 public NodeGroupDate(NodeGroup value)
 {
     position   = value.transform.position;
     groupColor = value.GroupColor;
     speed      = value.Speed;
     Nodes      = value.Nodes.Select(n => new NodeDate(n)).ToList();
 }
Beispiel #5
0
 public NodeGroup Update(NodeGroup ng)
 {
     using (dbc = DAL.Instance.GetDb()){
         dbc.Update(ng);
         return(ng);
     }
 }
Beispiel #6
0
        public void TestNodeGroup()
        {
            NodeGroup group = null;
            Function  n     = null;

            try
            {
                group = NodeGroup.EnterNewGroup("test");

                n = CNTKLib.InputVariable(new int[] { 2 }, DataType.Float);
                NodeGroup.Current.Add(n);

                n = CNTKLib.ReLU(n);
                NodeGroup.Current.Add(n);
            }
            finally
            {
                NodeGroup.LeaveGroup();
            }

            var g = NodeGroup.Groups.ToArray();

            Assert.AreEqual(1, g.Length);
            Assert.AreEqual(group, g[0]);

            var nodes = g[0].Nodes.ToArray();

            Assert.AreEqual(2, nodes.Length);
            Assert.AreEqual(n.Inputs[0].Uid, nodes[0].Uid);
            Assert.AreEqual(n.RootFunction.Uid, nodes[1].Uid);

            var f = NodeGroup.FindGroup(n.RootFunction.Uid);

            Assert.AreEqual("test", f.Name);
        }
Beispiel #7
0
        /// <summary>
        /// Build a one direction recurrent neural network (RNN) with long-short-term-memory (LSTM) cells.
        /// http://colah.github.io/posts/2015-08-Understanding-LSTMs/
        /// </summary>
        /// <param name="input">the input variable</param>
        /// <param name="LSTMDim">LSTM output dimension</param>
        /// <param name="cellDim">cell dimension</param>
        /// <param name="returnSequences">whether to return the last output in the output sequence, or the full sequence</param>
        /// <param name="device">CPU or GPU device to run the model</param>
        /// <param name="outputName">name of the model output</param>
        /// <returns>the RNN model</returns>
        public static Function Create(Variable input, int LSTMDim, int cellDim, bool returnSequences, bool stabilize,
                                      DeviceDescriptor device, string outputName)
        {
            try
            {
                NodeGroup.EnterNewGroup(outputName);

                Func <Variable, Function> pastValueRecurrenceHook = (x) => CNTKLib.PastValue(x);
                Function LSTMFunction = LSTMPComponentWithSelfStabilization <float>(
                    input,
                    new int[] { LSTMDim },
                    new int[] { cellDim },
                    pastValueRecurrenceHook,
                    pastValueRecurrenceHook,
                    stabilize,
                    device,
                    outputName).Item1;
                Composite.Register(LSTMFunction);

                if (!returnSequences)
                {
                    var f = CNTKLib.SequenceLast(LSTMFunction);
                    f.RootFunction.SetName(outputName);
                    return(f);
                }

                LSTMFunction.RootFunction.SetName(outputName);

                return(LSTMFunction);
            }
            finally
            {
                NodeGroup.LeaveGroup();
            }
        }
Beispiel #8
0
        public static NodeGroup GetGroups(PluginRoot Plugin, CodeString Code, char BracketLeft = '{', char BracketRight = '}')
        {
            var Ret   = new NodeGroup(Code);
            var State = Plugin.State;

            var List = RecognizerHelper.SplitToParameters(State, Code, ',');

            if (List == null)
            {
                return(null);
            }

            for (var i = 0; i < List.Length; i++)
            {
                var Param = List[i];
                if (Param.Length > 1 && Param[0] == BracketLeft && Param[Param.Length] == BracketLeft)
                {
                    Param = Param.Substring(1, Param.Length - 1).Trim();
                    Ret.Children.Add(Expressions.GetGroups(Plugin, Param));
                }
                else
                {
                    var Node = Expressions.Recognize(Param, Plugin);
                    if (Node == null)
                    {
                        return(null);
                    }

                    Ret.Children.Add(Node);
                }
            }

            return(Ret);
        }
Beispiel #9
0
        public override void OnHeaderGUI()
        {
            NodeGroup node = (NodeGroup)target;


            string title = target.name;

            GUILayout.Label(title, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30), GUILayout.MinWidth(0), GUILayout.ExpandWidth(true));

            Rect labelRect = GUILayoutUtility.GetLastRect();

            node.locked = EditorGUI.ToggleLeft(labelRect, lockIcon, node.locked);

            labelRect       = GUILayoutUtility.GetLastRect();
            labelRect.width = 30;

            if (Event.current.type == EventType.MouseUp)
            {
                if (labelRect.Contains(Event.current.mousePosition))
                {
                    node.locked = !node.locked;
                }
            }

            //  base.OnHeaderGUI();
        }
        /*******************************************/

        private static void CollectNodeGroups(NodeGroup group, ref Dictionary <Guid, List <NodeGroup> > result)
        {
            if (group != null)
            {
                foreach (Guid id in group.NodeIds)
                {
                    if (!result.ContainsKey(id))
                    {
                        result[id] = new List <NodeGroup> {
                            group
                        }
                    }
                    ;
                    else
                    {
                        result[id].Add(group);
                    }
                }

                foreach (NodeGroup child in group.InternalGroups)
                {
                    CollectNodeGroups(child, ref result);
                }
            }
        }
        public static JsonObject GetJsonLdResultsMetaData(JsonObject jsonLd)
        {
            JsonObject retval = new JsonObject();

            try
            {
                String JSON_TYPE       = "type";
                String JSON_NODE_COUNT = "node_count";

                // convert the jsonLD to a nodegroup.
                // note: this assumes that the results of the construct json can be transformed into a nodegroup.
                // this will break in the event that type info is omited, for instance. because this is intended to be
                // used with the dispatcher, it is a reasonable assumption for now.

                NodeGroup ngTemp;
                ngTemp = NodeGroup.FromConstructJson(jsonLd);

                retval.Add(JSON_TYPE, JsonValue.CreateStringValue("JSON-LD"));
                retval.Add(JSON_NODE_COUNT, JsonValue.CreateNumberValue(ngTemp.GetNodeCount()));

                return(retval);
            }
            catch (Exception e)
            {
                throw new Exception("Error assembling JSON header information for JSON-LD results: " + e.Message);
            }
        }
        public static void OnHierarchyGUI(int instanceID, Rect selectionRect)
        {
            GameObject obj = EditorUtility.InstanceIDToObject(instanceID) as GameObject;

            if (obj != null)
            {
                NodeGroup nodeGroup = obj.GetComponent <NodeGroup>();
                if (nodeGroup != null)
                {
                    Rect iconRect = new Rect(selectionRect.xMax - 15, selectionRect.y + 4, 10, 10);

                    ValidateIcons();
                    if (nodeGroup == NodifyEditorUtilities.currentSelectedGroup)
                    {
                        if (m_iconSelected != null)
                        {
                            GUI.DrawTexture(iconRect, m_iconSelected);
                        }
                    }
                    else
                    {
                        if (m_iconNormal != null)
                        {
                            GUI.DrawTexture(iconRect, m_iconNormal);
                        }
                    }
                }
            }
        }
Beispiel #13
0
        public static void OffsetNodes(NodeGroup ng, double xOffset, double yOffset)
        {
            Polyline poly = new Polyline(
                ng.Nodes.Select(x => x.Frame.Origin));

            if (ng.CustomData.ContainsKey("LoopClosed") && (bool)ng.CustomData["LoopClosed"])
            {
                poly.Add(poly[0]);
            }

            var normal = ng.Frame.ZAxis;

            if (normal * Vector3d.ZAxis < 0)
            {
                normal.Reverse();
            }

            Polyline newPoly = Util.OffsetPolyline(poly, normal, xOffset, yOffset);

            if (newPoly.Count > 1)
            {
                debug.Add(newPoly);
            }

            int N = Math.Min(ng.Nodes.Count, newPoly.Count);

            for (int i = 0; i < N; ++i)
            {
                ng.Nodes[i].Frame.Origin = newPoly[i];
            }
        }
Beispiel #14
0
        public async Task <SimpleResultSet> ExecuteDispatchFromNodeGroup(NodeGroup ng, JsonObject sparqlConnectionJson, JsonObject edcConstraintsJson, JsonObject runtimeConstraintsJson)
        {
            SimpleResultSet retval = null;

            conf.SetServiceEndpoint(mappingPrefix + dispatchFromNodegroupEndpoint);
            this.parameterJson.Add("jsonRenderedNodeGroup", JsonValue.CreateStringValue(ng.ToJson().ToString()));
            this.parameterJson.Add("sparqlConnection", JsonValue.CreateStringValue(sparqlConnectionJson.ToString()));
            if (edcConstraintsJson != null)
            {
                this.parameterJson.Add("externalDataConnectionConstraints", JsonValue.CreateStringValue(edcConstraintsJson.ToString()));
            }
            if (runtimeConstraintsJson != null)
            {
                this.parameterJson.Add("runtimeConstraints", JsonValue.CreateStringValue(runtimeConstraintsJson.ToString()));
            }
            try
            {
                JsonObject kObj = (JsonObject)(await this.Execute());
                retval = SimpleResultSet.FromJson(kObj);
                retval.ThrowExceptionIfUnsuccessful();
            }
            finally{
                conf.SetServiceEndpoint(null);

                this.parameterJson.Remove("jsonRenderedNodeGroup");
                this.parameterJson.Remove("sparqlConnection");
                this.parameterJson.Remove("externalDataConnectionConstraints");
                this.parameterJson.Remove("runtimeConstraints");
            }

            return(retval);
        }
Beispiel #15
0
        /// <summary>
        /// Build a one direction recurrent neural network (RNN) with long-short-term-memory (LSTM) cells.
        /// http://colah.github.io/posts/2015-08-Understanding-LSTMs/
        /// </summary>
        /// <param name="input">the input variable</param>
        /// <param name="embeddingDim">dimension of the embedding layer</param>
        /// <param name="LSTMDim">LSTM output dimension</param>
        /// <param name="cellDim">cell dimension</param>
        /// <param name="device">CPU or GPU device to run the model</param>
        /// <param name="outputName">name of the model output</param>
        /// <returns>the RNN model</returns>
        public static Function Create(Variable input, int embeddingDim, int LSTMDim, int cellDim, DeviceDescriptor device,
                                      string outputName)
        {
            try
            {
                NodeGroup.EnterNewGroup(outputName);

                Function embeddingFunction = Embedding(input, embeddingDim, device, outputName);
                Func <Variable, Function> pastValueRecurrenceHook = (x) => CNTKLib.PastValue(x);
                Function LSTMFunction = LSTMPComponentWithSelfStabilization <float>(
                    embeddingFunction,
                    new int[] { LSTMDim },
                    new int[] { cellDim },
                    pastValueRecurrenceHook,
                    pastValueRecurrenceHook,
                    device,
                    outputName).Item1;
                Function thoughtVectorFunction = CNTKLib.SequenceLast(LSTMFunction);

                thoughtVectorFunction.RootFunction.SetName(outputName);

                return(thoughtVectorFunction);
            }
            finally
            {
                NodeGroup.LeaveGroup();
            }
        }
Beispiel #16
0
    private void AssignSelectedGroup()
    {
        if (NodifyEditorUtilities.currentSelectedGroup != null)
        {
            return;
        }

        if (Selection.activeGameObject != null)
        {
            NodeGroup group = Selection.activeGameObject.GetComponent <NodeGroup>();
            if (group == null)
            {
                if (Selection.activeGameObject.GetComponent <Anchor>())
                {
                    Selection.activeTransform = Selection.activeTransform.parent;
                }

                if (Selection.activeGameObject.GetComponent <Node>())
                {
                    group = Selection.activeGameObject.GetComponent <Node>().parent;
                }
            }

            NodifyEditorUtilities.currentSelectedGroup = group;
        }
    }
    public bool OverlapCheck(Vector3Int stonePosition)
    {
        bool      overlaps  = false;
        NodeGroup nodeGroup = pathfinder.nodeGroup;

        for (int x = stonePosition.x - 1; x < stonePosition.x + 1; x++)
        {
            for (int y = stonePosition.y - 1; y < stonePosition.y + 1; y++)
            {
                if (nodeGroup.GetNode(x, y).isBuildable == false)
                {
                    overlaps = false;
                    break;
                }
                else
                {
                    overlaps = true;
                }
            }

            if (overlaps == false)
            {
                break;
            }
        }

        return(overlaps);
    }
Beispiel #18
0
        public void NodeGroupFromConstruct()
        {
            NodeGroup ngResult = new NodeGroup();

            NodeGroupExecutionClientConfig necc = new NodeGroupExecutionClientConfig("http", "fake-server.crd.ge.com", 12058);
            NodeGroupExecutionClient       nec  = new NodeGroupExecutionClient(necc);

            String nodeGroupId    = "Logging SPARQLgraph alerts";
            String connectionInfo = "{ \"name\": \"Logging SparqlGraph\", \"domain\": \"http://com.ge.research/knowledge/UsageLogging\", \"model\": [ { \"type\": \"virtuoso\", \"url\": \"http://fake-server.crd.ge.com:2420\", \"dataset\": \"http://com.ge.research/knowledge/UsageLogging/LogMaster\"} ], \"data\": [ {\"type\": \"virtuoso\", \"url\": \"http://fake-server.crd.ge.com:2420\", \"dataset\": \"http://com.ge.research/knowledge/UsageLogging/SPARQLGraph\" } ]}";

            JsonObject jObject = JsonObject.Parse(connectionInfo);

            JsonObject jsonLD = nec.ExecuteDispatchConstructByIdToJsonLd(nodeGroupId, jObject, null, null).Result;

            NodeGroupResultSet ngResultSet = new NodeGroupResultSet(true);

            ngResultSet.ReadJson(jsonLD);


            ngResult = NodeGroup.FromConstructJson(ngResultSet.GetResultsJson());

            Debug.WriteLine("total node count =" + ngResult.GetNodeCount());

            Assert.IsTrue(ngResult.GetNodeCount() > 0);

            foreach (Node nCurr in ngResult.GetNodeList())
            {
                // write some basic debug so we can see something is working.
                Debug.WriteLine("uri: " + nCurr.GetFullUriName() + " , instanceValue: " + nCurr.GetInstanceValue());
            }
        }
 /// <summary>
 /// Creates a Nodegroup thats linked to the existing nodegroup with new weights
 /// </summary>
 /// <param name="InputNodes">The nodes that its linked to</param>
 /// <param name="size">The size of the group</param>
 public NodeGroup(NodeGroup InputNodes, int size)
 {
     Nodes = new Node[size];
     for (int i = 0; i < size; i++)
     {
     }
 }
Beispiel #20
0
            public void GetShared(NodeGroup ng, out List <Node> SharedNodes, out List <Edge> SharedEdges)
            {
                SharedNodes = this.Nodes.Where(x => ng.Nodes.Contains(x)).ToList();
                var theseEdges = this.Nodes.SelectMany(x => x.Edges).ToList();
                var thoseEdges = ng.Nodes.SelectMany(x => x.Edges).ToList();

                SharedEdges = theseEdges.Where(x => thoseEdges.Contains(x)).ToList();
            }
Beispiel #21
0
 public NodeGroup Save(NodeGroup ng)
 {
     ng.Id = IdManager.GetId();
     using (dbc = DAL.Instance.GetDb()){
         dbc.Insert <NodeGroup>(ng);
     }
     return(ng);
 }
Beispiel #22
0
 private void OnEnable()
 {
     _group                  = (NodeGroup)target;
     centeredstyle           = new GUIStyle();
     centeredstyle.alignment = TextAnchor.MiddleCenter;
     centeredstyle.fontSize  = 15;
     centeredstyle.fontStyle = FontStyle.Bold;
 }
Beispiel #23
0
        public async Task <long> ExecuteDispatchCountByNodegroupToLong(NodeGroup nodegroup, JsonObject sparqlConnectionJson, JsonObject edcConstraintsJson, JsonArray runtimeConstraintsJson)
        {
            SimpleResultSet ret = await this.ExecuteDispatchCountFromNodeGroup(nodegroup, sparqlConnectionJson, edcConstraintsJson, runtimeConstraintsJson);

            Table tab = await this.WaitForJobAndGetTable(ret.GetResult("JobId"));

            return(tab.GetCellAsInt(0, 0));
        }
Beispiel #24
0
        protected override void AddItem()
        {
            IMainForm mainForm = Instances.MainForm;

            // Show the new account.
            NodeGroup newNode = new NodeGroup("", 0);

            mainForm.ShowItem(newNode);
        }
Beispiel #25
0
 public void NewNodeGroup()
 {
     if (GUILayout.Button("+", GUILayout.Width(20)))
     {
         NodeGroup ng = new GameObject().AddComponent <NodeGroup>();;
         ng.nodeList    = new List <Node>();
         nodegroup      = ng;
         nodegroup.name = "NewGroup";
     }
 }
Beispiel #26
0
        /// <summary>
        /// 获取结点组
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public NodeGroup GetNodeGroup(string key)
        {
            NodeGroup group = null;

            if (nodeGroups.TryGetValue(key, out group))
            {
                return(group);
            }
            return(null);
        }
Beispiel #27
0
 public void Write(NodeGroup <ConversationNode <TNodeUI, TTransitionUI> > group)
 {
     //TODO: Write groups again when things have stabilised
     //var g = new XElement("Group");
     //foreach (var node in group.Contents)
     //    g.Add(new XElement("Node", new XAttribute("Id", node.Id.ToString())));
     //m_nodeUISerializer.Write(group, g);
     ////WriteArea(group, g);
     //m_root.Add(g);
 }
Beispiel #28
0
 private void Initial()
 {
     _sequence.Clear();
     _tokenBuffer.Clear();
     _tokens.Clear();
     _exps.Clear();
     _lexer.Reset();
     _group       = new Capture(null, _lexer.AnonymousCapCount);
     _alternate   = new Alternate(_group);
     _concatenate = new Concatenate(_alternate);
 }
Beispiel #29
0
 private void PushGroup()
 {
     if (_unit.Type == NodeType.Comment || _unit.Type == NodeType.Field)
     {
         return;
     }
     _group       = _unit as NodeGroup;
     _alternate   = new Alternate(_group);
     _concatenate = new Concatenate(_alternate);
     _unit        = null;
 }
            /// <summary>
            /// Creates a new node with all new Nodes
            /// </summary>
            /// <param name="nodeGroup"></param>
            public Node(NodeGroup nodeGroup)
            {
                InputNodes = nodeGroup;
                Weights    = new double[nodeGroup.Size];
                Random random = new Random();

                for (int i = 0; i < Weights.Length; i++)
                {
                    Weights[i] = random.NextDouble();
                }
            }
Beispiel #31
0
        void Dfs1(Node node)
        {
            node.Index = nextSCCIndex++;
            node.LowLink = node.Index;
            nodeStack.Push (node);

            foreach (var to in node.PointsTo) {
                if (to.Index == 0) {
                    Dfs1 (to);
                    node.LowLink = System.Math.Min (node.LowLink, to.LowLink);
                } else if (nodeStack.Contains (to)) {
                    node.LowLink = System.Math.Min (node.LowLink, to.Index);
                }
            }

            if (node.LowLink == node.Index) {
                NodeGroup g = new NodeGroup ();
                Node n;
                do {
                    n = nodeStack.Pop ();
                    n.Group = g;
                    g.Add (n);
                } while (n != node);
                groups.Add (g);
            }
        }
        protected override void ProcessResource( ResourceTree aResourceTree )
        {
            System.Func<ResourceTreeNode, XElement, XElement> GetChildren = null;
              var excludedGroups = new NodeGroup[] {
            NodeGroup.ExtensionPackages, NodeGroup.GameInformation, NodeGroup.GlobalGameSettings, NodeGroup.Invalid
              };

              GetChildren = ( aNode, aParent ) => {
            foreach ( var node in aNode ) {
              if ( node.Type == NodeTypes.Group )
            aParent.Add( GetChildren( node, new XElement( "Group", new XAttribute( "Name", node.Name ) ) ) );
              else
            aParent.Add( new XElement( "Node", new XAttribute( "Name", node.Name ), new XAttribute( "ID", node.ID ) ) );
            }

            return aParent;
              };

              var document =
            new XElement( "Tree",
              from node in aResourceTree
              where !excludedGroups.Contains( node.Group )
              select GetChildren( node, new XElement( node.Group.ToString() ) )
            );

              SaveDocument( document, Filenames.Tree + ".xml" );
        }
    void parseGraph(string nodeAsset, int dimensionality, int type)
    {
        TextAsset positionsText = Resources.Load(nodeAsset) as TextAsset;
        string[,] myPositionsGrid = CSVReader.SplitCsvGrid(positionsText.text);
        int numberOfNodes = myPositionsGrid.GetUpperBound(1) - 1;

        masterNodeList = new Node[numberOfNodes];
        indicesToShowOrExplode = new int[numberOfNodes];

        // add nodes
        for (int i = 1; (i < numberOfNodes + 1); i++)
        {

            if (i != 0) { adjacencyList.AddVertex(i); }

            Vector3 position;

            int startIndexCoordinates;

            if (type == DATA_MNIST)
            {
                startIndexCoordinates = 3;
            }
            else
            {
                startIndexCoordinates = 8;
            }

            float x_3d = float.Parse(myPositionsGrid[startIndexCoordinates, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER;
            float y_3d = float.Parse(myPositionsGrid[startIndexCoordinates + 1, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER;
            float z_3d = float.Parse(myPositionsGrid[startIndexCoordinates + 2, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER;

            float x_2d = float.Parse(myPositionsGrid[startIndexCoordinates + 3, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER;
            float y_2d = float.Parse(myPositionsGrid[startIndexCoordinates + 4, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER;

            if (dimensionality == GRAPH_3D)
            {
                position = new Vector3(
                    x_3d,
                    y_3d,
                    z_3d
                );
            }
            else
            {
                position = new Vector3(
                    x_2d,
                    y_3d,
                    0.0f
                );
            }
            string label = myPositionsGrid[0, i];

            GameObject myNodeInstance =
                Instantiate(Resources.Load("Node") as GameObject,
                    position,
                    Quaternion.identity) as GameObject;

            //don't do getcomp live
            LayerSelfBasedOnRelativeLocations layerScript = myNodeInstance.GetComponent<LayerSelfBasedOnRelativeLocations>();
            layerScript.eagleEyeCamera = eagleEyeCamera;
            layerScript.headsetLocation = playerCamera;

            NodeForce nodeScript = myNodeInstance.GetComponent<NodeForce>();

            nodeScript.x_3d = x_3d;
            nodeScript.y_3d = y_3d;
            nodeScript.z_3d = z_3d;

            nodeScript.x_2d = x_2d;
            nodeScript.y_2d = y_2d;

            nodeScript.SetText(myPositionsGrid[1, i]);

            nodeScript.degree = int.Parse(myPositionsGrid[2, i]);

            nodeScript.SetScaleFromDegree(nodeScript.degree);

            masterNodeList[i - 1] = new Node(myNodeInstance, i - 1);

            if (type == DATA_TWITTER)
            {
                masterNodeList[i - 1].nodeForce.group = int.Parse(myPositionsGrid[3, i]);
                masterNodeList[i - 1].nodeForce.followerCount = (int)float.Parse(myPositionsGrid[4, i]);
            }
            else if (type == DATA_MNIST)
            {
                masterNodeList[i - 1].nodeForce.group = (int)float.Parse(myPositionsGrid[1, i]);
            }

            NodeGroup nodeGroupWrapperObject;
            // if this is a new key, make a new group
            if (!nodeGroups.ContainsKey(masterNodeList[i - 1].nodeForce.group))
            {
                GameObject nodeGroupObject = Instantiate(Resources.Load("NodeGroupContainer") as GameObject, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity) as GameObject;

                nodeGroupWrapperObject = new NodeGroup(nodeGroupObject);

                nodeGroupWrapperObject.nodeGroupContainerScript.groupNumber = masterNodeList[i - 1].nodeForce.group;

                nodeGroupWrapperObject.gameObject.transform.parent = nodeContainer.transform;

                nodeGroups.Add(
                    masterNodeList[i - 1].nodeForce.group,
                    nodeGroupWrapperObject
                    );
            }
            else // give access to the existing group
            {
                nodeGroupWrapperObject = nodeGroups[masterNodeList[i - 1].nodeForce.group];
            }
            masterNodeList[i - 1].nodeForce.SetColorByGroup(masterNodeList[i - 1].nodeForce.group);

            masterNodeList[i - 1].gameObject.transform.parent = nodeGroupWrapperObject.gameObject.transform; // not sure if this is gonna work right, off the bat

            // populate an array for the mnist image
            if (type == DATA_MNIST)
            {
                for (int q = 0; q < MNIST_IMAGE_SIZE; q++)
                {
                    for (int r = 0; r < MNIST_IMAGE_SIZE; r++)
                    {
                        //print("q: " + q + "... r: " + r);
                        masterNodeList[i - 1].nodeForce.image[q, r] = float.Parse(myPositionsGrid[startIndexCoordinates + 5 + q * MNIST_IMAGE_SIZE + r, i]);
                    }
                }
            }

            nameToID.Add(label, i - 1);
        }
    }
    void parseMetadata(string metaAsset)
    {
        TextAsset metaText = Resources.Load(metaAsset) as TextAsset;
        string[,] metaGrid = CSVReader.SplitCsvGrid(metaText.text);
        int numberOfGroups = metaGrid.GetUpperBound(1) - 1;

        for (int i = 1; (i < numberOfGroups + 1); i++)
        {

            // add the group

            GameObject nodeGroupObject = Instantiate(Resources.Load("NodeGroupContainer") as GameObject, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity) as GameObject;

            NodeGroup nodeGroupWrapperObject = new NodeGroup(nodeGroupObject);

            int currentGroupNumber = (int)float.Parse(metaGrid[0, i]);

            nodeGroupWrapperObject.nodeGroupContainerScript.groupNumber = currentGroupNumber;

            nodeGroupWrapperObject.gameObject.transform.parent = nodeContainer.transform;

            // give the group its centroid

            float x_3d = float.Parse(metaGrid[1, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER;
            float y_3d = float.Parse(metaGrid[2, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER;
            float z_3d = float.Parse(metaGrid[3, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER;

            GameObject centroidGameObject =
                Instantiate(Resources.Load("GroupCentroid") as GameObject,
                    new Vector3(
                        x_3d,
                        y_3d,
                        z_3d
                    ),
                    Quaternion.identity)
                as GameObject;

            centroidGameObject.transform.parent = nodeGroupWrapperObject.gameObject.transform;

            GroupCentroidReferences groupCentroidReferenceObject = new GroupCentroidReferences(centroidGameObject);

            nodeGroupWrapperObject.nodeGroupContainerScript.centroid = groupCentroidReferenceObject;

            groupCentroidReferenceObject.groupCentroidScript.x_3d = x_3d;
            groupCentroidReferenceObject.groupCentroidScript.y_3d = y_3d;
            groupCentroidReferenceObject.groupCentroidScript.z_3d = z_3d;

            nodeGroups.Add(
                currentGroupNumber,
                nodeGroupWrapperObject
                );

            groupCentroidReferenceObject.groupCentroidScript.SetColorByGroup(currentGroupNumber);

        }

        // put a centroid object in every group
        // give a reference to the centroid object to the group?
        // give the centroid object a reference to the group?
        // centroid color should match group color
    }
        public SkillTree(String treestring, startLoadingWindow start = null, UpdateLoadingWindow update = null, closeLoadingWindow finish = null)
        {
            bool displayProgress = ( start != null && update != null && finish != null );
           // RavenJObject jObject = RavenJObject.Parse( treestring.Replace( "Additional " , "" ) );
          JsonSerializerSettings jss = new JsonSerializerSettings
            {
            Error = delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
            {
            Debug.WriteLine(args.ErrorContext.Error.Message);
            args.ErrorContext.Handled = true;
            }
            };

          var inTree = JsonConvert.DeserializeObject<PoEClasses.PoESkillTree>(treestring.Replace("Additional ", ""), jss);
            int qindex = 0;


            foreach (var obj in inTree.skillSprites)
            {
                if (obj.Key.Contains("inactive"))
                    continue;
                iconActiveSkills.Images[obj.Value[3].filename] = null;
                foreach (var o in obj.Value[3].coords)
                {
                    iconActiveSkills.SkillPositions[o.Key] = new KeyValuePair<Rect, string>(new Rect(o.Value.x, o.Value.y, o.Value.w, o.Value.h), obj.Value[3].filename);
                }
            }
            foreach (var obj in inTree.skillSprites)
            {
                if (obj.Key.Contains("active"))
                    continue;
                iconActiveSkills.Images[obj.Value[3].filename] = null;
                foreach (var o in obj.Value[3].coords)
                {
                    iconActiveSkills.SkillPositions[o.Key] = new KeyValuePair<Rect, string>(new Rect(o.Value.x, o.Value.y, o.Value.w, o.Value.h), obj.Value[3].filename);
                }
            }   
            qindex = 0;    

            foreach(var ass in inTree.assets)
            {
               
                assets[ass.Key] = new Asset(ass.Key,ass.Value.ContainsKey(0.3835f)?ass.Value[0.3835f]:ass.Value.Values.First());
                                     
            }
           
            if ( displayProgress )
                start( );
            iconActiveSkills.OpenOrDownloadImages(update );
            iconInActiveSkills.OpenOrDownloadImages(update );
            if ( displayProgress )
                finish( );
            foreach( var c in inTree.characterData)
            {
                CharBaseAttributes[c.Key] = new Dictionary<string, float>() { { "+# to Strength", c.Value.base_str }, { "+# to Dexterity", c.Value.base_dex }, { "+# to Intelligence", c.Value.base_int } };
            }
           foreach (var nd in inTree.nodes)
           {
               Skillnodes.Add(nd.id, new SkillTree.SkillNode()
               {
                   id = nd.id,                
                   name = nd.dn,
                   attributes = nd.sd,
                   orbit = nd.o,
                   orbitIndex =nd.oidx,
                   icon = nd.icon,
                   linkID =nd.ot,
                   g = nd.g,
                   da = nd.da,
                   ia = nd.ia,
                   ks = nd.ks,
                   not = nd.not,
                   sa = nd.sa,
                   Mastery = nd.m,
                   spc=nd.spc.Count()>0?(int?)nd.spc[0]:null
               });
           }         
            List<ushort[]> links = new List<ushort[]>( );
            foreach ( var skillNode in Skillnodes )
            {
                foreach ( ushort i in skillNode.Value.linkID )
                {
                    if (
                        links.Count(
                            nd => ( nd[ 0 ] == i && nd[ 1 ] == skillNode.Key ) || nd[ 0 ] == skillNode.Key && nd[ 1 ] == i ) ==
                        1 )
                    {
                        continue;
                    }
                    links.Add( new ushort[] { skillNode.Key , i } );
                }
            }
            foreach ( ushort[] ints in links )
            {
                if ( !Skillnodes[ ints[ 0 ] ].Neighbor.Contains( Skillnodes[ ints[ 1 ] ] ) )
                    Skillnodes[ ints[ 0 ] ].Neighbor.Add( Skillnodes[ ints[ 1 ] ] );
                if ( !Skillnodes[ ints[ 1 ] ].Neighbor.Contains( Skillnodes[ ints[ 0 ] ] ) )
                    Skillnodes[ ints[ 1 ] ].Neighbor.Add( Skillnodes[ ints[ 0 ] ] );
            }
           
            foreach(var gp in inTree.groups )
            {
                NodeGroup ng = new NodeGroup();

                ng.OcpOrb = gp.Value.oo;
                ng.Position = new Vector2D(gp.Value.x, gp.Value.y);
                ng.Nodes = gp.Value.n;
                NodeGroups.Add(ng);
            }
          
            foreach ( SkillTree.NodeGroup group in NodeGroups )
            {
                foreach ( ushort node in group.Nodes )
                {
                    Skillnodes[ node ].NodeGroup = group;
                }
            }

            TRect = new Rect2D( new Vector2D( inTree.min_x * 1.1 , inTree.min_y * 1.1 ) ,
                               new Vector2D(inTree.max_x * 1.1, inTree.max_y * 1.1));




            InitNodeSurround( );
            DrawNodeSurround( );
            DrawNodeBaseSurround( );
            DrawSkillIconLayer( );
            DrawBackgroundLayer( );
            InitFaceBrushesAndLayer( );
            DrawLinkBackgroundLayer( links );
            InitOtherDynamicLayers( );
            CreateCombineVisual( );


            Regex regexAttrib = new Regex( "[0-9]*\\.?[0-9]+" );
            foreach ( var skillNode in Skillnodes )
            {
                skillNode.Value.Attributes = new Dictionary<string , List<float>>( );
                foreach ( string s in skillNode.Value.attributes )
                {

                    List<float> values = new List<float>( );

                    foreach ( Match m in regexAttrib.Matches( s ) )
                    {

                        if ( !AttributeTypes.Contains( regexAttrib.Replace( s , "#" ) ) )
                            AttributeTypes.Add( regexAttrib.Replace( s , "#" ) );
                        if ( m.Value == "" )
                            values.Add( float.NaN );
                        else
                            values.Add( float.Parse( m.Value , System.Globalization.CultureInfo.InvariantCulture ) );

                    }
                    string cs = ( regexAttrib.Replace( s , "#" ) );

                    skillNode.Value.Attributes[ cs ] = values;



                }
            }


        }
Beispiel #36
0
 public void Connect(NodeGroup to)
 {
     toGroups.Add (to);
     to.fromGroups.Add (this);
 }
Beispiel #37
0
 void Dfs2(NodeGroup g)
 {
     foreach (var n in g.Nodes) {
         foreach (var t in n.PointsTo) {
             if (t.Group != g)
                 g.Connect (t.Group);
         }
     }
 }
Beispiel #38
0
 public static void OpenInEditor(NodeGroup group)
 {
     Initialize();
     NodifyEditorUtilities.currentSelectedGroup = group;
 }
Beispiel #39
0
 public void DrawNodeGroup(NodeGroup node)
 {
     object renderer = Nodify.Editor.NodifyEditorUtilities.FindNodeRenderer(node.GetType());
     renderer.GetType().GetMethod("Render").Invoke(renderer, new object[] { node });
 }
Beispiel #40
0
    private void HandleEditorEvents(NodeGroup group)
    {
        int multi_select_nodes = EditorPrefs.GetInt("nodify.hotkeys.multi_select_nodes", 303);
        // Begin Context Menu Controls
        if (Event.current.type == EventType.ContextClick)
        {
            if (NodifyEditorUtilities.currentConnectingAnchor != null)
            {
                NodifyEditorUtilities.currentConnectingAnchor = null;

                Event.current.Use();
            }
            else
            {
                ShowNodeCreationMenu();

                Event.current.Use();
            }
        }

        if(Event.current.type == EventType.KeyDown)
        {
            // Begin Focus Element Control
            if (Event.current.keyCode == (KeyCode)EditorPrefs.GetInt("nodify.hotkeys.focus_on_selected_node2", 102) && NodifyPreferencesGUI.GetAdditionalButtons(EditorPrefs.GetInt("nodify.hotkeys.focus_on_selected_node", 0)))
            {
                if (Selection.activeGameObject != null)
                {
                    if (Selection.activeGameObject.GetComponent<Node>())
                    {
                        FocusNode(group, Selection.activeGameObject.GetComponent<Node>());
                    }

                    if (Selection.activeGameObject.GetComponent<Anchor>())
                    {
                        FocusNode(group, Selection.activeGameObject.GetComponent<Anchor>().parent);
                    }
                }
                ForceRepaint();
            }

            if (Event.current.keyCode == KeyCode.Delete)
            {
                foreach (GameObject obj in Selection.gameObjects)
                {
                    if (obj != NodifyEditorUtilities.currentSelectedGroup.gameObject && (obj.GetComponent<Node>() || obj.GetComponent<Anchor>()))
                    {
                        if (EditorUtility.DisplayDialog("Are you sure?", "Do you wish to delete the node: " + obj.name, "Delete", "Cancel"))
                        {
                            NodifyEditorUtilities.SafeDestroy(obj);
                        }
                    }
                }
            }
        }

        // Begin Mouse Selection Events
        if (NodifyEditorUtilities.currentManipulatingNode == null && NodifyPreferencesGUI.GetAdditionalButtons(EditorPrefs.GetInt("nodify.hotkeys.multi_select_nodes", 303)))
        {
            switch (Event.current.type)
            {
                case EventType.MouseDown:
                    if (Event.current.button == 0)
                    {
                        MouseSelectionStartPoint = Event.current.mousePosition;
                        MouseSelection = true;
                        ForceRepaint();
                    }
                    break;
                case EventType.MouseUp:
                    if (MouseSelection == true)
                    {
                        SelectNodesInRect(RectExtensions.GetRectFromPoints(MouseSelectionStartPoint, Event.current.mousePosition));
                        MouseSelection = false;
                    }
                    ForceRepaint();
                    break;
                case EventType.MouseDrag:
                    if (Event.current.button == 0)
                    {
                        ForceRepaint();
                    }
                    else if (Event.current.button == 2) // Begin Mouse Drag Controls
                    {
                        Vector2 mouseDelta = Event.current.delta;
                        Vector2 mouseZoomDelta = (1f / group.editorZoomAmount) * mouseDelta;

                        group.editorWindowOffset += mouseZoomDelta;

                        Event.current.Use();
                    }
                    break;
            }
        }

        if (Event.current.type == EventType.MouseDrag && multi_select_nodes != 0 && !NodifyPreferencesGUI.GetAdditionalButtons(EditorPrefs.GetInt("nodify.hotkeys.multi_select_nodes", 303)))
        {
            Vector2 mouseDelta = Event.current.delta;
            Vector2 mouseZoomDelta = (1f / group.editorZoomAmount) * mouseDelta;

            group.editorWindowOffset += mouseZoomDelta;

            ForceRepaint();
        }

        // Begin Zoom Controls
        if (Event.current.type == EventType.ScrollWheel)
        {
            group.editorZoomAmount -= Event.current.delta.y / 80;
            group.editorZoomAmount = (float)System.Math.Round((double)Mathf.Clamp(group.editorZoomAmount, minimumZoomFactor, maximumZoomFactor), 2);

            Event.current.Use();
        }

        if (Event.current.type == EventType.MouseDown && multi_select_nodes != 0 && NodifyPreferencesGUI.GetAdditionalButtons(EditorPrefs.GetInt("nodify.hotkeys.deselect_all", 303)))
        {
            Selection.objects = new UnityEngine.Object[0];

            Event.current.Use();
        }

        // Begin Drag & Drop Components into Variables
        if(Event.current.type == EventType.DragPerform || Event.current.type == EventType.DragUpdated)
        {
            DragAndDrop.visualMode = DragAndDropVisualMode.Link;

            if(Event.current.type == EventType.DragPerform)
            {
                DragAndDrop.AcceptDrag();

                foreach(UnityEngine.Object obj in DragAndDrop.objectReferences)
                {
                    foreach(CreateMenu nodeMenu in NodifyEditorUtilities.FindNodeTypes())
                    {
                        if(nodeMenu.type.BaseType.IsGenericType)
                        {
                            if(nodeMenu.type.BaseType.GetGenericArguments()[0] == obj.GetType())
                            {
                                GameObject nodeObj = new GameObject(obj.GetType().Name);

                                #if UNITY_5
                                Node nodeClass = (Node)nodeObj.AddComponent(nodeMenu.type);
                                #else
                                Node nodeClass = (Node)nodeObj.AddComponent(nodeMenu.type.Name);
                                #endif

                                nodeClass.editorPosition = Event.current.mousePosition - group.editorWindowOffset;
                                nodeClass.editorResourceIcon = nodeMenu.iconResourcePath;
                                nodeClass.OnEditorNodeCreated();
                                nodeObj.transform.parent = group.transform;

                                nodeClass.GetType().GetField("value").SetValue(nodeClass, obj);
                            }
                        }
                    }
                }
            }
        }
    }
Beispiel #41
0
 public void FocusNode(NodeGroup group, Node node)
 {
     group.editorZoomAmount = maximumZoomFactor;
     group.editorWindowOffset = -node.editorPosition + new Vector2(this.position.width / 2, this.position.height / 2);
 }