• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IRemoteClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IRemoteClient的典型用法代码示例。如果您正苦于以下问题:C# IRemoteClient类的具体用法?C# IRemoteClient怎么用?C# IRemoteClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IRemoteClient类属于命名空间,在下文中一共展示了IRemoteClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: HandleLoginRequestPacket

        public static void HandleLoginRequestPacket(IPacket packet, IRemoteClient client, IMultiplayerServer server)
        {
            var loginRequestPacket = (LoginRequestPacket)packet;
            var remoteClient = (RemoteClient)client;
            if (loginRequestPacket.ProtocolVersion < server.PacketReader.ProtocolVersion)
                remoteClient.QueuePacket(new DisconnectPacket("Client outdated! Use beta 1.7.3."));
            else if (loginRequestPacket.ProtocolVersion > server.PacketReader.ProtocolVersion)
                remoteClient.QueuePacket(new DisconnectPacket("Server outdated! Use beta 1.7.3."));
            else if (server.Worlds.Count == 0)
                remoteClient.QueuePacket(new DisconnectPacket("Server has no worlds configured."));
            else if (!server.PlayerIsWhitelisted(remoteClient.Username) && server.PlayerIsBlacklisted(remoteClient.Username))
                remoteClient.QueuePacket(new DisconnectPacket("You're banned from this server"));
            else if (server.Clients.Count(c => c.Username == client.Username) > 1)
                remoteClient.QueuePacket(new DisconnectPacket("The player with this username is already logged in"));
            else
            {
                remoteClient.LoggedIn = true;
                remoteClient.Entity = new PlayerEntity(remoteClient.Username);
                remoteClient.World = server.Worlds[0];
                remoteClient.ChunkRadius = 2;

                if (!remoteClient.Load())
                    remoteClient.Entity.Position = remoteClient.World.SpawnPoint;
                // Make sure they don't spawn in the ground
                var collision = new Func<bool>(() =>
                {
                    var feet = client.World.GetBlockID((Coordinates3D)client.Entity.Position);
                    var head = client.World.GetBlockID((Coordinates3D)(client.Entity.Position + Vector3.Up));
                    var feetBox = server.BlockRepository.GetBlockProvider(feet).BoundingBox;
                    var headBox = server.BlockRepository.GetBlockProvider(head).BoundingBox;
                    return feetBox != null || headBox != null;
                });
                while (collision())
                    client.Entity.Position += Vector3.Up;

                // Send setup packets
                remoteClient.QueuePacket(new LoginResponsePacket(0, 0, Dimension.Overworld));
                remoteClient.UpdateChunks();
                remoteClient.QueuePacket(new WindowItemsPacket(0, remoteClient.Inventory.GetSlots()));
                remoteClient.QueuePacket(new SpawnPositionPacket((int)remoteClient.Entity.Position.X,
                        (int)remoteClient.Entity.Position.Y, (int)remoteClient.Entity.Position.Z));
                remoteClient.QueuePacket(new SetPlayerPositionPacket(remoteClient.Entity.Position.X,
                        remoteClient.Entity.Position.Y + 1,
                        remoteClient.Entity.Position.Y + remoteClient.Entity.Size.Height + 1,
                        remoteClient.Entity.Position.Z, remoteClient.Entity.Yaw, remoteClient.Entity.Pitch, true));
                remoteClient.QueuePacket(new TimeUpdatePacket(remoteClient.World.Time));

                // Start housekeeping for this client
                var entityManager = server.GetEntityManagerForWorld(remoteClient.World);
                entityManager.SpawnEntity(remoteClient.Entity);
                entityManager.SendEntitiesToClient(remoteClient);
                server.Scheduler.ScheduleEvent("remote.keepalive", remoteClient, TimeSpan.FromSeconds(10), remoteClient.SendKeepAlive);
                server.Scheduler.ScheduleEvent("remote.chunks", remoteClient, TimeSpan.FromSeconds(1), remoteClient.ExpandChunkRadius);

                if (!string.IsNullOrEmpty(Program.ServerConfiguration.MOTD))
                    remoteClient.SendMessage(Program.ServerConfiguration.MOTD);
                if (!Program.ServerConfiguration.Singleplayer)
                    server.SendMessage(ChatColor.Yellow + "{0} joined the server.", remoteClient.Username);
            }
        }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:60,代码来源:LoginHandlers.cs


示例2: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     var bottom = coordinates + MathHelper.BlockFaceToCoordinates(face);
     var top = bottom + Coordinates3D.Up;
     if (world.GetBlockID(top) != 0 || world.GetBlockID(bottom) != 0)
         return;
     DoorFlags direction;
     switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
     {
         case Direction.North:
             direction = DoorFlags.Northwest;
             break;
         case Direction.South:
             direction = DoorFlags.Southeast;
             break;
         case Direction.East:
             direction = DoorFlags.Northeast;
             break;
         default: // Direction.West:
             direction = DoorFlags.Southwest;
             break;
     }
     user.Server.BlockUpdatesEnabled = false;
     world.SetBlockID(bottom, BlockID);
     world.SetMetadata(bottom, (byte)direction);
     world.SetBlockID(top, BlockID);
     world.SetMetadata(top, (byte)(direction | DoorFlags.Upper));
     user.Server.BlockUpdatesEnabled = true;
     item.Count--;
     user.Inventory[user.SelectedSlot] = item;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:31,代码来源:DoorItem.cs


示例3: HandleHandshakePacket

 public static void HandleHandshakePacket(IPacket packet, IRemoteClient client, IMultiplayerServer server)
 {
     var handshakePacket = (HandshakePacket) packet;
     var remoteClient = (RemoteClient)client;
     remoteClient.Username = handshakePacket.Username;
     remoteClient.QueuePacket(new HandshakeResponsePacket("-")); // TODO: Implement some form of authentication
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:7,代码来源:LoginHandlers.cs


示例4: Handle

        public override void Handle(IRemoteClient client, string alias, string[] arguments)
        {
            switch (arguments.Length)
            {
                case 0:
                    client.SendMessage(client.World.Time.ToString());
                    break;
                case 2:
                    if (!arguments[0].Equals("set"))
                        Help(client, alias, arguments);

                    int newTime;

                    if(!Int32.TryParse(arguments[1], out newTime))
                        Help(client, alias, arguments);

                    client.World.Time = newTime;

                    client.SendMessage(string.Format("Setting time to {0}", arguments[1]));

                    foreach (var remoteClient in client.Server.Clients.Where(c => c.World.Equals(client.World)))
                        remoteClient.QueuePacket(new TimeUpdatePacket(newTime));
                    
                    break;
                default:
                    Help(client, alias, arguments);
                    break;
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:29,代码来源:TimeCommand.cs


示例5: ItemUsedOnBlock

        public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
        {
            if (face == BlockFace.PositiveY || face == BlockFace.NegativeY)
            {
                // Trapdoors are not placed when the user clicks on the top or bottom of a block
                return;
            }

            // NOTE: These directions are rotated by 90 degrees so that the hinge of the trapdoor is placed
            // where the user had their cursor.
            switch (face)
            {
                case BlockFace.NegativeZ:
                    item.Metadata = (byte)TrapdoorDirection.West;
                    break;
                case BlockFace.PositiveZ:
                    item.Metadata = (byte)TrapdoorDirection.East;
                    break;
                case BlockFace.NegativeX:
                    item.Metadata = (byte)TrapdoorDirection.South;
                    break;
                case BlockFace.PositiveX:
                    item.Metadata = (byte)TrapdoorDirection.North;
                    break;
                default:
                    return;
            }

            base.ItemUsedOnBlock(coordinates, item, face, world, user);
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:30,代码来源:TrapdoorBlock.cs


示例6: Run

        public static ScenarioResult Run(this Scenario scenario, IRemoteClient proxy)
        {
            var scenarioResult = new ScenarioResult();

            scenarioResult.ScenarioName = scenario.Name;

            scenario.Children = scenario.Children.OrderBy(d => d.Index).ToList();

            scenario.Children.ForEach(i => scenarioResult.InteractionResults.Add((i as Interaction).Run(proxy)));

            scenarioResult.SetResult();

            if (!scenario.ExpectFailure)
                return scenarioResult;
            else
                if (scenarioResult.Result.status.ToLower().Equals("pass"))
                {
                    scenarioResult.Result.status = "FAIL";
                    scenarioResult.Result.error = "Expected failure, but scenario incorrectly passed.";
                }
                else
                {
                    scenarioResult.Result.status = "PASS";
                    scenarioResult.Result.error = "";
                    scenarioResult.Result.retrn = "Scenario failed correctly.";
                }

            return scenarioResult;
        }
开发者ID:ihenehan,项目名称:Behavior,代码行数:29,代码来源:ScenarioExtensions.cs


示例7: BlockPlaced

 public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     var chunk = world.FindChunk(descriptor.Coordinates);
     user.Server.Scheduler.ScheduleEvent("crops", chunk,
         TimeSpan.FromSeconds(MathHelper.Random.Next(30, 60)),
         (server) => GrowBlock(server, world, descriptor.Coordinates + MathHelper.BlockFaceToCoordinates(face)));
 }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:7,代码来源:CropsBlock.cs


示例8: GetPlayerByName

 protected static IRemoteClient GetPlayerByName(IRemoteClient client, string username)
 {
     var receivingPlayer =
         client.Server.Clients.FirstOrDefault(
             c => String.Equals(c.Username, username, StringComparison.CurrentCultureIgnoreCase));
     return receivingPlayer;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:7,代码来源:GiveCommand.cs


示例9: Handle

        public override void Handle(IRemoteClient client, string alias, string[] arguments)
        {
            if (arguments.Length < 2)
            {
                Help(client, alias, arguments);
                return;
            }

            string  username    = arguments[0],
                    itemid      = arguments[1],
                    amount      = "1";

            if(arguments.Length >= 3)
                    amount = arguments[2];
            
            var receivingPlayer = GetPlayerByName(client, username);

            if (receivingPlayer == null)
            {
                client.SendMessage("No client with the username \"" + username + "\" was found.");
                return;
            }

            if (!GiveItem(receivingPlayer, itemid, amount, client))
            {
                Help(client, alias, arguments);
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:28,代码来源:GiveCommand.cs


示例10: Handle

        public override void Handle(IRemoteClient client, string alias, string[] arguments)
        {
            if (arguments.Length > 1)
            {
                Help(client, alias, arguments);
                return;
            }

            var identifier = arguments.Length == 1 ? arguments[0] : "1";

            ICommand found;
            if ((found = Program.CommandManager.FindByName(identifier)) != null)
            {
                found.Help(client, identifier, new string[0]);
                return;
            }
            else if ((found = Program.CommandManager.FindByAlias(identifier)) != null)
            {
                found.Help(client, identifier, new string[0]);
                return;
            }

            int pageNumber;
            if (int.TryParse(identifier, out pageNumber))
            {
                HelpPage(client, pageNumber);
                return;
            }
            Help(client, alias, arguments);
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:30,代码来源:HelpCommand.cs


示例11: Handle

        public override void Handle(IRemoteClient client, string alias, string[] arguments)
        {
            if (arguments.Length < 2)
            {
                Help(client, alias, arguments);
                return;
            }
            
            string username = arguments[0];
            var messageBuilder = new System.Text.StringBuilder();

            for (int i = 1; i < arguments.Length; i++)
                messageBuilder.Append(arguments[i] + " ");
            var message = messageBuilder.ToString();

            var receivingPlayer = GetPlayerByName(client, username);

            if (receivingPlayer == null)
            {
                client.SendMessage("No client with the username \"" + username + "\" was found.");
                return;
            }
            if (receivingPlayer == client)
            {
                client.SendMessage(ChatColor.Red + "You can't send a private message to yourself!");
                return;
            }

            receivingPlayer.SendMessage(ChatColor.Gray + "<"+ client.Username + " -> You> " + message);
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:30,代码来源:TellCommand.cs


示例12: Handle

        public override void Handle(IRemoteClient client, string alias, string[] arguments)
        {
            if (arguments.Length != 1)
            {
                Help(client, alias, arguments);
                return;
            }

            int id;
            if (!int.TryParse(arguments[0], out id))
            {
                Help(client, alias, arguments);
                return;
            }

            var manager = client.Server.GetEntityManagerForWorld(client.World);
            var entity = manager.GetEntityByID(id) as MobEntity;
            if (entity == null)
            {
                client.SendMessage(ChatColor.Red + "An entity with that ID does not exist in this world.");
                return;
            }

            manager.DespawnEntity(entity);
        }
开发者ID:ac682,项目名称:TrueCraft,代码行数:25,代码来源:DebugCommands.cs


示例13: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     coordinates += MathHelper.BlockFaceToCoordinates(face);
     var descriptor = world.GetBlockData(coordinates);
     LadderDirection direction;
     switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
     {
         case Direction.North:
             direction = LadderDirection.North;
             break;
         case Direction.South:
             direction = LadderDirection.South;
             break;
         case Direction.East:
             direction = LadderDirection.East;
             break;
         default:
             direction = LadderDirection.West;
             break;
     }
     descriptor.Metadata = (byte)direction;
     if (IsSupported(descriptor, user.Server, world))
     {
         world.SetBlockID(descriptor.Coordinates, BlockID);
         world.SetMetadata(descriptor.Coordinates, (byte)direction);
         item.Count--;
         user.Inventory[user.SelectedSlot] = item;
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:29,代码来源:LadderBlock.cs


示例14: BlockPlaced

 public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     var chunk = world.FindChunk(descriptor.Coordinates);
     user.Server.Scheduler.ScheduleEvent(chunk,
         DateTime.UtcNow.AddSeconds(MathHelper.Random.Next(MinGrowthTime, MaxGrowthTime)),
         s => TrySpread(descriptor.Coordinates, world, user.Server));
 }
开发者ID:zevipa,项目名称:TrueCraft,代码行数:7,代码来源:GrassBlock.cs


示例15: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     coordinates += MathHelper.BlockFaceToCoordinates(face);
     if (world.GetBlockID(coordinates) == AirBlock.BlockID)
     {
         world.SetBlockID(coordinates, FireBlock.BlockID);
     }
 }
开发者ID:KayleeSmall,项目名称:TrueCraft,代码行数:8,代码来源:FlintAndSteelItem.cs


示例16: ClientViewModel

        public ClientViewModel(IRemoteClient remoteClient)
        {
            RemoteClient = remoteClient;

            _clientInformationDecorator = new ClientInformationDecorator(RemoteClient);

            UpdateInformation();
        }
开发者ID:pierregillon,项目名称:ConnectUs,代码行数:8,代码来源:ClientViewModel.cs


示例17: BlockPlaced

        public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
        {
            double rotation = user.Entity.Yaw + 180 % 360;
            if (rotation < 0)
                rotation += 360;

            world.SetMetadata(descriptor.Coordinates, (byte)(rotation / 22.5));
        }
开发者ID:Gbear605,项目名称:TrueCraft,代码行数:8,代码来源:UprightSignBlock.cs


示例18: BlockRightClicked

 public override bool BlockRightClicked(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     if (descriptor.Metadata == 5)
         world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
     else
         world.SetMetadata(descriptor.Coordinates, (byte)(descriptor.Metadata + 1));
     return false;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:8,代码来源:CakeBlock.cs


示例19: BlockPlaced

 public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     if (IsHydrated(descriptor.Coordinates, world))
     {
         world.SetMetadata(descriptor.Coordinates, 1);
     }
     user.Server.Scheduler.ScheduleEvent(DateTime.Now.AddSeconds(UpdateIntervalSeconds), (server) => HydrationCheckEvent(server, descriptor.Coordinates, world));
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:8,代码来源:FarmlandBlock.cs


示例20: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     if (world.GetBlockID(coordinates) == FarmlandBlock.BlockID)
     {
         world.SetBlockID(coordinates + MathHelper.BlockFaceToCoordinates(face), CropsBlock.BlockID);
         world.BlockRepository.GetBlockProvider(CropsBlock.BlockID).BlockPlaced(
             new BlockDescriptor { Coordinates = coordinates }, face, world, user);
     }
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:9,代码来源:SeedsItem.cs



注:本文中的IRemoteClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IRenderContext类代码示例发布时间:2022-05-24
下一篇:
C# IRelationalRow类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap