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

C# Net.Client类代码示例

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

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



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

示例1: Use

 public void Use(Client client, string[] tokens)
 {
     int newTime = -1;
     if (tokens.Length < 2)
     {
         client.SendMessage("You must specify an explicit time, day, or night.");
         return;
     }
     if (int.TryParse(tokens[1], out newTime) && newTime >= 0 && newTime <= 24000)
     {
         client.Owner.World.Time = newTime;
     }
     else if (tokens[1].ToLower() == "day")
     {
         client.Owner.World.Time = 0;
     }
     else if (tokens[1].ToLower() == "night")
     {
         client.Owner.World.Time = 12000;
     }
     else
     {
         client.SendMessage("You must specify a time value between 0 and 24000");
         return;
     }
     client.Owner.Server.Broadcast(new TimeUpdatePacket { Time = client.Owner.World.Time });
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:27,代码来源:CmdTime.cs


示例2: DamageMob

        public void DamageMob(Client hitBy = null)
        {
            if (hitBy != null)
            {
                // TODO: Get the Clients held item.
                this.Health -= 1;
            }
            else
            {
                // TODO: Generic damage from falling/lava/fire?
                this.Health -= 1;
            }

            foreach (Client c in World.Server.GetNearbyPlayers(World, Position.X, Position.Y, Position.Z))
            {
                c.PacketHandler.SendPacket(new AnimationPacket // Hurt Animation
                {
                    Animation = 2,
                    PlayerId = this.EntityId
                });

                c.PacketHandler.SendPacket(new EntityStatusPacket // Hurt Action
                {
                    EntityId = this.EntityId,
                    EntityStatus = 2
                });
            }

            // TODO: Entity Knockback

            if (this.Health == 0) HandleDeath(hitBy);
        }
开发者ID:dredge20,项目名称:c-raft,代码行数:32,代码来源:Mob.cs


示例3: Use

        public void Use(Client client, string commandName, string[] tokens)
        {
            Vector3 facing = new Vector3(client.Owner.Yaw, client.Owner.Pitch);

            Vector3 start = new Vector3(client.Owner.Position.X, client.Owner.Position.Y + client.Owner.EyeHeight, client.Owner.Position.Z);
            Vector3 end = facing * 100 + start;
            if (end.Y < 0)
            {
                end = end * (Math.Abs(end.Y) / start.Y);
                end.Y = 0;
            }

            RayTraceHitBlock hit = client.Owner.World.RayTraceBlocks(new AbsWorldCoords(start), new AbsWorldCoords(end));

            if (hit != null)
            {
                if (tokens.Length == 0)
                {
                }
                else
                {
                    MobType mobType;
                    if (Enum.TryParse<MobType>(tokens[0], true, out mobType))
                    {
                        Mob theMob = MobFactory.CreateMob(client.Owner.World, client.Server.AllocateEntity(), mobType, null);
                        theMob.Position = new AbsWorldCoords(client.Owner.World.FromFace(hit.TargetBlock, hit.FaceHit));
                        client.Server.AddEntity(theMob);
                    }
                    else
                    {
                        client.SendMessage(String.Format("Unrecognised mob type: '{0}'", tokens[0]));
                    }
                }
            }
        }
开发者ID:IdentErr,项目名称:c-raft,代码行数:35,代码来源:DbgMob.cs


示例4: Use

        public void Use(Client client, string commandName, string[] tokens)
        {
            if (client.Point2 == null || client.Point1 == null)
            {
                client.SendMessage("§cPlease select a cuboid first.");
                return;
            }

            UniversalCoords start = client.SelectionStart.Value;
            UniversalCoords end = client.SelectionEnd.Value;

            ItemStack item = client.Owner.Server.Items[tokens[0]];
            if (ItemStack.IsVoid(item))
            {
                client.SendMessage("§cUnknown item.");
                return;
            }

            if (item.Type > 255)
            {
                client.SendMessage("§cInvalid item.");
            }

            for (int x = start.WorldX; x <= end.WorldX; x++)
            {
                for (int y = start.WorldY; y <= end.WorldY; y++)
                {
                    for (int z = start.WorldZ; z <= end.WorldZ; z++)
                    {
                        client.Owner.World.SetBlockAndData(UniversalCoords.FromWorld(x, y, z), (byte)item.Type, (byte)item.Durability);
                    }
                }
            }
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:34,代码来源:CmdSet.cs


示例5: DoInteraction

        protected override void DoInteraction(Client client, Interfaces.ItemStack item)
        {
            base.DoInteraction(client, item);

            if (client != null && !Chraft.Interfaces.ItemStack.IsVoid(item))
            {
                if (item.Type == (short)Chraft.World.BlockData.Items.Shears && !Data.Sheared)
                {
                    // Drop wool when sheared
                    sbyte count = (sbyte)Server.Rand.Next(2, 4);
                    if (count > 0)
                        Server.DropItem(World, UniversalCoords.FromWorld(Position.X, Position.Y, Position.Z), new Interfaces.ItemStack((short)Chraft.World.BlockData.Blocks.Wool, count, (short)Data.WoolColor));
                    Data.Sheared = true;

                    SendMetadataUpdate();
                }
                else if (item.Type == (short)Chraft.World.BlockData.Items.Ink_Sack)
                {
                    // Set the wool colour of this Sheep based on the item.Durability
                    // Safety check. Values of 16 and higher (color do not exist) may crash the client v1.8.1 and below
                    if (item.Durability >= 0 && item.Durability <= 15)
                    {
                        //this.Data.WoolColor = (WoolColor)Enum.ToObject(typeof(WoolColor), (15 - item.Durability));
                        Data.WoolColor = DyeColorToWoolColor((MetaData.Dyes)Enum.ToObject(typeof(MetaData.Dyes), item.Durability));
                        SendMetadataUpdate();
                    }
                }
            }
        }
开发者ID:Smjert,项目名称:c-raft,代码行数:29,代码来源:Sheep.cs


示例6: Use

 public void Use(Client client, string[] tokens)
 {
     if (tokens.Length < 2)
     {
         client.SendMessage("§cUsage <player> <mode>");
         return;
     }
     Client c = client.Owner.Server.GetClients(tokens[1]).FirstOrDefault();
     if (c != null)
     {
         if (c.Owner.GameMode == Convert.ToByte(tokens[2]))
         {
             client.SendMessage("§7You are already in that mode");
             return;
         }
         c.SendPacket(new NewInvalidStatePacket
         {
             GameMode = c.Owner.GameMode = Convert.ToByte(tokens[2]),
             Reason = NewInvalidStatePacket.NewInvalidReason.ChangeGameMode
         });
     }
     else
     {
         client.SendMessage(string.Format("§cPlayer {0} not found", tokens[1]));
     }
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:26,代码来源:CmdGameMode.cs


示例7: Use

 public void Use(Client client, string commandName, string[] tokens)
 {
     switch (tokens.Length)
     {
         case 0:
             ChangeGameMode(client, client.Owner.GameMode == 0 ? 1 : 0);
             break;
         case 2:
             if (Int32.Parse(tokens[1]) != 0)
             {
                 if (Int32.Parse(tokens[1]) != 1)
                 {
                     Help(client);
                     break;
                 }
             }
             Client c = client.Owner.Server.GetClients(tokens[0]).FirstOrDefault();
             if (c != null)
             {
                 if (c.Owner.GameMode == Convert.ToByte(tokens[1]))
                 {
                     client.SendMessage(ChatColor.Red + "Player is already in that mode");
                     break;
                 }
                 ChangeGameMode(client, Int32.Parse(tokens[1]));
                 break;
             }
             client.SendMessage(string.Format(ChatColor.Red + "Player {0} not found", tokens[0]));
             break;
         default:
             Help(client);
             break;
     }
 }
开发者ID:dekema2,项目名称:c-raft,代码行数:34,代码来源:CmdGameMode.cs


示例8: Use

        public void Use(Client client, string[] tokens)
        {
            if (client.Point2 == null || client.Point1 == null)
            {
                client.SendMessage("§cPlease select a cuboid first.");
                return;
            }

            PointI start = client.SelectionStart.Value;
            PointI end = client.SelectionEnd.Value;

            ItemStack item = client.Owner.Server.Items[tokens[1]];
            if (ItemStack.IsVoid(item))
            {
                client.SendMessage("§cUnknown item.");
                return;
            }

            if (item.Type > 255)
            {
                client.SendMessage("§cInvalid item.");
            }

            for (int x = start.X; x <= end.X; x++)
            {
                for (int y = start.Y; y <= end.Y; y++)
                {
                    for (int z = start.Z; z <= end.Z; z++)
                    {
                        client.Owner.World.SetBlockAndData(x, y, z, (byte)item.Type, (byte)item.Durability);
                    }
                }
            }
        }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:34,代码来源:CmdSet.cs


示例9: ReadCloseWindow

        public static void ReadCloseWindow(Client client, PacketReader reader)
        {
            CloseWindowPacket cw = new CloseWindowPacket();
            cw.Read(reader);

            if(!reader.Failed)
                Client.HandlePacketCloseWindow(client, cw);
        }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:8,代码来源:PacketHandlers.cs


示例10: ReadChatMessage

        public static void ReadChatMessage(Client client, PacketReader reader)
        {
            ChatMessagePacket cm = new ChatMessagePacket();
            cm.Read(reader);

            if (!reader.Failed)
                Client.HandlePacketChatMessage(client, cm);
        }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:8,代码来源:PacketHandlers.cs


示例11: ReadKeepAlive

        public static void ReadKeepAlive(Client client, PacketReader reader)
        {
            KeepAlivePacket ka = new KeepAlivePacket();
            ka.Read(reader);

            if (!reader.Failed)
                Client.HandlePacketKeepAlive(client, ka);
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:8,代码来源:PacketHandlers.cs


示例12: ReadAnimation

        public static void ReadAnimation(Client client, PacketReader reader)
        {
            AnimationPacket ap = new AnimationPacket();
            ap.Read(reader);

            if(!reader.Failed)
                Client.HandlePacketAnimation(client, ap);
        }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:8,代码来源:PacketHandlers.cs


示例13: Inventory

 internal Inventory(Client client)
     : base(InterfaceType.Inventory, 4, 45)
 {
     _ActiveSlot = 36;
     Associate(client);
     _IsOpen = true;
     UpdateClient();
 }
开发者ID:cyberdudedk,项目名称:c-raft,代码行数:8,代码来源:Inventory.cs


示例14: SetHealth

 private void SetHealth(Client client, short health)
 {
     if (health > 20)
     {
         health = 20;
     }
     client.SendPacket(new UpdateHealthPacket { Health = health });
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:8,代码来源:CmdSetHealth.cs


示例15: Use

 public void Use(Client client, string[] tokens)
 {
     if (tokens.Length < 2)
     {
         SetHealth(client, 20);
         return;
     }
     SetHealth(client, short.Parse(tokens[1]));
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:9,代码来源:CmdSetHealth.cs


示例16: Use

 public void Use(Client client, string[] tokens)
 {
     string message = "";
     for (int i = 1; i < tokens.Length; i++)
     {
         message += tokens[i] + " ";
     }
     client.Owner.Server.Broadcast(message);
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:9,代码来源:CmdSay.cs


示例17: Use

 public void Use(Client client, string[] tokens)
 {
     client.Owner.Server.Broadcast("The server is shutting down.");
     client.Owner.Server.Logger.Log(Logger.LogLevel.Info, "The server is shutting down.");
     Thread.Sleep(5000);
     client.Owner.Server.Stop();
     Thread.Sleep(10);
     Console.WriteLine("Press Enter to exit.");
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:9,代码来源:CmdStop.cs


示例18: Inventory

 internal Inventory(Client client)
     : base(InterfaceType.Inventory, 4, 45)
 {
     _ActiveSlot = 36;
     Associate(client);
     _IsOpen = true;
     // Inventory is always WindowId 0
     Handle = 0;
     UpdateClient();
 }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:10,代码来源:Inventory.cs


示例19: Player

 public Player(Server server, int entityId, Client client)
     : base(server, entityId, null)
 {
     _client = client;
     EnsureServer(server);
     Inventory = null;
     DisplayName = client.Username;
     InitializePosition();
     PermHandler = new PermissionHandler(server);
 }
开发者ID:Nirad,项目名称:c-raft,代码行数:10,代码来源:Player.cs


示例20: Use

 public void Use(Client client, string commandName, string[] tokens)
 {
     short newHealth = 20;
     if (tokens.Length > 0)
     {
         if (!short.TryParse(tokens[0], out newHealth))
             newHealth = 20;
     }
     client.Owner.SetHealth(newHealth);
 }
开发者ID:dekema2,项目名称:c-raft,代码行数:10,代码来源:CmdSetHealth.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Net.PacketReader类代码示例发布时间:2022-05-24
下一篇:
C# generic.XmlMerger类代码示例发布时间: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