Пример #1
0
        static bool MoveTowards(PlayerBot bot, Player p)
        {
            int dx = p.pos[0] - bot.pos[0], dy = p.pos[1] - bot.pos[1], dz = p.pos[2] - bot.pos[2];

            bot.foundPos = p.pos;
            bot.movement = true;

            Vec3F32 dir = new Vec3F32(dx, dy, dz);

            dir = Vec3F32.Normalise(dir);
            byte yaw, pitch;

            DirUtils.GetYawPitch(dir, out yaw, out pitch);

            // If we are very close to a player, switch from trying to look
            // at them to just facing the opposite direction to them
            if (Math.Abs(dx) >= 4 || Math.Abs(dz) >= 4)
            {
                bot.rot[0] = yaw;
            }
            else if (p.rot[0] < 128)
            {
                bot.rot[0] = (byte)(p.rot[0] + 128);
            }
            else
            {
                bot.rot[0] = (byte)(p.rot[0] - 128);
            }
            bot.rot[1] = pitch;

            return(dx <= 8 && dy <= 16 && dz <= 8);
        }
Пример #2
0
        static bool MoveTowards(PlayerBot bot, Player p)
        {
            int dx = p.Pos.X - bot.Pos.X, dy = p.Pos.Y - bot.Pos.Y, dz = p.Pos.Z - bot.Pos.Z;

            bot.TargetPos = p.Pos;
            bot.movement  = true;

            Vec3F32 dir = new Vec3F32(dx, dy, dz);

            dir = Vec3F32.Normalise(dir);
            Orientation rot = bot.Rot;

            DirUtils.GetYawPitch(dir, out rot.RotY, out rot.HeadX);

            dx = Math.Abs(dx); dy = Math.Abs(dy); dz = Math.Abs(dz);

            // If we are very close to a player, switch from trying to look
            // at them to just facing the opposite direction to them
            if (dx < 4 && dz < 4)
            {
                rot.RotY = (byte)(p.Rot.RotY + 128);
            }
            bot.Rot = rot;

            return(dx <= 8 && dy <= 16 && dz <= 8);
        }
Пример #3
0
        public override void ExecuteLeft(Player p)
        {
            byte targetkick = (byte)((p.rot[0] - 32) % 256);
            var  targetdir  = DirUtils.GetDirVector(targetkick, p.rot[1]);

            PlayerHandlers.KickBall(p, (float)(targetdir.X * 0.5), 0, (float)(targetdir.Z * 0.5), false);
        }
Пример #4
0
        internal static ChangeResult RocketStart(Player p, BlockID old, ushort x, ushort y, ushort z)
        {
            if (p.level.physics < 2 || p.level.physics == 5)
            {
                return(ChangeResult.Unchanged);
            }

            int dx = 0, dy = 0, dz = 0;

            DirUtils.EightYaw(p.Rot.RotY, out dx, out dz);
            DirUtils.Pitch(p.Rot.HeadX, out dy);

            // Looking straight up or down
            byte pitch = p.Rot.HeadX;

            if (pitch >= 192 && pitch <= 196 || pitch >= 60 && pitch <= 64)
            {
                dx = 0; dz = 0;
            }
            Vec3U16 head = new Vec3U16((ushort)(x + dx * 2), (ushort)(y + dy * 2), (ushort)(z + dz * 2));
            Vec3U16 tail = new Vec3U16((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz));

            bool headFree = p.level.IsAirAt(head.X, head.Y, head.Z) && p.level.CheckClear(head.X, head.Y, head.Z);
            bool tailFree = p.level.IsAirAt(tail.X, tail.Y, tail.Z) && p.level.CheckClear(tail.X, tail.Y, tail.Z);

            if (headFree && tailFree)
            {
                p.level.Blockchange(head.X, head.Y, head.Z, Block.RocketHead);
                p.level.Blockchange(tail.X, tail.Y, tail.Z, Block.LavaFire);
            }
            return(ChangeResult.Unchanged);
        }
Пример #5
0
        public static void DownloadTodayBingImages()
        {
            if (!NetworkStatus.IsConnectedToInternet())
            {
                "The internet connection was not found.".LogText();
                return;
            }

            var dir = DirUtils.GetImagesDir();

            Enumerable.Range(start: 0, count: 9).AsParallel().ForAll(imageIndex =>
            {
                try
                {
                    var source = $"http://www.bing.com/HPImageArchive.aspx?format=xml&idx={imageIndex}&n=1&mkt=en-US";
                    downloadImage(source, dir, xml =>
                    {
                        var bingImage = xml.FromXmlContent <images>();
                        return(new ImageInfo
                        {
                            Url = $"http://www.bing.com{bingImage.image.url.Replace("_1366x768.jpg", "_1920x1080.jpg")}",
                            Copyright = bingImage.image.copyright
                        });
                    });
                }
                catch (Exception ex)
                {
                    ex.LogException();
                }
            });
        }
Пример #6
0
    public static void BuildPlatform(BuildTarget platform, string[] scenes)
    {
        var platformPath = DirUtils.PlatformBuildPath(platform);

        if (platformPath == null)
        {
            Debug.LogWarningFormat(string.Format("Do not know info for {0}", platform));
            return;
        }

        var previousGroup  = EditorUserBuildSettings.selectedBuildTargetGroup;
        var previousTarget = EditorUserBuildSettings.activeBuildTarget;

        if (!Directory.Exists(Constants.BuildPath))
        {
            Directory.CreateDirectory(Constants.BuildPath);
        }

        try
        {
            // DirUtils.RmStreamingBundle();
            // CreateAssetBundles.EnsureBuilt(platform, setStreamingAssets:true);

            BuildPipeline.BuildPlayer(new BuildPlayerOptions {
                target           = platform,
                scenes           = scenes,
                locationPathName = platformPath,
                options          = BuildOptions.None
            });
        }
        finally
        {
            EditorUserBuildSettings.SwitchActiveBuildTarget(previousGroup, previousTarget);
        }
    }
Пример #7
0
        protected override void PlacedMark(Player p, ushort x, ushort y, ushort z, BlockID block)
        {
            p.RevertBlock(x, y, z);
            if (!p.level.Config.Guns)
            {
                p.ClearBlockchange(); return;
            }
            if (!CommandParser.IsBlockAllowed(p, "use", block))
            {
                return;
            }

            WeaponArgs args = new WeaponArgs();

            args.player     = p;
            args.block      = block;
            args.weaponType = (WeaponType)p.blockchangeObject;

            args.start      = MakePos(p);
            args.dir        = DirUtils.GetFlatDirVector(p.Rot.RotY, p.Rot.HeadX);
            args.pos        = args.PosAt(3);
            args.iterations = 4;

            SchedulerTask task = new SchedulerTask(GunCallback, args, TimeSpan.Zero, true);

            p.CriticalTasks.Add(task);
        }
Пример #8
0
        static Vec3U16 MissileTarget(WeaponArgs args)
        {
            Player p = args.player;

            args.start = MakePos(p);
            args.dir   = DirUtils.GetDirVector(p.Rot.RotY, p.Rot.HeadX);
            int i;

            for (i = 1; ; i++)
            {
                Vec3U16 target = args.PosAt(i);
                BlockID block  = p.level.GetBlock(target.X, target.Y, target.Z);
                if (block == Block.Invalid)
                {
                    break;
                }

                if (block != Block.Air && !args.allBlocks.Contains(target) && HandlesHitBlock(p, block, args.weaponType, target, false))
                {
                    break;
                }

                Player hit = GetPlayer(p, target, true);
                if (hit != null)
                {
                    return(MakePos(hit));
                }
            }
            return(args.PosAt(i - 1));
        }
Пример #9
0
 public void GetDirIndexTest()
 {
     Assert.AreEqual(0, DirUtils.GetDirIndex(Direction.SOUTH), "SOUTH did not produce 0");
     Assert.AreEqual(1, DirUtils.GetDirIndex(Direction.NORTH), "NORTH did not produce 1");
     Assert.AreEqual(2, DirUtils.GetDirIndex(Direction.EAST), "EAST did not produce 2");
     Assert.AreEqual(3, DirUtils.GetDirIndex(Direction.WEST), "WEST did not produce 3");
 }
Пример #10
0
        public void SolvePart1()
        {
            Coord coord = new Coord(0, 0);

            string[] directions  = InputParser.ReadToStringArr(Day);
            char     orientation = 'E';

            foreach (string direction in directions)
            {
                (char dir, int val) = DirUtils.ParseDir(direction);

                if (DirUtils.CardinalKeys.Contains(dir))
                {
                    CardinalDir step = DirUtils.dirLkup[dir];
                    coord.X += (val * step.dx);
                    coord.Y += (val * step.dy);
                }
                else if (DirUtils.Turns.Contains(dir))
                {
                    for (int i = 0; i < (val / 90); i++)
                    {
                        orientation = DirUtils.turnLkp[dir][orientation];
                    }
                }
                else if (dir == 'F')
                {
                    CardinalDir step = DirUtils.dirLkup[orientation];
                    coord.X += (val * step.dx);
                    coord.Y += (val * step.dy);
                }
            }
            int solution = Math.Abs(coord.X) + Math.Abs(coord.Y);

            Console.WriteLine($"Manhattan Distance: {solution}");
        }
Пример #11
0
        static void PlayerClickCallback(Player p, MouseButton btn, MouseAction action,
                                        ushort yaw, ushort pitch, byte entity,
                                        ushort x, ushort y, ushort z, TargetBlockFace face)
        {
            Weapon weapon = p.weapon;

            if (weapon == null || action != MouseAction.Pressed)
            {
                return;
            }

            if (!(btn == MouseButton.Left || btn == MouseButton.Right))
            {
                return;
            }
            if (!p.level.Config.Guns)
            {
                weapon.Disable(); return;
            }

            BlockID held = p.ClientHeldBlock;

            if (!CommandParser.IsBlockAllowed(p, "use", held))
            {
                return;
            }

            Vec3F32 dir = DirUtils.GetDirVectorExt(yaw, pitch);

            weapon.OnActivated(dir, held);
        }
Пример #12
0
        Vec3U16 MissileTarget(MissileData args)
        {
            args.start = (Vec3U16)p.Pos.BlockCoords;
            args.dir   = DirUtils.GetDirVector(p.Rot.RotY, p.Rot.HeadX);
            int i;

            for (i = 1; ; i++)
            {
                Vec3U16 target = args.PosAt(i);
                BlockID block  = p.level.GetBlock(target.X, target.Y, target.Z);

                if (block == Block.Invalid)
                {
                    break;
                }
                if (block != Block.Air && !args.all.Contains(target))
                {
                    break;
                }

                Player hit = PlayerAt(p, target, true);
                if (hit != null)
                {
                    return((Vec3U16)hit.Pos.BlockCoords);
                }
            }
            return(args.PosAt(i - 1));
        }
        public static DynamicElement GetDynamicElementAround(
            Scenario scenario,
            Point charPos,
            MapElements type,
            Func <Scenario, Point, DynamicElement> GetElem
            )
        {
            var obj = GetElem(scenario, DirUtils.GetNorthFromPos(charPos));

            if (obj != null && obj.Type == type)
            {
                return(obj);
            }

            obj = GetElem(scenario, DirUtils.GetEastFromPos(charPos));
            if (obj != null && obj.Type == type)
            {
                return(obj);
            }

            obj = GetElem(scenario, DirUtils.GetSouthFromPos(charPos));
            if (obj != null && obj.Type == type)
            {
                return(obj);
            }

            obj = GetElem(scenario, DirUtils.GetWestFromPos(charPos));
            if (obj != null && obj.Type == type)
            {
                return(obj);
            }

            return(null);
        }
Пример #14
0
        private static void Pack(DirectoryInfo[] dirs)
        {
            int numOfPackagesToPack = dirs.Count();
              if(numOfPackagesToPack == 0)
              {
            return;
              }
              mNumOfPackedPackages += numOfPackagesToPack;

              var myDirUtils = new DirUtils();
              System.Diagnostics.Process process = new System.Diagnostics.Process();
              System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
              startInfo.WorkingDirectory = mPackModulesDest;
              startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
              startInfo.FileName = "cmd.exe";

              StringBuilder listOfModules = new StringBuilder();
              foreach(var d in dirs)
              {
            listOfModules.Append(d.FullName + " ");
            Console.WriteLine("packing " + d.FullName);
              }

              startInfo.Arguments = "/C npm pack " + listOfModules;
              process.StartInfo = startInfo;
              process.Start();
              process.WaitForExit();
        }
Пример #15
0
        public void SaveResult(string pathDir)
        {
            string path = pathDir;

            DirUtils.CreateDir(path);
            //this.FileName = this.FileName.Replace(':', '_');
            path = path + "\\" + DateTime.Now.ToString("yyyyMMdd HHmmss");
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(this.Barcode + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.Depart + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.ComputerInfo + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.MachineInfo + "\r\n");
            stringBuilder.Append(this.GetBarcodePart(this.Barcode) + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.ProductLineInfo + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.OwkInfo + "\r\n");
            stringBuilder.Append(FluidProgram.CurrentOrDefault().RuntimeSettings.CustomParam.RTVParam.UserInfo + "\r\n");
            stringBuilder.Append(this.GetProgramRunTime() + "\r\n");
            stringBuilder.Append(this.GetProgramEndTime() + "\r\n");
            stringBuilder.Append("No  Width  MaxValue  MinValue  Height  MaxValue  MinValue" + "\r\n");
            for (int i = 0; i < this.Results.Count; i++)
            {
                string s = "";
                s += (1 + i).ToString() + "   ";
                s += this.Results[i][0] + "   ";
                s += this.Results[i][1] + "      ";
                s += this.Results[i][2] + "      ";
                s += this.Results[i][3] + "    ";
                s += this.Results[i][4] + "      ";
                s += this.Results[i][5];
                stringBuilder.Append(s + "\r\n");
            }

            CsvUtil.WriteLine(path, stringBuilder.ToString());
        }
Пример #16
0
        internal static bool RocketStart(Player p, byte block, ushort x, ushort y, ushort z)
        {
            if (p.level.physics < 2 || p.level.physics == 5)
            {
                p.RevertBlock(x, y, z); return(true);
            }

            int dx = 0, dy = 0, dz = 0;

            p.RevertBlock(x, y, z);
            DirUtils.EightYaw(p.rot[0], out dx, out dz);
            DirUtils.Pitch(p.rot[1], out dy);

            // Looking straight up or down
            if (p.rot[1] >= 192 && p.rot[1] <= 196 || p.rot[1] >= 60 && p.rot[1] <= 64)
            {
                dx = 0; dz = 0;
            }

            byte b1 = p.level.GetTile((ushort)(x + dx * 2), (ushort)(y + dy * 2), (ushort)(z + dz * 2));
            byte b2 = p.level.GetTile((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz));

            if (b1 == Block.air && b2 == Block.air && p.level.CheckClear((ushort)(x + dx * 2), (ushort)(y + dy * 2), (ushort)(z + dz * 2)) &&
                p.level.CheckClear((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz)))
            {
                p.level.Blockchange((ushort)(x + dx * 2), (ushort)(y + dy * 2), (ushort)(z + dz * 2), Block.rockethead);
                p.level.Blockchange((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz), Block.lava_fire);
            }
            return(true);
        }
Пример #17
0
        static void BlockChangingCallback(Player p, ushort x, ushort y, ushort z, BlockID block, bool placing, ref bool cancel)
        {
            Weapon weapon = p.weapon;

            if (weapon == null)
            {
                return;
            }

            // Revert block back since client assumes changes always succeeds
            p.RevertBlock(x, y, z);
            cancel = true;

            // Defer to player click handler if PlayerClick supported
            if (weapon.aimer == null)
            {
                return;
            }

            if (!p.level.Config.Guns)
            {
                weapon.Disable(); return;
            }
            if (!CommandParser.IsBlockAllowed(p, "use", block))
            {
                return;
            }

            Vec3F32 dir = DirUtils.GetDirVector(p.Rot.RotY, p.Rot.HeadX);

            weapon.OnActivated(dir, block);
        }
Пример #18
0
 public void DoPatternWeight()
 {
     DirUtils.CreateDir(string.Format("mes\\{0}", DateTime.Today.ToString("yyyy-MM-dd")));
     PatternWeightSettings.FilePathDotWeight =
         string.Format("mes\\{0}\\DotWeight-{0}.csv",
                       DateTime.Today.ToString("yyyy-MM-dd"));
     PatternWeightSettings.FilePathMatrixWeight = string.Format("mes\\{0}\\MatrixWeight-{0}.csv",
                                                                DateTime.Today.ToString("yyyy-MM-dd"));
     if (!string.IsNullOrEmpty(PatternWeightSettings.FileDirUser))
     {
         DirUtils.CreateDir(string.Format("{0}\\{1}", PatternWeightSettings.FileDirUser, DateTime.Today.ToString("yyyy-MM-dd")));
     }
     if (!string.IsNullOrEmpty(PatternWeightSettings.FileDirUser))
     {
         PatternWeightSettings.FilePathDotWeightUser    = string.Format("{0}\\{1}\\DotWeight-{1}.csv", PatternWeightSettings.FileDirUser, DateTime.Today.ToString("yyyy-MM-dd"));
         PatternWeightSettings.FilePathMatrixWeightUser = string.Format("{0}\\{1}\\MatrixWeight-{1}.csv", PatternWeightSettings.FileDirUser, DateTime.Today.ToString("yyyy-MM-dd"));
     }
     //this.recdPatternWeight();
     //this.recDotWeight();
     Executor.Instance.ShotNums = 0;
     if (String.IsNullOrEmpty(patterName))
     {
         return;
     }
     //if (this.runnableModule==null)
     //    return;
     Machine.Instance.Robot.MoveSafeZAndReply();
     this.Valve.MoveToScaleLoc();
     Valve.DoWeight(spray);
     this.shotNums = Executor.Instance.ShotNums;
     this.recdPatternWeight();
     this.recDotWeight();
 }
Пример #19
0
        bool DoDrill(Player p, Vec3S32[] marks, object state, ExtBlock block)
        {
            ushort x = (ushort)marks[0].X, y = (ushort)marks[0].Y, z = (ushort)marks[0].Z;

            block = p.level.GetBlock(x, y, z);
            int dist = (ushort)state, numBlocks = (3 * 3) * dist;

            if (numBlocks > p.group.DrawLimit)
            {
                Player.Message(p, "You tried to drill " + numBlocks + " blocks.");
                Player.Message(p, "You cannot drill more than " + p.group.DrawLimit + ".");
                return(false);
            }

            int dx = 0, dz = 0;

            DirUtils.FourYaw(p.Rot.RotY, out dx, out dz);
            Level lvl = p.level;

            if (dx != 0)
            {
                for (int depth = 0; depth < dist; x += (ushort)dx, depth++)
                {
                    if (x >= lvl.Width)
                    {
                        continue;
                    }

                    for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
                    {
                        for (ushort zz = (ushort)(z - 1); zz <= (ushort)(z + 1); zz++)
                        {
                            DoBlock(p, lvl, block, x, yy, zz);
                        }
                    }
                }
            }
            else
            {
                for (int depth = 0; depth < dist; z += (ushort)dz, depth++)
                {
                    if (z >= lvl.Length)
                    {
                        break;
                    }

                    for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
                    {
                        for (ushort xx = (ushort)(x - 1); xx <= (ushort)(x + 1); xx++)
                        {
                            DoBlock(p, lvl, block, xx, yy, z);
                        }
                    }
                }
            }

            Player.Message(p, "Drilled " + numBlocks + " blocks.");
            return(true);
        }
Пример #20
0
        public static void KickBall(Player p, ushort Yaw, ushort Pitch)
        {
            Yaw   = (byte)(Yaw >> 8);
            Pitch = (byte)(Pitch >> 8);
            var Dir = DirUtils.GetDirVector((byte)Yaw, (byte)Pitch);

            KickBall(p, Dir.X, Dir.Y, Dir.Z);
        }
Пример #21
0
        static void FaceTowards(PlayerBot bot, Player p)
        {
            int     dx = p.pos[0] - bot.pos[0], dy = p.pos[1] - bot.pos[1], dz = p.pos[2] - bot.pos[2];
            Vec3F32 dir = new Vec3F32(dx, dy, dz);

            dir = Vec3F32.Normalise(dir);
            DirUtils.GetYawPitch(dir, out bot.rot[0], out bot.rot[1]);
        }
Пример #22
0
        public void clear()
        {
            LogUtils.debug("ClearService.clear", "start...");

            DirUtils.del(ClearServicePlugin.DIR_PATH_TMP);

            LogUtils.debug("ClearService.clear", "end...");
        }
Пример #23
0
        public override void ExecuteRight(Player p)
        {
            var dir = DirUtils.GetDirVector(p.rot[0], p.rot[1]);

            PlayerHandlers.KickBall(p, (float)(dir.X * -0.1), 0, (float)(dir.Z * -0.3));
            Thread.Sleep(250);
            PlayerHandlers.KickBall(p, (float)(dir.X * 0.5), 0, (float)(dir.Z * 0.5));
        }
Пример #24
0
        static void RideCallback(SchedulerTask task)
        {
            Player p = (Player)task.State;

            if (!p.onTrain)
            {
                p.trainGrab = false;
                p.Message("Dismounted");

                Server.MainScheduler.QueueOnce(TrainInvincibleCallback, p,
                                               TimeSpan.FromSeconds(1));
                task.Repeating = false;
                return;
            }

            Vec3S32 P = p.Pos.FeetBlockCoords;

            for (int dx = -1; dx <= 1; dx++)
            {
                for (int dy = -1; dy <= 1; dy++)
                {
                    for (int dz = -1; dz <= 1; dz++)
                    {
                        ushort xx = (ushort)(P.X + dx), yy = (ushort)(P.Y + dy), zz = (ushort)(P.Z + dz);
                        if (p.level.GetBlock(xx, yy, zz) != Block.Train)
                        {
                            continue;
                        }
                        p.trainGrab = true;

                        byte    yaw, pitch;
                        Vec3F32 dir = new Vec3F32(dx, 0, dz);
                        DirUtils.GetYawPitch(dir, out yaw, out pitch);

                        if (dy == 1)
                        {
                            pitch = 240;
                        }
                        else if (dy == 0)
                        {
                            pitch = 0;
                        }
                        else
                        {
                            pitch = 8;
                        }

                        if (dx != 0 || dy != 0 || dz != 0)
                        {
                            Position pos = Position.FromFeetBlockCoords(P.X + dx, P.Y + dy, P.Z + dz);
                            p.SendPos(Entities.SelfID, pos, new Orientation(yaw, pitch));
                        }
                        return;
                    }
                }
            }
            p.trainGrab = false;
        }
Пример #25
0
        void DoAim(Player p)
        {
            List <Vec3U16> lastSent = new List <Vec3U16>(), toSend = new List <Vec3U16>();

            while (p.aiming)
            {
                Vec3F32 dir = DirUtils.GetFlatDirVector(p.rot[0], p.rot[1]);
                try {
                    ushort x = (ushort)Math.Round((ushort)(p.pos[0] / 32) + dir.X * 3);
                    ushort y = (ushort)Math.Round((ushort)(p.pos[1] / 32) + dir.Y * 3);
                    ushort z = (ushort)Math.Round((ushort)(p.pos[2] / 32) + dir.Z * 3);

                    int signX = Math.Sign(dir.X) >= 0 ? 1 : -1, signZ = Math.Sign(dir.Z) >= 0 ? 1 : -1;
                    CheckTile(p.level, toSend, x, y, z);
                    CheckTile(p.level, toSend, x + signX, y, z);
                    CheckTile(p.level, toSend, x, y, z + signZ);
                    CheckTile(p.level, toSend, x + signX, y, z + signZ);

                    // Revert all glass blocks now not in the ray from the player's direction
                    for (int i = 0; i < lastSent.Count; i++)
                    {
                        Vec3U16 cP = lastSent[i];
                        if (toSend.Contains(cP))
                        {
                            continue;
                        }

                        if (p.level.IsValidPos(cP))
                        {
                            p.RevertBlock(cP.X, cP.Y, cP.Z);
                        }
                        lastSent.RemoveAt(i); i--;
                    }

                    // Place the new glass blocks that are in the ray from the player's direction
                    foreach (Vec3U16 cP in toSend)
                    {
                        if (lastSent.Contains(cP))
                        {
                            continue;
                        }
                        lastSent.Add(cP);
                        p.SendBlockchange(cP.X, cP.Y, cP.Z, Block.glass);
                    }
                    toSend.Clear();
                }
                catch { }
                Thread.Sleep(20);
            }

            foreach (Vec3U16 cP in lastSent)
            {
                if (p.level.IsValidPos(cP))
                {
                    p.RevertBlock(cP.X, cP.Y, cP.Z);
                }
            }
        }
        void Step(PlayerBot bot)
        {
            bot.TargetPos = bot.Pos;
            bot.movement  = true;
            Vec3F32 dir = DirUtils.GetDirVector(bot.Rot.RotY, 0);

            bot.TargetPos.X = bot.Pos.X + (int)(dir.X * bot.movementSpeed);
            bot.TargetPos.Z = bot.Pos.Z + (int)(dir.Z * bot.movementSpeed);
        }
Пример #27
0
        public override void ExecuteLeft(Player p)
        {
            byte first     = (byte)((p.rot[0] + 90) % 256);
            var  firstdir  = DirUtils.GetDirVector(first, p.rot[1]);
            byte second    = (byte)((p.rot[0] - 60) % 256);
            var  seconddir = DirUtils.GetDirVector(second, p.rot[1]);

            PlayerHandlers.KickBall(p, (float)(firstdir.X * 0.1), 0, (float)(firstdir.Z * 0.1));
            Thread.Sleep(500);
            PlayerHandlers.KickBall(p, (float)(seconddir.X * 0.3), 0, (float)(seconddir.Z * 0.3));
        }
Пример #28
0
        private static void ExecuteCommand(string nodeModulesSrc, Command cmd)
        {
            mNumOfPackedPackages = 0;
              var myDirUtil = new DirUtils();
              DirectoryInfo di = new DirectoryInfo(nodeModulesSrc);

              Console.WriteLine("start packing ...");

              myDirUtil.Walk(di, cmd, "node_modules");

              Console.WriteLine("packing ended, packed " + mNumOfPackedPackages + " packages");
        }
Пример #29
0
    static void BuildAllAssetBundles()
    {
        DirUtils.RmPlatformBundle();

        foreach (var platform in Constants.platforms)
        {
            DirUtils.RmPlatformBundle(platform);
            EnsureBuilt(platform);
        }

        EnsureBuilt();
    }
Пример #30
0
 private void BrowseForFolder()
 {
     using (var fbd = new FolderBrowserDialog())
     {
         DialogResult result = fbd.ShowDialog();
         if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
         {
             LocalFolderPath = fbd.SelectedPath;
             ClientAge       = DirUtils.GetLatestFileWriteTimeInDir(mapping.ClientSidePath);
         }
     }
 }
Пример #31
0
        static void FaceTowards(PlayerBot bot, Player p)
        {
            int     dx = p.Pos.X - bot.Pos.X, dy = p.Pos.Y - bot.Pos.Y, dz = p.Pos.Z - bot.Pos.Z;
            Vec3F32 dir = new Vec3F32(dx, dy, dz);

            dir = Vec3F32.Normalise(dir);

            Orientation rot = bot.Rot;

            DirUtils.GetYawPitch(dir, out rot.RotY, out rot.HeadX);
            bot.Rot = rot;
        }
Пример #32
0
        public void SolveTest()
        {
            Coord shipLoc  = new Coord(0, 0);
            Coord waypoint = new Coord(1, 10);

            string[] directions  = InputParser.ReadToStringArr(Day, "Test");
            char     orientation = 'E';

            foreach (string direction in directions)
            {
                (char dir, int val) = DirUtils.ParseDir(direction);

                if (DirUtils.CardinalKeys.Contains(dir))
                {
                    CardinalDir step = DirUtils.dirLkup[dir];
                    waypoint.X += (val * step.dx);
                    waypoint.Y += (val * step.dy);
                }
                else if (DirUtils.Turns.Contains(dir))
                {
                    for (int i = 0; i < (val / 90); i++)
                    {
                        if (dir == 'R')
                        {
                            int x = waypoint.X;
                            int y = waypoint.Y;
                            waypoint.X = y;
                            waypoint.Y = -x;
                        }
                        if (dir == 'L')
                        {
                            int x = waypoint.X;
                            int y = waypoint.Y;
                            waypoint.X = -y;
                            waypoint.Y = x;
                        }
                    }
                }
                else if (dir == 'F')
                {
                    CardinalDir step = DirUtils.dirLkup[orientation];
                    for (int i = 0; i < val; i++)
                    {
                        shipLoc.X += waypoint.X;
                        shipLoc.Y += waypoint.Y;
                    }
                }
            }
            int solution = Math.Abs(shipLoc.X) + Math.Abs(shipLoc.Y);

            Console.WriteLine($"Manhattan Distance: {solution}");
        }