コード例 #1
0
        private void UpdateExistingNodeGoData(GameObject nodeExistingGo, CdmNodeBtc nodeNewBtc)
        {
            GraphNodeBrain gnb = nodeExistingGo.GetComponent <GraphNodeBrain>();

            if (gnb != null)
            {
                gnb.CdmNodeBtc  = nodeNewBtc;
                gnb.NodeType    = nodeNewBtc.NodeType;
                gnb.ValueMBtc   = nodeNewBtc.FinalBalance;
                gnb.TotalEdges  = nodeNewBtc.NodeEdgeCountTotal;
                gnb.Id          = nodeNewBtc.NodeId;
                gnb.TxDate      = nodeNewBtc.CreateDate;
                gnb.BlockHeight = nodeNewBtc.BlockHeight;
                gnb.RelayedBy   = nodeNewBtc.RelayedBy;

                // Special case for first ever created node
                if (!GlobalData.Instance.FirstNodeCreatedYet)
                {
                    GlobalData.Instance.FirstNodeCreatedYet = true;
                    gnb.SetFirstEverCreated();
                }

                // Update UI text els with the new GraphNodeBrain values
                gnb.RefreshUI();
            }
        }
コード例 #2
0
        void IGraphFactory.CreateOrUpdateNode(CdmNode nodeNew, Vector3 location)
        {
            CdmNodeBtc nodeNewBtc = nodeNew as CdmNodeBtc;

            // Do we exist already?
            GameObject nodeExistingGo;

            if (_graphIndex.TryGetValue(nodeNewBtc.NodeId, out nodeExistingGo))
            {
                UpdateExistingNodeGoData(nodeExistingGo, nodeNewBtc);

                Msg.Log("GraphFactory.CreateOrUpdateNode: Node refreshed: " + nodeExistingGo.gameObject.name + " at " + nodeExistingGo.gameObject.transform.position);

                return;
            }

            GameObject nodeCreated = null;
            Vector3    createPos   = GetRandomPosNear(location);

            //Msg.LogWarning("created near:" + location);

            nodeCreated = InstantiateNode(createPos, nodeNewBtc.NodeType);

            if (nodeCreated != null)
            {
                GraphNodePhysics nodeNode = nodeCreated.GetComponent <GraphNodePhysics>();
                nodeNode.name = nodeNewBtc.NodeId;
                nodeNode.Text = name;

                UpdateExistingNodeGoData(nodeCreated, nodeNewBtc);

                Msg.Log("GraphFactory.CreateOrUpdateNode: Node created: " + nodeCreated.gameObject.name + " at " + nodeCreated.gameObject.transform.position);
                _graphIndex.Add(nodeNewBtc.NodeId, nodeCreated);
            }
            else
            {
                Msg.LogWarning("GraphFactory.CreateOrUpdateNode: Something went wrong, no node created.");
                return;
            }
        }
コード例 #3
0
        private void OnCdmPoolGraphAdded(object sender, CdmPoolEventArgs args)
        {
            // Note: it is possible to filter to just showing graphs that WE requested from the cdmpool. To do this, examine args.CdmRequest to see
            // what the request was. For now this is not needed and not done.

            CdmGraphBtc gb = args.CdmGraph as CdmGraphBtc;

            if (gb == null)
            {
                Msg.LogError("FrontEndController.OnCdmPoolGraphAdded heard event but graph fragment is null or not correct type");
                return;
            }
            else
            {
                Msg.Log("FrontEndController.OnCdmPoolGraphAdded heard event that graph fragment" + gb.GraphId + " is to be added to pool");
            }

            // Create nodes and edges
            Vector3 location = args.CdmRequest.WorldLocation;

            foreach (CdmNode n in gb.GetAllNodes())
            {
                CdmNodeBtc nb = n as CdmNodeBtc;
                GraphFactory.CreateOrUpdateNode(nb, location);
            }

            foreach (CdmEdge e in gb.GetAllEdges())
            {
                CdmEdgeBtc eb = e as CdmEdgeBtc;
                GraphFactory.CreateOrUpdateEdge(eb);
            }

            // An audio-visual feast
            if (AudioManager.Instance != null)
            {
                AudioManager.Instance.PlayPop();
            }
        }