public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node) { node = (MethodDeclarationSyntax)base.VisitMethodDeclaration(node); var attributes = node.AttributeLists.ToString(); if (attributes.Contains("[DllImport(")) { if (attributes.Contains("[DllImport(\"\"")) { return(null); } var methodName = node.Identifier.ValueText; if (this.parent.namesToNamespaces.TryGetValue(methodName, out var requiredNamespace)) { var currentNamespace = GetEnclosingNamespace(node); if (requiredNamespace != currentNamespace) { if (!this.namespaceToMovedData.TryGetValue(requiredNamespace, out var movedData)) { movedData = new MovedData(); this.namespaceToMovedData[requiredNamespace] = movedData; } movedData.Methods.Add(node); return(null); } } } return(node); }
// Respond to a moved message in sent to this client // The player in this client will issue a moved message to the server when it moves private void process(MovedData moved) { if (moved == null) return; // IF We get back our own moved message do nothing if (moved.playerID == playerData.playerID) return; else { // Another player has moved so we find the component associated with the player id // and we PlayerData other = otherPlayers.FirstOrDefault(p => p.playerID == moved.playerID); if(other != null) { // Update this client's copy of the other's data other.X = moved.toX; other.Y = moved.toY; // Find the component that correspond to the player Id coming in var OtherPlayers = Game.Components.Where(o => o.GetType() == typeof(OtherPlayer)).ToList(); foreach (OtherPlayer p in OtherPlayers) { if (p.playerData.playerID == moved.playerID) { p.playerData.X = moved.toX; p.playerData.Y = moved.toY; p.Position = new Vector2(playerData.X, playerData.Y); } } } } }
private SyntaxNode VisitDeclarationSyntax(MemberDeclarationSyntax node, string name) { if (this.parent.namesToNamespaces.TryGetValue(name, out var requiredNamespace)) { var currentNamespace = GetEnclosingNamespace(node); if (requiredNamespace != currentNamespace) { if (!this.namespaceToMovedData.TryGetValue(requiredNamespace, out var movedData)) { movedData = new MovedData(); this.namespaceToMovedData[requiredNamespace] = movedData; } movedData.Others.Add(node); return(null); } } return(node); }
private static void process(MovedData movedData) { if (movedData == null) { return; } // Update the player position on the server PlayerData player = Players.First(p => p.playerID == movedData.playerID); player.X = movedData.toX; player.Y = movedData.toY; // Tell all the clients the new position DataHandler.sendNetMess <MovedData>(server, new MovedData { playerID = movedData.playerID, toX = movedData.toX, toY = movedData.toY }, SENT.TOALL); }