public override bool ValidateParams(string line)
        {
            try
            {
                if (!ParsingUtilities.HasTwoParam(name, line))
                {
                    return(false);
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            string[] arguments   = ParsingUtilities.GetQuoteArguments(line);
            string   copyFromArg = PathTracker.CombineRelativePath(arguments[0]);
            string   copyToArg   = PathTracker.CombineRelativePath(arguments[1]);

            // Check if copyFrom file exists.
            if (!PathTracker.IsFilePathValid(copyFromArg))
            {
                throw new InvalidPathException("COPY_FILE_DOESNT_EXIST");
            }

            // Check if copyTo file doesn't exist.
            if (PathTracker.IsFilePathValid(copyToArg))
            {
                throw new InvalidPathException("COPY_FILE_ALREADY_EXISTS");
            }

            return(true);
        }
        public override bool ValidateParams(string line)
        {
            try
            {
                if (!ParsingUtilities.HasOneParam(name, line))
                {
                    return(false);
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            string path;

            try
            {
                path = ParsingUtilities.GetQuoteOneArgument(line);
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            if (!PathTracker.IsDirPathValid(path))
            {
                throw new InvalidPathException();
            }

            return(true);
        }
Example #3
0
        public override void Execute()
        {
            string[] dirNamesArr  = DirFileUtilities.GetDirectoriesNames(PathTracker.GetInstance().ToString());
            string[] fileNamesArr = DirFileUtilities.GetFileNames(PathTracker.GetInstance().ToString());

            MethodsOutput.PrintLocalStringLine("DIRECTORIES");
            if (dirNamesArr.Length > 0)
            {
                MethodsOutput.PrintArray(dirNamesArr);
            }
            else
            {
                MethodsOutput.PrintLocalStringLine("NO_DIRECTORIES");
            }

            MethodsOutput.SkipLine();

            MethodsOutput.PrintLocalStringLine("FILES");
            if (fileNamesArr.Length > 0)
            {
                MethodsOutput.PrintArray(fileNamesArr);
            }
            else
            {
                MethodsOutput.PrintLocalStringLine("NO_FILES");
            }
        }
        public override bool ValidateParams(string line)
        {
            // Concat command can have 1 and more options.
            try
            {
                if (!ParsingUtilities.HasAtLeastOneParam(name, line))
                {
                    return(false);
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            string[] paths = ParsingUtilities.GetQuoteArguments(line);
            foreach (var path in paths)
            {
                // Check if all files exist.
                if (!PathTracker.IsFilePathValid(path))
                {
                    throw new InvalidPathException("FILE_NOT_FOUND");
                }
            }

            return(true);
        }
Example #5
0
        public override bool ValidateParams(string line)
        {
            // Checking if command line has only 1 param.
            try
            {
                if (!ParsingUtilities.HasOneParam(name, line))
                {
                    return(false);
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            string filePathArg = ParsingUtilities.GetQuoteOneArgument(line);

            // Check if file exists.
            if (!PathTracker.IsFilePathValid(PathTracker.CombineRelativePath(filePathArg)))
            {
                throw new InvalidPathException("FILE_NOT_FOUND");
            }

            return(true);
        }
        public override void TakeParameters(string line)
        {
            string[] paths = ParsingUtilities.GetQuoteArguments(line);
            for (int i = 0; i < paths.Length; i++)
            {
                paths[i] = PathTracker.CombineRelativePath(paths[i]);
            }

            filePaths = paths;
        }
        public override void TakeParameters(string line)
        {
            string[] arguments = ParsingUtilities.GetQuoteArguments(line);
            filePath = PathTracker.CombineRelativePath(arguments[0]);
            someText = arguments[1];

            // Selecting user's encoding.
            currentEncoding = ParsingUtilities.HasThreeParam(name, line)
                ? EncodingUtilities.dictStrEncoding[arguments[2]]
                : defaultEncoding;
        }
Example #8
0
    // Use this for initialization
    void Start()
    {
        enemyObject      = this.gameObject;
        allWaypoints     = FindObjectOfType <AllWaypoints>();
        pathTracker      = enemyObject.GetComponentInChildren <PathTracker>();
        thePlayerTracker = FindObjectOfType <PlayerPathTracker>();

        //waypointsParent = GameObject.Find("WayPointsMaster");

        barrierCheck  = false;
        stillChecking = false;
        notInList     = true;
        count         = 0;
    }
        public override bool ValidateParams(string line)
        {
            // Print command can have 1 option or 2 options.
            try
            {
                if (!(ParsingUtilities.HasOneParam(name, line) ||
                      ParsingUtilities.HasTwoParam(name, line)))
                {
                    return(false);
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            string path;

            try
            {
                string[] arguments = ParsingUtilities.GetQuoteArguments(line);
                // User has not specified encoding.
                if (!ParsingUtilities.HasOneParam(name, line))
                {
                    // Trying to find specified encoding.
                    var encodingStr = arguments[1];
                    if (!EncodingUtilities.dictStrEncoding.ContainsKey(encodingStr))
                    {
                        throw new InvalidEncodingException();
                    }
                }

                path = arguments[0];
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            // Check if file exists.
            if (!PathTracker.IsFilePathValid(path))
            {
                throw new InvalidPathException("FILE_NOT_FOUND");
            }

            return(true);
        }
        public override bool ValidateParams(string line)
        {
            // Print command can have 2 or 3 options.
            try
            {
                if (!(ParsingUtilities.HasTwoParam(name, line) ||
                      ParsingUtilities.HasThreeParam(name, line)))
                {
                    return(false);
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            string[] arguments = ParsingUtilities.GetQuoteArguments(line);
            string   path      = PathTracker.CombineRelativePath(arguments[0]);

            // Check if file already exists.
            if (PathTracker.IsFilePathValid(path))
            {
                throw new InvalidPathException("FILE_ALREADY_EXISTS");
            }

            // Check if chosen encoding is correct.
            try
            {
                if (ParsingUtilities.HasThreeParam(name, line))
                {
                    if (!EncodingUtilities.dictStrEncoding.ContainsKey(arguments[2]))
                    {
                        throw new InvalidEncodingException();
                    }
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            return(true);
        }
Example #11
0
        public override bool ValidateParams(string line)
        {
            // Checking if command was written without params.
            try
            {
                if (!ParsingUtilities.HasNoParam(name, line))
                {
                    return(false);
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            // Checking if getting directories and files is possible.
            DirFileUtilities.GetDirectoriesNames(PathTracker.GetInstance().ToString());
            DirFileUtilities.GetFileNames(PathTracker.GetInstance().ToString());

            return(true);
        }
Example #12
0
 void Awake()
 {
     pathTracker  = GetComponent <PathTracker>();
     selfCollider = GetComponent <Collider2D>();
     disc         = GameObject.FindObjectOfType <Disc>();
 }
Example #13
0
 /// <summary>
 ///     <inheritdoc cref="ReadStringPrefix" />
 ///     Uses path as prefix.
 /// </summary>
 /// <returns> Read line. </returns>
 public static string ReadStringPrefixPath()
 {
     return(ReadStringPrefix(LocalizationManager.getInstance()
                             .GetLocalizedFormat("CONSOLE_PATH_INPUT_PREFIX", PathTracker.GetInstance())));
 }
 public override void Execute()
 {
     MethodsOutput.PrintFileEncoding(PathTracker.CombineRelativePath(filePath), currentEncoding);
 }
Example #15
0
        private void PathTrackerOnPathModifier(PathEventArgs args)
        {
            Debug.WriteLineIf(_gesture.Modifier != args.Modifier, "Gesture:" + _gesture);

            _gesture.Modifier = args.Modifier;

            if (IsInCaptureMode)
            {
                return;
            }

            //如果当前被“捕获”了,则把修饰符事件发送给命令。
            if (_effectiveIntent != null)
            {
                var modifierStateAwareCommand = _effectiveIntent.Command as IGestureModifiersAware;
                if (PathTracker.IsSuspended && modifierStateAwareCommand != null)
                {
                    modifierStateAwareCommand.ModifierTriggered(args.Modifier);
                    return;
                }
            }

            var lastEffectiveIntent = _effectiveIntent;

            _effectiveIntent = IntentFinder.Find(_gesture, args.Context);

            if (_effectiveIntent != null)
            {
                if (IntentRecognized != null && _effectiveIntent != lastEffectiveIntent)
                {
                    IntentRecognized(_effectiveIntent);
                }

                //如果设置了允许滚动时执行 且 确实可以执行(手势包含滚轮),则执行
                //这样执行之后,在释放手势的时候应该 不再执行!
                if (_effectiveIntent.CanExecuteOnModifier())
                {
                    OnIntentReadyToExecuteOnModifier(args.Modifier);


                    var modifierStateAwareCommand = _effectiveIntent.Command as IGestureModifiersAware;

                    //todo: 这个逻辑似乎应该放在GestureIntent中
                    if (modifierStateAwareCommand != null)
                    {
                        modifierStateAwareCommand.ReportStatus += OnCommandReportStatus;
                        GestureModifier observedModifiers;
                        modifierStateAwareCommand.GestureRecognized(out observedModifiers);

                        //要观察的modifier事件与PathTracker需要排除的恰好相反
                        PathTracker.SuspendTemprarily(filteredModifiers: GestureModifier.All & ~observedModifiers);
                    }
                    else
                    {
                        //对于非组合手势,同样unhook除了触发修饰符之外的所有修饰符,这样可以仍然反复执行,实现类似“多出粘贴”的功能!
                        PathTracker.SuspendTemprarily(filteredModifiers: GestureModifier.None);//GestureModifier.All &~ args.Modifier);

                        //todo:在这里发布一个事件应该是合理的
                        _effectiveIntent.Execute(args.Context, this);
                    }
                }
            }
            else if (lastEffectiveIntent != null)
            {
                if (IntentInvalid != null)
                {
                    IntentInvalid();
                }
            }
        }
Example #16
0
 public virtual void Stop()
 {
     PathTracker.Stop();
     OnStateChanged(State.STOPPED);
 }
Example #17
0
 public virtual void Start()
 {
     PathTracker.Start();
 }
Example #18
0
        public static void Main(string[] args)
        {
            bool        gamerunning = true;
            bool        paused      = false;
            char        input       = 'X';
            PathTracker pathObject  = new PathTracker();
            EventMagic  eventObject = new EventMagic();

            Console.WriteLine(" ESCAPE FROM CANDYLAND!\n Controls: Press Space to Pause\n New Game Y/N?");
            input = Convert.ToChar(Console.ReadKey().Key);

            if (Char.ToUpper(input) == 'Y')
            {
                Console.Write("\r Good! What else would you be doing?\n");
            }
            else
            {
                Console.Write("\r Well that's a funny way to type 'Y'...\n");
            }

            while (gamerunning)
            {
                do
                {
                    while (!Console.KeyAvailable && gamerunning)
                    {
                        System.Threading.Thread.Sleep(100);
                        Console.Write("\r SPACE:{0} DISTANCE LEFT:{1}", pathObject.currentspot, 1000 - pathObject.currentspot);
                        pathObject.AdvanceSpot();
                        eventObject.PingEvent(pathObject);

                        if (pathObject.currentspot >= 1000)
                        {
                            Console.WriteLine(" You Won! Boy howdy I hope this validates you. Also f**k you.");
                            Console.WriteLine(" Press any key to quit.");
                            Console.ReadKey(true);
                            gamerunning = false;
                        }
                    }
                } while (gamerunning && Console.ReadKey(true).Key != ConsoleKey.Spacebar);

                paused = true;
                Console.WriteLine("");
                while (paused && gamerunning)
                {
                    Console.Write("\r GAME PAUSED. Hit V to View Surroundings, or hit Space to Proceed...\n");
                    input = Convert.ToChar(Console.ReadKey().Key);
                    if (input == ' ')
                    {
                        Console.Write("Game Resumed.\n");
                        paused = false;
                    }
                    else if (Char.ToUpper(input) == 'V')
                    {
                        pathObject.SurroundingsView();
                    }
                    else
                    {
                        Console.Write("Try Again.");
                    }
                }
            }
        }
 public override void TakeParameters(string line)
 {
     string[] arguments = ParsingUtilities.GetQuoteArguments(line);
     copyFromPath = PathTracker.CombineRelativePath(arguments[0]);
     copyToPath   = PathTracker.CombineRelativePath(arguments[1]);
 }
Example #20
0
        public override void TakeParameters(string line)
        {
            string filePathArg = ParsingUtilities.GetQuoteOneArgument(line);

            filePath = PathTracker.CombineRelativePath(filePathArg);
        }
 public override void Execute()
 {
     PathTracker.GetInstance().SetUpPath(newPath);
 }
Example #22
0
 public FileManager()
 {
     SetUpCommands();
     PathTracker.GetInstance().SetUpProjectPath();
 }