当前位置: 首页>>代码示例>>C#>>正文


C# Player.manualChange方法代码示例

本文整理汇总了C#中MCDawn.Player.manualChange方法的典型用法代码示例。如果您正苦于以下问题:C# Player.manualChange方法的具体用法?C# Player.manualChange怎么用?C# Player.manualChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MCDawn.Player的用法示例。


在下文中一共展示了Player.manualChange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Use

 public override void Use(Player p, string message)
 {
     if (message.Trim() == "" && !p.autobuild) { Help(p); return; }
     if (p == null) { Player.SendMessage(p, "Command not usable from Console."); return; }
     if (message.Trim().ToLower() == "off" || (p.autobuild && message.Trim() == "")) { p.autobuild = false; Player.SendMessage(p, "AutoBuild turned off."); return; }
     if (message.Split(' ').Length < 2 || message.Split(' ').Length > 3) { Help(p); return; }
     byte action; string actionString = message.Split(' ')[0].ToLower().Trim();
     if (actionString == "build" || actionString == "place" || actionString == "1") { action = 1; }
     else if (actionString == "destroy" || actionString == "break" || actionString == "0") { action = 0; }
     else { Player.SendMessage(p, "Please choose a valid block action."); return; }
     byte block = Block.Byte(message.Split(' ')[1]);
     if (block >= 255) { Player.SendMessage(p, "Unknown Block."); return; }
     if (block == Block.air) { Player.SendMessage(p, "Cannot use air as block. Set action to \"destroy\" instead."); return; }
     double interval = 1;
     if (message.Split(' ').Length > 2)
     {
         try { interval = Math.Abs(double.Parse(message.Split(' ')[2])); }
         catch { Player.SendMessage(p, "Please choose a valid interval."); return; }
     }
     p.autobuild = true; Player.SendMessage(p, "AutoBuild mode activated!");
     Thread autoBuildThread = new Thread(new ThreadStart(delegate
     {
         try // Try/Catch block in case player is looking outside the map.
         {
             while (p.autobuild)
             {
                 double x, y, z;
                 for (byte i = 0; i < 4; i++)
                 {
                     x = Math.Round((p.pos[0] / 32) + (double)(Math.Sin(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI) * i * Math.Cos(((double)(p.rot[1]) / 256) * 2 * Math.PI)));
                     y = Math.Round((p.pos[1] / 32) + (double)(Math.Cos(((double)(p.rot[1] + 64) / 256) * 2 * Math.PI) * i));
                     z = Math.Round((p.pos[2] / 32) + (double)(Math.Cos(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI) * i * Math.Cos(((double)(p.rot[1]) / 256) * 2 * Math.PI)));
                     if (p.level.GetTile((ushort)(x), (ushort)(y), (ushort)(z)) != Block.air || i >= 3) { p.manualChange((ushort)(x), (ushort)(y), (ushort)(z), action, block); break; }
                 }
                 Thread.Sleep((int)(1000 * interval));
             }
         }
         catch { }
     })); autoBuildThread.Start();
 }
开发者ID:jonnyli1125,项目名称:MCDawn,代码行数:40,代码来源:CmdAutoBuild.cs

示例2: Use

        public override void Use(Player p, string message)
        {
            string[] parameters = message.Split(' ');
            ushort[] click = p.lastClick;

            if (message.IndexOf(' ') != -1)
            {
                if (parameters.Length != 3)
                {
                    Help(p);
                    return;
                }
                else
                {
                    for (int value = 0; value < 3; value++)
                    {
                        if (parameters[value].ToLower() == "x" || parameters[value].ToLower() == "y" || parameters[value].ToLower() == "z")
                            click[value] = p.lastClick[value];
                        else if (isValid(parameters[value], value, p))
                            click[value] = ushort.Parse(parameters[value]);
                        else
                        {
                            Player.SendMessage(p, "\"" + parameters[value] + "\" was not valid");
                            return;
                        }
                    }
                }
            }

            p.manualChange(click[0], click[1], click[2], 0, Block.rock);
            Player.SendMessage(p, "Clicked &b(" + click[0] + ", " + click[1] + ", " + click[2] + ")");
        }
开发者ID:sillyboyization,项目名称:MCDawn,代码行数:32,代码来源:CmdClick.cs


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