コード例 #1
0
ファイル: MapNode.cs プロジェクト: ullizei/pirates
    public void AddConnection(NodeConnection connection)
    {
        if (connections == null)
            connections = new List<NodeConnection>();

        connections.Add (connection);
    }
コード例 #2
0
    void OnEnable()
    {
        _target = (NodeConnection) target;

        if (_target.path == null)
            _target.path = new List<Vector3>();
    }
コード例 #3
0
ファイル: NodeConnector.cs プロジェクト: Wuzseen/Circuit-Math
	public bool IsEqual(NodeConnection other) {
		if(other.a == this.a && other.b == this.b) {
			return true;
		}
		if(other.a == this.b && other.b == this.a) {
			return true;
		}
		return false;
	}
コード例 #4
0
ファイル: GraphDesigner.cs プロジェクト: webconfig/Design
 /// <summary>
 /// 连接两个节点
 /// </summary>
 /// <param name="behaviorSource"></param>
 /// <param name="nodeDesigner">结束模块</param>
 public void connectNodes(Task node)
 {
     NodeConnection nodeConnection = ActiveNodeConnection;
     ActiveNodeConnection = null;
     if (nodeConnection != null && !nodeConnection.OriginatingNodeDesigner.Equals(node))
     {//不是连接到自己
         Task originating = nodeConnection.OriginatingNodeDesigner;
         if (nodeConnection.NodeConnectionType == NodeConnectionType.Outgoing)
         {
             originating.AddConnection(node, nodeConnection, true);
         }
         data.Datas.Remove(nodeConnection.DestinationNodeDesigner);
     }
 }
コード例 #5
0
ファイル: Intersection.cs プロジェクト: brayan-schroeder/tcc
 /// <summary>
 /// Gibt den Zeitpunkt des Schnittpunktes an der NodeConnection nc an
 /// </summary>
 /// <param name="nc">NodeConnection dessen Schnittpunkt-Zeitparameter zurückgegeben werden soll</param>
 /// <returns>_aTime/_bTime falls nc=_aConnection/nc=_bConnection, sonst Exception</returns>
 public double GetMyTime(NodeConnection nc)
 {
     if (_aConnection == nc)
     {
         return(_aTime);
     }
     else if (_bConnection == nc)
     {
         return(_bTime);
     }
     else
     {
         throw new Exception();
     }
 }
コード例 #6
0
ファイル: Node.cs プロジェクト: Darpaler/Mazes-and-Monsters
 public void AddUniqueLinkTo(Node target)
 {
     if (ContainsLinkTo(target))
     {
         return;
     }
     else
     {
         NodeConnection temp = new NodeConnection();
         temp.fromNode = this;
         temp.toNode   = target;
         temp.cost     = Vector3.Distance(this.tf.position, target.tf.position);
         connections.Add(temp);
     }
 }
コード例 #7
0
 public ConversationActionNodeNoticeHandler(
     NodeNotice notice,
     NodeConnection nodeConnection,
     IConversationsService conversationsService,
     IConversationsNoticeService conversationsNoticeService,
     ILoadDialogsService loadDialogsService,
     ISystemMessagesService systemMessagesService)
 {
     this.notice                     = (ConversationActionNodeNotice)notice;
     this.nodeConnection             = nodeConnection;
     this.conversationsService       = conversationsService;
     this.conversationsNoticeService = conversationsNoticeService;
     this.loadDialogsService         = loadDialogsService;
     this.systemMessagesService      = systemMessagesService;
 }
コード例 #8
0
ファイル: Node.cs プロジェクト: royosherove/NBitcoin
 internal Node(Peer peer, NodeServer nodeServer, Socket socket, VersionPayload version)
 {
     _Peer        = peer;
     _NodeServer  = nodeServer;
     _Connection  = new NodeConnection(this, socket);
     _FullVersion = version;
     Version      = version.Version;
     LastSeen     = peer.NetworkAddress.Time;
     TraceCorrelation.LogInside(() =>
     {
         NodeServerTrace.Information("Connected to advertised node " + _Peer.NetworkAddress.Endpoint);
         State = NodeState.Connected;
     });
     _Connection.BeginListen();
 }
コード例 #9
0
        public void SelfReferenceTest()
        {
            var node       = new Node <int, string>(1);
            var connection = new NodeConnection <int, string>(node, node, "ConnectionItem");

            connection.BindToNodes();

            List <NodeConnection <int, string> > removedEdges;
            List <int> result = TopologicalSorter.Sort(EnumerableUtils.One(node), out removedEdges);

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(node.Item, result[0]);
            Assert.AreEqual(1, removedEdges.Count);
            Assert.AreEqual(connection, removedEdges[0]);
        }
コード例 #10
0
ファイル: Intersection.cs プロジェクト: brayan-schroeder/tcc
        /// <summary>
        /// Unregisters the given vehicle from this intersection.
        /// </summary>
        /// <param name="v">Vehicle to unregister (must already be registered!).</param>
        /// <param name="nc">NodeConnection the vehicle is going to use (must participate on this Intersection!).</param>
        public void UnregisterVehicle(IVehicle v, NodeConnection nc)
        {
            Debug.Assert(nc == _aConnection || nc == _bConnection);

            if (nc == _aConnection)
            {
                Debug.Assert(aCrossingVehicles.ContainsKey(v));
                aCrossingVehicles.Remove(v);
            }
            else
            {
                Debug.Assert(bCrossingVehicles.ContainsKey(v));
                bCrossingVehicles.Remove(v);
            }
        }
コード例 #11
0
ファイル: Intersection.cs プロジェクト: brayan-schroeder/tcc
        /// <summary>
        /// Returns the CrossingVehicleTimes data of the given vehicle.
        /// </summary>
        /// <param name="v">Vehicle to search for (must already be registered!).</param>
        /// <param name="nc">NodeConnection the vehicle is going to use (must participate on this Intersection!).</param>
        /// <returns>The CrossingVehicleTimes data of the given vehicle.</returns>
        public CrossingVehicleTimes GetCrossingVehicleTimes(IVehicle v, NodeConnection nc)
        {
            Debug.Assert(nc == _aConnection || nc == _bConnection);

            if (nc == _aConnection)
            {
                Debug.Assert(aCrossingVehicles.ContainsKey(v));
                return(aCrossingVehicles[v]);
            }
            else
            {
                Debug.Assert(bCrossingVehicles.ContainsKey(v));
                return(bCrossingVehicles[v]);
            }
        }
コード例 #12
0
ファイル: Intersection.cs プロジェクト: brayan-schroeder/tcc
 /// <summary>
 /// Gibt die andere an der Intersection teilhabende NodeConnection zurück
 /// </summary>
 /// <param name="nc">NodeConnection die nicht zurückgegeben werden soll</param>
 /// <returns>Die NodeConnection, die sich in dieser Intersection mit nc schneidet oder null, wenn nc nicht an der Intersection teilnimmt</returns>
 public NodeConnection GetOtherNodeConnection(NodeConnection nc)
 {
     if (_aConnection == nc)
     {
         return(_bConnection);
     }
     else if (_bConnection == nc)
     {
         return(_aConnection);
     }
     else
     {
         return(null);
     }
 }
コード例 #13
0
ファイル: Intersection.cs プロジェクト: brayan-schroeder/tcc
 /// <summary>
 /// Gibt den ListNode des Schnittpunktes an der NodeConnection nc an
 /// </summary>
 /// <param name="nc">NodeConnection dessen ListNode zurückgegeben werden soll</param>
 /// <returns>_aListNode/_bListNode falls nc=_aConnection/nc=_bConnection, sonst Exception</returns>
 public LinkedListNode <Intersection> GetMyListNode(NodeConnection nc)
 {
     if (_aConnection == nc)
     {
         return(_aListNode);
     }
     else if (_bConnection == nc)
     {
         return(_bListNode);
     }
     else
     {
         throw new Exception();
     }
 }
コード例 #14
0
ファイル: MouseController.cs プロジェクト: Torppe/blob-wars
 private void SendUnitsTo(NodeConnection node)
 {
     if (selectedObjects.Count > 0)
     {
         foreach (GameObject movable in selectedObjects)
         {
             if (movable.TryGetComponent(out IMovable unit) &&
                 movable.TryGetComponent(out UnitController controller) &&
                 controller.currentNode != null)
             {
                 unit.MoveTo(controller.currentNode.GetComponent <Node>(), node.GetComponent <Node>());
             }
         }
     }
 }
コード例 #15
0
 public ChannelNodeNoticeHandler(
     NodeNotice notice,
     NodeConnection current,
     IConversationsNoticeService conversationsNoticeService,
     ICreateChannelsService createChannelsService,
     ILoadChannelsService loadChannelsService,
     ISystemMessagesService systemMessagesService)
 {
     this.notice  = (ChannelNodeNotice)notice;
     this.current = current;
     this.conversationsNoticeService = conversationsNoticeService;
     this.createChannelsService      = createChannelsService;
     this.loadChannelsService        = loadChannelsService;
     this.systemMessagesService      = systemMessagesService;
 }
コード例 #16
0
ファイル: baseRoom.cs プロジェクト: VN0/The-7th-Guest-Unity
    void enterRoom(NodeConnection nc)
    {
        RoomDestination rd;

        if (!roomDestinations.TryGetValue(nc.toPos[0].filename, out rd))
        {
            Debug.LogError("could not find room " + nc.toPos[0].filename);
            return;
        }
        Debug.Log("entering room " + rd.roomName);
        fmvman.QueueVideo(new FMVManager.Command {
            file = rd.fileName, type = FMVManager.CommandType.VIDEO, freezeFrame = true, fadeInTime = rd.fade?1:0
        });
        fmvman.SwitchRoom(rd.roomName, rd.node, rd.facing);
    }
コード例 #17
0
ファイル: Intersection.cs プロジェクト: brayan-schroeder/tcc
 /// <summary>
 /// Gibt Bogenlängenposition des Schnittpunktes an der NodeConnection nc an
 /// </summary>
 /// <param name="nc">NodeConnection dessen Bogenlängenposition zurückgegeben werden soll</param>
 /// <returns>aArcPosition/bArcPosition falls nc=_aConnection/nc=_bConnection, sonst Exception</returns>
 public double GetMyArcPosition(NodeConnection nc)
 {
     if (_aConnection == nc)
     {
         return(aArcPosition);
     }
     else if (_bConnection == nc)
     {
         return(bArcPosition);
     }
     else
     {
         throw new Exception();
     }
 }
コード例 #18
0
 public MessagesReadNoticeHandler(NodeNotice notice,
                                  NodeConnection current,
                                  IConversationsNoticeService conversationsNoticeService,
                                  IUpdateMessagesService updateMessagesService,
                                  IUpdateChatsService updateChatsService,
                                  ILoadDialogsService loadDialogsService,
                                  IUpdateChannelsService updateChannelsService)
 {
     this.notice  = (MessagesReadNodeNotice)notice;
     this.current = current;
     this.conversationsNoticeService = conversationsNoticeService;
     this.updateMessagesService      = updateMessagesService;
     this.updateChatsService         = updateChatsService;
     this.loadDialogsService         = loadDialogsService;
     this.updateChannelsService      = updateChannelsService;
 }
コード例 #19
0
 public AddUsersChatNoticeHandler(NodeNotice notice,
                                  NodeConnection node,
                                  IConversationsNoticeService conversationsNoticeService,
                                  IUpdateChatsService updateChatsService,
                                  INodeRequestSender nodeRequestSender,
                                  ICrossNodeService crossNodeService,
                                  ISystemMessagesService systemMessagesService)
 {
     this.notice = (AddUsersChatNodeNotice)notice;
     this.node   = node;
     this.conversationsNoticeService = conversationsNoticeService;
     this.updateChatsService         = updateChatsService;
     this.nodeRequestSender          = nodeRequestSender;
     this.crossNodeService           = crossNodeService;
     this.systemMessagesService      = systemMessagesService;
 }
コード例 #20
0
 public GetObjectsInfoNodeRequestHandler(NodeRequest request,
                                         NodeConnection nodeConnection,
                                         ILoadChatsService loadChatsService,
                                         ILoadUsersService loadUsersService,
                                         ILoadChannelsService loadChannelsService,
                                         IPrivacyService privacyService,
                                         IFilesService filesService)
 {
     this.request             = (GetObjectsInfoNodeRequest)request;
     this.nodeConnection      = nodeConnection;
     this.loadChatsService    = loadChatsService;
     this.loadUsersService    = loadUsersService;
     this.loadChannelsService = loadChannelsService;
     this.privacyService      = privacyService;
     this.filesService        = filesService;
 }
コード例 #21
0
        private void DrawcontrolButtons(NodeConnection connection, Rect rect)
        {
            var addButtonRect = rect;

            addButtonRect.yMin   = rect.yMin += 18;
            addButtonRect.xMin   = rect.width + 4;
            addButtonRect.width  = 24;
            addButtonRect.height = 14;
            if (connection.CanAddRule() && GUI.Button(addButtonRect, "+"))
            {
                var rule = connection.AddRule();
                rule.name = connection.fromNode.name + connection.toNode.name + "Rule_" + connection.rules.Count;
                AssetDatabase.AddObjectToAsset(rule, graph);
                graph.IsDirty = true;
            }
        }
コード例 #22
0
        public async Task <ChatVm> GetFullChatInformationAsync(long chatId, NodeConnection nodeConnection)
        {
            try
            {
                GetFullChatInformationNodeRequest request = new GetFullChatInformationNodeRequest(chatId);
                SendRequest(nodeConnection, request);
                ChatsNodeResponse response = (ChatsNodeResponse) await GetResponseAsync(request).ConfigureAwait(false);

                return(response.Chats.FirstOrDefault());
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex);
                return(null);
            }
        }
コード例 #23
0
 void Awake()
 {
     moneyManager   = GameObject.Find("GameManager").GetComponent <MoneyManager>();
     modeManager    = GameObject.Find("GameManager").GetComponent <ModeManager>();
     nodeConnection = GameObject.Find("GameManager").GetComponent <NodeConnection>();
     if (modeManager.mode == "Shop")
     {
         canMove = true;
         mode    = "Shop";
     }
     else if (modeManager.mode == "Constructor")
     {
         canMove = true;
         mode    = "Constructor";
     }
 }
コード例 #24
0
        /// <summary>
        /// Gets the connection region of the specified Node Connection
        /// </summary>
        /// <param name="connection">Node connection</param>
        /// <returns><see cref="Region"/> Connection Region</returns>
        public static Region GetConnectionRegion(NodeConnection connection)
        {
            NodeConnector to         = connection.To;
            NodeConnector from       = connection.From;
            RectangleF    toBounds   = to.Bounds;
            RectangleF    fromBounds = from.Bounds;
            float         x1         = (toBounds.Left + toBounds.Right) / 2.0f;
            float         y1         = (toBounds.Top + toBounds.Bottom) / 2.0f;
            float         x2         = (fromBounds.Left + fromBounds.Right) / 2.0f;
            float         y2         = (fromBounds.Top + fromBounds.Bottom) / 2.0f;
            Region        region;

            using (GraphicsPath linePath = GetLinePath(x1, y1, x2, y2, false, extra_thickness: 5.0f).Path)
                region = new Region(linePath);
            return(region);
        }
コード例 #25
0
        void Input_MouseUpOverPin(NodePin targetPin)
        {
            _targetPin = targetPin;

            if (ValidateConnection(targetPin) != ValidationResult.Valid)
            {
                NodeEditor.Logger.Log <NodeEditorPinConnector>(GetErrorMessage(ValidateConnection(targetPin)));
                return;
            }

            NodeEditor.Logger.Log <NodeEditorPinConnector>("Connecting pin '{0}' in '{1}' to '{2}' in '{3}'",
                                                           _sourcePin.Name,
                                                           _sourcePin.Node.Name,
                                                           targetPin.Name,
                                                           targetPin.Node.Name);

            NodeConnection connection = null;
            NodePin        startPin   = null;
            NodePin        endPin     = null;

            if (IsModifyingConnection())
            {
                startPin = _modifyingConnection.SourcePin;
            }
            else
            {
                startPin = _sourcePin;
            }

            endPin = targetPin;

            connection = new NodeConnection(startPin, endPin);

            if (IsModifyingConnection())
            {
                _graph.Replace(_modifyingConnection, connection);
            }
            else
            {
                _graph.Connect(connection);
            }

            _view.EndDrawState();

            _modifyingConnection = null;
            _sourcePin           = null;
        }
コード例 #26
0
        public async Task <ChannelDto> GetChannelInformationAsync(long channelId, NodeConnection nodeConnection)
        {
            try
            {
                GetObjectsInfoNodeRequest request = new GetObjectsInfoNodeRequest(new List <long> {
                    channelId
                }, null, Enums.NodeRequestType.GetChannels);
                SendRequest(nodeConnection, request);
                NodeResponse response = await GetResponseAsync(request).ConfigureAwait(false);

                return(((ChannelsNodeResponse)response).Channels.FirstOrDefault());
            }
            catch
            {
                return(null);
            }
        }
コード例 #27
0
        private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var rect   = sender as System.Windows.Shapes.Rectangle;
            var socket = rect.Tag as NodeSocket;

            if (isCreatingLink)
            {
                if (socket is InputNodeSocket)
                {
                    connection.Input = (InputNodeSocket)socket;
                }

                else if (socket is OutputNodeSocket)
                {
                    connection.Output = (OutputNodeSocket)socket;
                }

                connection.Input.Connections.Add(connection);
                connection.Output.Connections.Add(connection);

                displNodeGraph.Connections.Add(connection);

                startingRect.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White);

                isCreatingLink = false;
            }
            else
            {
                connection   = new NodeConnection();
                startingRect = rect;

                startingRect.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightBlue);

                if (socket is InputNodeSocket)
                {
                    connection.Input = (InputNodeSocket)socket;
                }

                else if (socket is OutputNodeSocket)
                {
                    connection.Output = (OutputNodeSocket)socket;
                }

                isCreatingLink = true;
            }
        }
コード例 #28
0
ファイル: Council.cs プロジェクト: HeleusCore/Heleus.Node
        public bool NewTransaction(Transaction transaction, NodeConnection connection)
        {
            if (transaction == null || transaction.TargetChainId != ChainId)
            {
                return(false);
            }

            if (_blockStorage.HistoryContainsTransactionOrRegistration(transaction) != TransactionResultTypes.Ok)
            {
                return(false);
            }

            lock (_lock)
            {
                if (_transactions.ContainsKey(transaction.UniqueIdentifier))
                {
                    return(false);
                }

                _transactions[transaction.UniqueIdentifier] = transaction;
            }

            // broadcast to other members, if it's not from a member
            if (connection == null)
            {
                _ = Broadcast(new NodeTransactionMessage(transaction, 0)
                {
                    SignKey = _node.NodeConfiguration.LocaleNodePrivateKey
                }, null);
            }
            else
            {
                lock (_lock)
                {
                    if (!_voteConnections.Contains(connection))
                    {
                        _ = Broadcast(new NodeTransactionMessage(transaction, 0)
                        {
                            SignKey = _node.NodeConfiguration.LocaleNodePrivateKey
                        }, connection.NodeInfo.NodeId);
                    }
                }
            }

            return(true);
        }
コード例 #29
0
 public EditChatsNoticeHandler(
     CommunicationObject @object,
     NodeConnection nodeConnection,
     INodeNoticeService nodeNoticeService,
     IConversationsNoticeService conversationsNoticeService,
     ILoadChatsService loadChatsService,
     ICrossNodeService crossNodeService,
     ISystemMessagesService systemMessagesService)
 {
     notice = (CreateOrEditChatsNodeNotice)@object;
     this.nodeConnection             = nodeConnection;
     this.nodeNoticeService          = nodeNoticeService;
     this.conversationsNoticeService = conversationsNoticeService;
     this.loadChatsService           = loadChatsService;
     this.crossNodeService           = crossNodeService;
     this.systemMessagesService      = systemMessagesService;
 }
コード例 #30
0
ファイル: baseRoom.cs プロジェクト: VN0/The-7th-Guest-Unity
    protected void OnClick(Vector2 pos, NodeConnection nc)
    {
        //Debug.Log("clicky! "+pos.ToString("0.00")+" from "+ currPos.node.ToString()+" "+ currPos.facing);
        if (fmvman.playlist.Count > 0)
        {
            //Debug.Log("speeeed boost! queue full");

            /*var p = fmvman.playing_videos;
             * foreach(var c in p)
             * {
             *  c.playbackSpeed = 4;
             *  if(c.player && c.player.GetComponent<UnityEngine.Video.VideoPlayer>())
             *  {
             *      c.player.GetComponent<UnityEngine.Video.VideoPlayer>().playbackSpeed = 4;
             *  }
             * }*/
            //return;
        }

        /*if(fmvman.playlist.Count > 3)
         * {
         *  Debug.Log("queue full!");
         *  return;
         * }*/

        //var nc = GetNodeConnection(pos);
        if (nc != null)
        {
            nc.timesClicked++;
            if (nc.toPos != null)
            {
                foreach (var f in nc.toPos)
                {
                    if (currPos != f)
                    {
                        Travel(f, nc.speed);
                    }
                }
            }
            if (nc.callback != null)
            {
                nc.callback(nc);
            }
        }
    }
コード例 #31
0
ファイル: Dungeon.cs プロジェクト: guipaz/taurum
        public bool Connect(Room adjacent)
        {
            List <NodeExit> curExits = AvailableExits;
            List <NodeExit> adjExits = adjacent.AvailableExits;

            NodeExit curChosen = null;
            NodeExit adjChosen = null;
            int      quality   = 0;

            foreach (NodeExit v1 in curExits)
            {
                foreach (NodeExit v2 in adjExits)
                {
                    int q = 0; // bad
                    if (v1.GetOpposite() == v2.direction)
                    {
                        q = 2; // good
                    }
                    else if (v1.direction != v2.direction)
                    {
                        q = 1; // ok
                    }

                    if (curChosen == null || q > quality)
                    {
                        curChosen = v1;
                        adjChosen = v2;
                        quality   = q;
                    }
                }
            }

            if (curChosen != null && adjChosen != null)
            {
                NodeConnection c1 = new NodeConnection(adjacent, adjChosen);
                connections[curChosen] = c1;

                NodeConnection c2 = new NodeConnection(this, curChosen);
                adjacent.connections[adjChosen] = c2;

                return(true);
            }

            return(false);
        }
コード例 #32
0
        private void DrawRules(NodeConnection connection, TransitionRule rule)
        {
            Rect rect = EditorGUILayout.BeginHorizontal();

            var variableNames        = graph.variables.Select(x => x.name).ToArray();
            var currentVariableIndex = Array.IndexOf(variableNames, rule.Variable.name);
            var variableIndex        = EditorGUILayout.Popup(currentVariableIndex, variableNames);

            if (variableIndex != currentVariableIndex)
            {
                rule.Variable = graph.variables[variableIndex];
                // rule.VariableName = rule.Variable.name;
            }
            switch (rule.Variable.VariableType)
            {
            case VariableType.Trigger:
                rule.Qualifier       = Qualifier.Equal;
                rule.QualifierIntVal = 1;
                break;

            case VariableType.Boolean:
                rule.QualifierBoolEnum = (TrueFalse)EditorGUILayout.EnumPopup(rule.QualifierBoolEnum);
                rule.QualifierIntVal   = (int)rule.QualifierBoolEnum;
                rule.Qualifier         = Qualifier.Equal;
                break;

            case VariableType.Float:
                rule.Qualifier         = (Qualifier)EditorGUILayout.EnumPopup(rule.Qualifier);
                rule.QualifierFloatVal = EditorGUILayout.FloatField(rule.QualifierFloatVal);
                break;

            case VariableType.Integer:
                rule.Qualifier       = (Qualifier)EditorGUILayout.EnumPopup(rule.Qualifier);
                rule.QualifierIntVal = EditorGUILayout.IntField(rule.QualifierIntVal);
                break;
            }

            if (GUILayout.Button("x", EditorStyles.miniButton, GUILayout.Width(23)) && ConfirmRemoveRule())
            {
                connection.RemoveRule(rule);
                return;
            }

            EditorGUILayout.EndHorizontal();
        }
コード例 #33
0
        private void stopOutgoingConnection()
        {
            int port = Properties.Settings.Default.PortNumber;

            if (!Properties.Settings.Default.RunAsService)
            {
                port = 0;
            }
            if (port != m_port)
            {
                if (m_port > 0 && m_outgoingConnection != null)
                {
                    // stop existing connection
                    m_outgoingConnection.Close();
                    m_outgoingConnection = null;
                }
            }
        }
コード例 #34
0
ファイル: Council.cs プロジェクト: HeleusCore/Heleus.Node
        public void AddVoteNodeConnection(NodeConnection connection)
        {
            lock (_lock)
            {
                _voteConnections.Add(connection);
            }

            // force sync
            var blockData = _blockStorage.LastBlockData;

            if (blockData != null)
            {
                _ = connection.Send(new NodeBlockDataMessage(blockData.ChainType, blockData.BlockId, blockData.ChainId, blockData.ChainIndex, blockData)
                {
                    SignKey = _node.NodeConfiguration.LocaleNodePrivateKey
                });
            }
        }
コード例 #35
0
 void checkForAttachment()
 {
     if (Vector2.Distance(grabPosition, Input.mousePosition) > 100f || Time.time > grabStartingTime + 0.5f){
         List<NodeConnection> connections = GameManager.getInstance().nodeConnections;
         foreach (NodeConnection nc in connections) {
             Vector2 thisPosition = this.transform.position;
             Vector2 nodePosition = nc.transform.position;
             float dist = Vector2.Distance(thisPosition, nodePosition);
             if (dist < 1.5f && !nc.isConnected) {
                 SoundManager.getInstance().playSoundEffect("Blood");
                 preConnectionRotation = this.transform.rotation;
                 isConnected = true;
                 nc.connectWithRope(this);
                 activeNodeConnection = nc;
                 EventManager.instance.TriggerEvent(new NodeConnectionsChangedEvent());
                 break;
             }
         }
     }
 }
コード例 #36
0
ファイル: ShipPositionMarker.cs プロジェクト: ullizei/pirates
    private IEnumerator TravelToPortRoutine(MapNode newPort, NodeConnection connection)
    {
        float cameraLerpTime = CameraControl.Instance.LerpToPosition(_transform.position);
        yield return new WaitForSeconds(cameraLerpTime+0.1f);

        SoundManager.PlaySfx(Sfx.Wave);

        CR_Spline crSpline = connection.GetCRSpline(newPort);
        float travelTime = 1.25f;
        float elapsedTime = 0f;

        Vector3 pos;
        while (elapsedTime < travelTime)
        {
            pos = crSpline.Interp(elapsedTime/travelTime);
            pos.z = _transform.position.z;
            _transform.position = pos;
            CameraControl.Instance.MoveToPosition(pos);
            yield return null;
            elapsedTime += Time.smoothDeltaTime;
        }

        currentPort = newPort;
    }
コード例 #37
0
ファイル: Navigation.cs プロジェクト: EraYaN/MiDeRP
 public void recalculatePath()
 {
     currentPos = currentPos.Flipped;
     if (Data.challenge == Challenge.FindPath)
     {
         makePaths();
     }
     else if (Data.challenge == Challenge.FindTreasure)
     {
         findTreasure();
     }
     else
     {
         throw new ArgumentException("Invalid challenge...");
     }
 }
コード例 #38
0
 /// <summary>
 /// Prüfe, ob ich auf der NodeConnection nc fahren darf
 /// </summary>
 /// <param name="nc">zu prüfende NodeConnection</param>
 /// <returns>true, wenn ich auf nc fahren darf, sonst false</returns>
 public abstract bool CheckNodeConnectionForSuitability(NodeConnection nc);
コード例 #39
0
ファイル: Car.cs プロジェクト: chenysh/CTS-Develop
 /// <summary>
 /// Prüfe, ob ich auf der NodeConnection nc fahren darf
 /// </summary>
 /// <param name="nc">zu prüfende NodeConnection</param>
 /// <returns>nc.carsAllowed</returns>
 public override bool CheckNodeConnectionForSuitability(NodeConnection nc)
 {
     return nc.carsAllowed;
 }
コード例 #40
0
 public void Foo5()
 {
     var f = new NodeConnection("", "", false);
 }
コード例 #41
0
 public void DrawNodeConnection(NodeConnection connection)
 {
     object renderer = Nodify.Editor.NodifyEditorUtilities.FindAnchorRenderer(connection.owner.GetType());
     renderer.GetType().GetMethod("OnRenderNodeConnection").Invoke(renderer, new object[] { connection.owner, connection });
 }
コード例 #42
0
        /// <summary>
        /// Returns the next vehicle on the given Nodeconnection together with the distance to its rear end.
        /// </summary>
        /// <param name="nc">NodeConnection where to start with search</param>
        /// <param name="arcPos">Arc position on given Nodeconnection.</param>
        /// <param name="distance">Distance to cover during search.</param>
        /// <returns>The closest vehicle and its distance to the rear end, null if no such vehicle exists.</returns>
        private VehicleDistance GetNextVehicleOnMyTrack(NodeConnection nc, double arcPos, double distance)
        {
            VehicleDistance toReturn = null;

            // the beginning of a NodeConnection may be close to other connections - search on each of them
            double arcLengthToLookForParallelVehicles = 1.0 * nc.startNode.outSlope.Abs; // search distance on parallel connections
            foreach (NodeConnection parallelNodeConnection in nc.startNode.nextConnections)
                {
                VehicleDistance vd = parallelNodeConnection.GetVehicleBehindArcPosition(arcPos, distance);
                if (vd != null && vd.distance > 0)
                    {
                    vd.distance -= vd.vehicle.length;

                    if (   (toReturn == null || vd.distance < toReturn.distance)
                        && (parallelNodeConnection == nc || (arcPos < arcLengthToLookForParallelVehicles && vd.distance < arcLengthToLookForParallelVehicles)))
                        {
                        toReturn = vd;
                        }
                    }
                }

            return toReturn;
        }
コード例 #43
0
        /// <summary>
        /// Initiiert einen Spurwechsel
        /// </summary>
        /// <param name="lcp">LCP auf dem der Spurwechsel durchgeführt werden soll</param>
        /// <param name="arcPositionOffset">bereits auf dem LCP zurückgelegte Strecke</param>
        private void InitiateLineChange(NodeConnection.LineChangePoint lcp, double arcPositionOffset)
        {
            // einem evtl. ausgebremsten Fahrzeug sagen, dass es nicht mehr extra für mich abbremsen braucht
            _state.UnsetLineChangeVehicleInteraction();

            // unregister at all intersections
            foreach (SpecificIntersection si in registeredIntersections)
                {
                si.intersection.UnregisterVehicle(this, si.nodeConnection);
                }
            registeredIntersections.Clear();

            // sich merken, dass das IVehicle gerade am Spurwechseln ist
            currentlyChangingLine = true;
            currentLineChangePoint = lcp;
            currentPositionOnLineChangePoint = arcPositionOffset;
            if (lcp.target.nc == lcp.otherStart.nc)
                {
                ratioProjectionOnTargetConnectionvsLCPLength = (lcp.target.arcPosition - lcp.otherStart.arcPosition) / lcp.lineSegment.length;
                }
            else
                {
                ratioProjectionOnTargetConnectionvsLCPLength = (lcp.target.arcPosition + lcp.otherStart.nc.lineSegment.length - lcp.otherStart.arcPosition) / lcp.lineSegment.length;
                }

            // Neuen State schonmal auf die ZielNodeConnection setzen (currentNodeConnection, currentPosition)
            RemoveFromCurrentNodeConnection(true, lcp.otherStart.nc, lcp.otherStart.arcPosition + arcPositionOffset * ratioProjectionOnTargetConnectionvsLCPLength);
            _wayToGo = Routing.CalculateShortestConenction(currentNodeConnection.endNode, targetNodes, _vehicleType);

            _statistics.numLineChanges++;
            lineChangeNeeded = false;
            lci = null;
        }
コード例 #44
0
        /// <summary>
        /// To be called when this vehicle shall be removed from the current NodeConnection
        /// </summary>
        /// <param name="logConnectionStatistics">Flag, whether NodeConnection statistics shall be logged</param>
        /// <param name="nextConnection">NodeConnection where to respawn vehicle - set to null if vehicle shall not respawn</param>
        /// <param name="nextArcPosition">arc position on nextConnection where vehicle shall respawn</param>
        private void RemoveFromCurrentNodeConnection(bool logConnectionStatistics, NodeConnection nextConnection, double nextArcPosition)
        {
            _state.UnsetLineChangeVehicleInteraction();

            if (logConnectionStatistics)
                {
                OnVehicleLeftNodeConnection(new VehicleLeftNodeConnectionEventArgs(new Interval<double>(statistics.arcPositionOfStartOnNodeConnection, currentPosition), new Interval<double>(statistics.startTimeOnNodeConnection, GlobalTime.Instance.currentTime)));
                }
            currentNodeConnection.RemoveVehicle(this);

            if (nextConnection != null)
                {
                double pos = Math.Min(nextConnection.lineSegment.length, nextArcPosition);
                if (pos < nextArcPosition)
                    {
                    // FIXME: this sometimes happens, even if it should not!
                    }

                lastLineChangeCheck.Right -= currentNodeConnection.lineSegment.length;

                // update statistics
                _statistics.totalMilage += currentPosition - statistics.arcPositionOfStartOnNodeConnection;
                _statistics.numNodeConnections++;
                _statistics.arcPositionOfStartOnNodeConnection = pos;
                _statistics.startTimeOnNodeConnection = GlobalTime.Instance.currentTime;

                // set new state
                _state = new State(nextConnection, pos);

                // add vehicle to new node connection
                nextConnection.AddVehicleAt(this, pos);
                }
            else
                {
                // evoke VehicleDied event
                OnVehicleDied(new VehicleDiedEventArgs(_statistics, targetNodes.Contains(currentNodeConnection.endNode)));
                }
        }
コード例 #45
0
 /// <summary>
 /// Konstruktor, der nur die Position initialisiert. Der Rest ist uninitialisiert!
 /// </summary>
 /// <param name="p">Zeitposition auf der Linie</param>
 public State(double p)
 {
     currentNodeConnection = null;
     m_Position = p;
     m_PositionAbs = null;
     m_Orientation = null;
     m_letVehicleChangeLine = false;
     m_tailPositionOfOtherVehicle = 0;
     m_vehicleThatLetsMeChangeLine = null;
     m_vehicleToChangeLine = null;
     _freeDrive = true;
 }
コード例 #46
0
            /// <summary>
            /// Standardkonstruktor, benötigt eine Nodeconnection und Zeitposition. Der Rest wird intern berechnet
            /// </summary>
            /// <param name="nc">aktuelle NodeConnection</param>
            /// <param name="p">Zeitposition auf nc</param>
            public State(NodeConnection nc, double p)
            {
                currentNodeConnection = nc;
                m_Position = p;

                double t = currentNodeConnection.lineSegment.PosToTime(p);
                m_PositionAbs = currentNodeConnection.lineSegment.AtTime(t);
                m_Orientation = currentNodeConnection.lineSegment.DerivateAtTime(t);
                m_letVehicleChangeLine = false;
                m_tailPositionOfOtherVehicle = 0;
                m_vehicleThatLetsMeChangeLine = null;
                m_vehicleToChangeLine = null;
                _freeDrive = true;
            }
コード例 #47
0
            /// <summary>
            /// Sets the LineChangeVehicleInteraction: otherVehicle will be told to wait for me to change line. Therefore, it will try to keep behind myTailPositionOnTargetConnection.
            /// </summary>
            /// <param name="lineChangingVehicle">vehicle, that wants to change line</param>
            /// <param name="otherVehicle">vehicle on the target connection, that will wait for me to change line</param>
            /// <param name="targetConnection">Target NodeConnection</param>
            /// <param name="myTailPositionOnTargetConnection">My projected tail position on targetConnection. otherVehicle will try to keep behind this arc position.</param>
            public void SetLineChangeVehicleInteraction(IVehicle lineChangingVehicle, IVehicle otherVehicle, NodeConnection targetConnection, double myTailPositionOnTargetConnection)
            {
                UnsetLineChangeVehicleInteraction();

                if (otherVehicle.currentNodeConnection == targetConnection && myTailPositionOnTargetConnection >= 0)
                    {
                    // Make sure that no two LineChangeVehicleInteractions cross each other:
                    // Therefore, we here check die vehicles on the two NodeConnections of the LineChangePoint. This simplifies the algorithm and should be enough here.
                    LinkedListNode<IVehicle> myNode = lineChangingVehicle.listNode.Previous;
                    while (myNode != null)
                        {
                        // we have found a vehicle (call it vehicle B) behind me waiting for another vehicle (call it vehicle C) changing line
                        if (myNode.Value._state.letVehicleChangeLine)
                            {
                            // check whether vehicle C is in front of the vehicle, that will wait for me
                            if (myNode.Value._state.vehicleToChangeLine.currentPosition > otherVehicle.currentPosition)
                                {
                                // We have found two LineChangeVehicleInteraction crossing each other. To solve the problem, simply let vehicle C wait for me.
                                otherVehicle = myNode.Value._state.vehicleToChangeLine;
                                break;
                                }
                            }
                        myNode = myNode.Previous;
                        }

                    m_vehicleThatLetsMeChangeLine = otherVehicle;
                    otherVehicle._state.m_letVehicleChangeLine = true;
                    otherVehicle._state.m_tailPositionOfOtherVehicle = myTailPositionOnTargetConnection;
                    otherVehicle._state.m_vehicleToChangeLine = lineChangingVehicle;
                    }
                else
                    {
                    // TODO: think about s.th. clever to do in this case. :)
                    }
            }
コード例 #48
0
ファイル: Navigation.cs プロジェクト: EraYaN/MiDeRP
        private void addAllNodeConnections(uint xlim, uint ylim)
        {
            for (uint x = 0; x < xlim; x++)
            {
                for (uint y = 0; y < ylim; y++)
                {
                    Coord N1 = new Coord();
                    Coord N2 = new Coord();
                    NodeConnection ml = new NodeConnection();
                    N1.X = x;
                    N1.Y = y;
                    N2.X = x;
                    N2.Y = y;
                    if (xlim == Data.M && ylim != Data.N)
                        N2.Y++;
                    else
                        N2.X++;
                    ml.To = N1;
                    ml.From = N2;
                    Data.ctr.treasureSearchList.Add(ml);
                }

            }
        }
コード例 #49
0
ファイル: Navigation.cs プロジェクト: EraYaN/MiDeRP
        public void getNextAxis()
        {
            const int notvisitedscore = 10, visitedpenalty = 6, turnpenalty = 20, fullturnpenalty = 24, minepenalty = 999;
            int i, score = -999, temp_score, length = 0;
            Direction nextdir = Direction.Unknown, currentdir;
            NodeConnection currentnodeconnection = currentPos;
            Coord to = currentPos.To;

            for (i = 0; i < 4; i++)
            {
                currentdir = (Direction)i;
                temp_score = 0;

                //Add score for longer possible path
                if (currentdir == Direction.Left)
                    length = (int)currentPos.To.X;
                else if (currentdir == Direction.Right)
                    length = (int)Data.M - 1 - (int)currentPos.To.X;
                else if (currentdir == Direction.Up)
                    length = (int)Data.N - 1 - (int)currentPos.To.Y;
                else if (currentdir == Direction.Down)
                    length = (int)currentPos.To.Y;

                if (length == 0)
                    continue;

                //Subtract score for any mines and visited nodes
                if (currentdir == Direction.Left)
                    currentnodeconnection = new NodeConnection(new Coord(currentPos.To.X, currentPos.To.Y), new Coord(currentPos.To.X - 1, currentPos.To.Y));
                else if (currentdir == Direction.Right)
                    currentnodeconnection = new NodeConnection(new Coord(currentPos.To.X, currentPos.To.Y), new Coord(currentPos.To.X + 1, currentPos.To.Y));
                else if (currentdir == Direction.Up)
                    currentnodeconnection = new NodeConnection(new Coord(currentPos.To.X, currentPos.To.Y ), new Coord(currentPos.To.X , currentPos.To.Y + 1));
                else if (currentdir == Direction.Down)
                    currentnodeconnection = new NodeConnection(new Coord(currentPos.To.X, currentPos.To.Y), new Coord(currentPos.To.X, currentPos.To.Y - 1));

                if (visited.Contains(currentnodeconnection) || visited.Contains(currentnodeconnection.Flipped))
                    temp_score -= (visitedpenalty * ((int)Data.M - length) + (visited.IndexOf(currentnodeconnection) / 6));
                if (mines.Contains(currentnodeconnection) || mines.Contains(currentnodeconnection.Flipped))
                    temp_score -= minepenalty;
                if (!(visited.Contains(currentnodeconnection) || visited.Contains(currentnodeconnection.Flipped)))
                    temp_score += notvisitedscore;

                //Substract for making a turn
                if (currentdir != Data.ctr.RobotDirection)
                    temp_score -= turnpenalty;

                //Substract for making a full turn
                if (((int)currentdir + 2) % 4 == (int)Data.ctr.RobotDirection)
                    temp_score -= fullturnpenalty;

                //Is this path better?
                if (temp_score >= score)
                {
                    score = temp_score;
                    nextdir = currentdir;
                }
            }

            if (nextdir == Direction.Left)
            {
                to = new Coord(currentPos.To.X - 1, currentPos.To.Y);
            }
            else if (nextdir == Direction.Right)
            {
                to = new Coord(currentPos.To.X + 1, currentPos.To.Y);
            }
            else if (nextdir == Direction.Up)
            {
                to = new Coord(currentPos.To.X, currentPos.To.Y + 1);
            }
            else if (nextdir == Direction.Down)
            {
                to = new Coord(currentPos.To.X, currentPos.To.Y - 1);
            }

            fullPath = getPath(currentPos.To, to);
        }
コード例 #50
0
ファイル: GraphUtils.cs プロジェクト: idursun/StateMachines
    public static Region GetConnectionRegion(NodeConnection connection)
    {
        var to		= connection.To;
        var from	= connection.From;
        RectangleF toBounds = to.bounds;
        RectangleF fromBounds = @from.bounds;

        var x1 = (fromBounds.Left + fromBounds.Right) / 2.0f;
        var y1 = (fromBounds.Top + fromBounds.Bottom) / 2.0f;
        var x2 = (toBounds.Left + toBounds.Right) / 2.0f;
        var y2 = (toBounds.Top + toBounds.Bottom) / 2.0f;

        Region region;
        using (var linePath = GetArrowLinePath(	x1, y1, x2, y2, true, 5.0f))
        {
            region = new Region(linePath);
        }
        return region;
    }
コード例 #51
0
    void CreateConnectionIfValid(List<NodeConnection> list, Node nodeFrom, Node nodeTo)
    {
        if (nodeTo.Weight < Single.MaxValue)
        {
            var conn = new NodeConnection
            {
                // 1.4 for diagonals and 1 for horizontal or vertical connections
                Cost = nodeFrom.coord.x == nodeTo.coord.x || nodeFrom.coord.y == nodeTo.coord.y ? 1 : 1.4f,
                From = nodeFrom,
                To = nodeTo,
            };

            list.Add(conn);
        }
    }
コード例 #52
0
 void disconnect()
 {
     isConnected = false;
     rigidbody.isKinematic = false;
     if (activeNodeConnection != null){
         activeNodeConnection.disconnectRope();
         this.transform.rotation = preConnectionRotation;
         EventManager.instance.TriggerEvent(new NodeConnectionsChangedEvent());
         SoundManager.getInstance().playSoundEffect("squish");
     }
     activeNodeConnection = null;
 }
コード例 #53
0
ファイル: Story.cs プロジェクト: microVoltage/NB-N
    public static bool IsNodeBetweenConnection(CompoundIndex nodeIndex, NodeConnection nodeConnection)
    {
        if (nodeIndex.treeIndex != nodeConnection.treeIndex) {
            return false;
        }

        int[] path = forest.trees[nodeIndex.treeIndex].FindPath(
            nodeConnection.startNodeIndex,
            nodeConnection.endNodeIndex);

        foreach (var node in path) {
            if (node == nodeIndex.nodeIndex) {
                return true;
            }
        }

        return false;
    }
コード例 #54
0
ファイル: Task.cs プロジェクト: webconfig/Design
 /// <summary>
 /// ���һ������
 /// </summary>
 /// <param name="Conn"></param>
 public void AddNodeConnection(NodeConnection Conn, bool addtodata)
 {
     OutgoingNodeConnections.Add(Conn);
     if (addtodata)
     {
         Childs.Add(Conn.DestinationNodeDesigner);
     }
 }
コード例 #55
0
ファイル: Visualization.cs プロジェクト: EraYaN/MiDeRP
 void mine_MouseUp(object sender, MouseButtonEventArgs e)
 {
     Ellipse circle = (Ellipse)e.OriginalSource;
     NodeConnection ml = Data.GetMineLocation(circle);
     NodeConnection ml2 = new NodeConnection(ml.From, ml.To);
     if (e.ChangedButton == MouseButton.Left)
     {
         if (Data.nav.mines.Contains(ml))
         {
             Data.nav.mines.Remove(ml);
         }
         else
         {
             Data.nav.mines.Add(ml);
         }
         Data.db.UpdateProperty("MineCount");
     }
     else if(e.ChangedButton == MouseButton.Right)
     {
         if (Data.nav.currentPos == ml)
         {
             Data.nav.currentPos = ml2;
         }
         else
         {
             Data.nav.currentPos = ml;
         }
         Data.db.UpdateProperty("CurrentPosText");
     }
     Data.vis.DrawField();
 }
コード例 #56
0
ファイル: Task.cs プロジェクト: webconfig/Design
 /// <summary>
 ///�Ƴ�һ������
 /// </summary>
 /// <param name="conn"></param>
 public void RemoveConnection(NodeConnection conn)
 {
     OutgoingNodeConnections.Remove(conn);
     Childs.Remove(conn.DestinationNodeDesigner);
 }
コード例 #57
0
 internal static void SendAsync(NodeConnection nodeConnection, string inventoryVectorHex)
 {
     SQLiteAsyncConnection conn = nodeConnection.Bitmessage.DB;
     var query = conn.Table<Payload>().Where(inv => inv.InventoryVectorHex == inventoryVectorHex);
     query.FirstOrDefaultAsync().ContinueWith(t =>
                                                  {
                                                      if (t.Result != null)
                                                          nodeConnection.Send(t.Result);
                                                  });
 }
コード例 #58
0
ファイル: Task.cs プロジェクト: webconfig/Design
 /// <summary>
 /// ���һ������
 /// </summary>
 /// <param name="childNodeDesigner"></param>
 /// <param name="nodeConnection"></param>
 public void AddConnection(Task child, NodeConnection Connection, bool addtodata)
 {
     child.InConnections.Add(Connection);
     Connection.DestinationNodeDesigner = child;
     Connection.Originating.AddNodeConnection(Connection, addtodata);
 }
コード例 #59
0
ファイル: Navigation.cs プロジェクト: EraYaN/MiDeRP
        public List<NodeConnection> getPath(Coord entry, Coord exit)
        {
            setMinesInDLL();
            int res = updatePath(entry.Id, exit.Id);
            if (res != 0)
                throw new ArgumentException("No path found");

               		List<NodeConnection> path = new List<NodeConnection>();
            uint len = getPathLength();
            IntPtr ptr = Marshal.AllocHGlobal(((int)len+1)*sizeof(int));
            int[] stage1 = new int[len+1];
            res = extractPath(ptr);

            if (res == 0 && len > 0 && ptr != null)
            {
                Marshal.Copy(ptr, stage1, 0, (int)len + 1);
                Marshal.FreeHGlobal(ptr);
                List<Coord> stage2 = new List<Coord>(); //node's
                for (int i = 0; i < len + 1; i++)
                {
                    Coord c = new Coord();
                    c.Id = (uint)stage1[i];
                    stage2.Add(c);
                }
                Coord? prev = null;
                foreach (Coord c in stage2)
                {
                    if (prev == null)
                    {
                        prev = c;
                    }
                    else
                    {
                        NodeConnection nc = new NodeConnection((Coord)c, (Coord)prev);
                        path.Add(nc);
                        prev = c;
                    }
                }
                if (Data.challenge == Challenge.FindPath)
                {
                    if (currentPath > 0)
                        path.Insert(0, new NodeConnection(new Coord(targetCPs[(int)(currentPath - 1)]), false));
                    path.Add(new NodeConnection(new Coord(currentExitCP), true));
                }
            }
             //Update UI
            Data.db.UpdateProperty("PathLength");
            Data.db.UpdateProperty("MineCount");
            Data.db.UpdateProperty("CurrentPosText");
            return path;
        }
コード例 #60
0
 /// <summary>
 /// verbleibende bogenlängenentfernung bis zum Ende der NodeConnection
 /// </summary>
 /// <param name="currentNC">NodeConnection für die die Beschleunigungswerte berechnet werden sollen</param>
 /// <param name="arcPos">Position auf currentNC für die die Beschleunigungswerte berechnet werden sollen</param>
 /// <returns>currentNC.lineSegment.length - arcPos</returns>
 public double GetDistanceToEndOfLineSegment(NodeConnection currentNC, double arcPos)
 {
     return currentNC.lineSegment.length - arcPos;
 }