Ejemplo n.º 1
0
    void Awake()
    {
        runtimeVariables = RuntimeVariables.GetInstance();
        runtimeVariables.player0RoundsWon = 0;
        runtimeVariables.player1RoundsWon = 0;

        // Check if the player has selected single player mode.
        if (runtimeVariables.isSinglePlayerToggled)
        {
            numberOfPlayers = 1;
        }
        else
        {
            numberOfPlayers = 2;
        }

        player0ThreatenedByProjectileInLane = new bool[desiredDesks];
        player1ThreatenedByProjectileInLane = new bool[desiredDesks];

        SpawnDesks();
        SpawnComputers();
        SpawnServers();
        SetServerPositions(leftServers);
        SetServerPositions(rightServers);
        ZoomCamera();
        SpawnDefenseTriggers();
        SpawnPlayers();
    }
Ejemplo n.º 2
0
        protected override void FileAction(string fileName, string rawLocation)
        {
            string           location = rawLocation + "\\" + fileName;
            StringCollection paths    = Clipboard.GetFileDropList();

            if (paths.Contains(location))
            {
                string s = FileValidator.IsDirectory(fileName) ? "Directory " : "File ";
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! " + s + fileName + " is already cut.");
            }

            try
            {
                paths.Add(location);
                DataObject data = new DataObject();
                data.SetFileDropList(paths);
                data.SetData("Preferred DropEffect", DragDropEffects.Move);
                Clipboard.SetDataObject(data, true);

                RuntimeVariables.GetInstance().Success();
                Logger.GetInstance().LogCommand("Cut " + fileName);
            }
            catch (Exception)
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! Something went wrong during cutting " + fileName + ".");
            }
        }
Ejemplo n.º 3
0
        public void RunListOfFiles()
        {
            decimal previousIndex = RuntimeVariables.GetInstance().GetValueNumber("index");
            string  previousThis  = RuntimeVariables.GetInstance().GetValueString("this");

            RuntimeVariables.GetInstance().Actualize("index", 0);

            List <string> elements = list.ToList();

            foreach (string element in elements)
            {
                RuntimeVariables.GetInstance().Actualize("this", element);

                try
                {
                    Action(element);
                }
                catch (CommandException ce)
                {
                    Logger.GetInstance().LogCommandError(ce.GetMessage());
                }

                RuntimeVariables.GetInstance().IncrementBy("index", 1);
            }

            RuntimeVariables.GetInstance().Actualize("index", previousIndex);
            RuntimeVariables.GetInstance().Actualize("this", previousThis);
        }
Ejemplo n.º 4
0
        protected void AddSecureFilesToEnvironment()
        {
            Trace.Entering();
            ArgUtil.NotNull(ExecutionContext, nameof(ExecutionContext));
            ArgUtil.NotNull(SecureFiles, nameof(SecureFiles));

            List <SecureFile> secureFiles;

            if ((RuntimeVariables.GetBoolean(Constants.Variables.Agent.AllowAllSecureFiles) ?? false) ||
                string.Equals(System.Environment.GetEnvironmentVariable("AGENT_ALLOWALLSECUREFILES") ?? string.Empty, bool.TrueString, StringComparison.OrdinalIgnoreCase))
            {
                secureFiles = ExecutionContext.SecureFiles ?? new List <SecureFile>(0); // todo: remove after sprint 121 or so
            }
            else
            {
                secureFiles = SecureFiles;
            }

            // Add the secure files to the environment variable dictionary.
            foreach (SecureFile secureFile in secureFiles)
            {
                if (secureFile != null && secureFile.Id != Guid.Empty)
                {
                    string partialKey = secureFile.Id.ToString();
                    AddEnvironmentVariable(
                        key: $"SECUREFILE_NAME_{partialKey}",
                        value: secureFile.Name);
                    AddEnvironmentVariable(
                        key: $"SECUREFILE_TICKET_{partialKey}",
                        value: secureFile.Ticket);
                }
            }
        }
Ejemplo n.º 5
0
        public static decimal GetSize(string file)
        {
            if (file.Equals(""))
            {
                return(0);
            }

            string location = RuntimeVariables.GetInstance().GetWholeLocation() + "//" + file;

            try
            {
                if (FileValidator.IsDirectory(location))
                {
                    return((decimal)(DirSize(new DirectoryInfo(@location))));
                }
                else
                {
                    return((decimal)(new System.IO.FileInfo(location).Length));
                }
            }
            catch (Exception)
            {
                return(0);
            }
        }
Ejemplo n.º 6
0
        public override bool HasNext()
        {
            while (true)
            {
                if (list.Count == 0)
                {
                    RuntimeVariables.GetInstance().Actualize("this", previousThis);
                    RuntimeVariables.GetInstance().Actualize("index", previousIndex);
                    RuntimeVariables.GetInstance().RetreatLocation();
                    return(false);
                }
                else
                {
                    string value = list[0];
                    list.RemoveAt(0);
                    RuntimeVariables.GetInstance().ReplaceLocationEnding(value);

                    if (RuntimeVariables.GetInstance().WholeLocationExists())
                    {
                        RuntimeVariables.GetInstance().Actualize("this", value);
                        RuntimeVariables.GetInstance().IncrementBy("index", 1);
                        return(true);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public static bool ReadOnly(string file)
        {
            if (file.Equals(""))
            {
                return(false);
            }

            string location = RuntimeVariables.GetInstance().GetWholeLocation() + "//" + file;

            if (FileValidator.IsDirectory(file))
            {
                if (!Directory.Exists(location))
                {
                    return(false);
                }

                DirectoryInfo info = new DirectoryInfo(location);
                return((info.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly);
            }
            else
            {
                if (!File.Exists(location))
                {
                    return(false);
                }

                FileInfo info = new FileInfo(location);
                return(info.IsReadOnly);
            }
        }
Ejemplo n.º 8
0
        protected void AddPrependPathToEnvironment()
        {
            // Validate args.
            Trace.Entering();
            ArgUtil.NotNull(ExecutionContext.PrependPath, nameof(ExecutionContext.PrependPath));
            if (ExecutionContext.PrependPath.Count == 0)
            {
                return;
            }

            // Prepend path.
            string prepend           = string.Join(Path.PathSeparator.ToString(), ExecutionContext.PrependPath.Reverse <string>());
            var    containerStepHost = StepHost as ContainerStepHost;

            if (containerStepHost != null)
            {
                containerStepHost.PrependPath = prepend;
            }
            else
            {
                string taskEnvPATH;
                Environment.TryGetValue(Constants.PathVariable, out taskEnvPATH);
                string originalPath = RuntimeVariables.Get(Constants.PathVariable) ??                      // Prefer a job variable.
                                      taskEnvPATH ??                                                       // Then a task-environment variable.
                                      System.Environment.GetEnvironmentVariable(Constants.PathVariable) ?? // Then an environment variable.
                                      string.Empty;
                string newPath = PathUtil.PrependPath(prepend, originalPath);
                AddEnvironmentVariable(Constants.PathVariable, newPath);
            }
        }
Ejemplo n.º 9
0
        public static DateTime GetCreation(string file)
        {
            if (file.Equals(""))
            {
                return(DateTime.MinValue);
            }

            string address = RuntimeVariables.GetInstance().GetWholeLocation() + "//" + file;

            try
            {
                if (FileValidator.IsDirectory(file))
                {
                    return(System.IO.Directory.GetCreationTime(@address));
                }
                else
                {
                    return(System.IO.File.GetCreationTime(@address));
                }
            }
            catch (Exception)
            {
                return(DateTime.MinValue);
            }
        }
Ejemplo n.º 10
0
        protected override void DirectoryAction(string directoryName, string rawLocation)
        {
            string location = rawLocation + "\\" + directoryName;

            try
            {
                DirectoryInfo di = new DirectoryInfo(location);
                di.Attributes &= ~FileAttributes.ReadOnly;

                RuntimeVariables.GetInstance().Success();
                Logger.GetInstance().LogCommand("Unlock " + directoryName);
            }
            catch (Exception ex)
            {
                RuntimeVariables.GetInstance().Failure();

                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    throw new CommandException("Action ignored! Access denied during unlocking " + directoryName + ".");
                }
                else
                {
                    throw new CommandException("Action ignored! Something went wrong during unlocking " + directoryName + ".");
                }
            }
        }
Ejemplo n.º 11
0
        public override List <string> ToList()
        {
            List <string> everything = RuntimeVariables.GetInstance().GetValueList("directories");

            everything.AddRange(RuntimeVariables.GetInstance().GetValueList("files"));
            return(everything);
        }
Ejemplo n.º 12
0
        protected override void FileAction(string fileName, string rawLocation)
        {
            string           location = rawLocation + "\\" + fileName;
            StringCollection paths    = Clipboard.GetFileDropList();

            if (paths.Contains(location))
            {
                string s = FileValidator.IsDirectory(fileName) ? "Directory " : "File ";
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! " + s + fileName + " is already copied.");
            }

            try
            {
                paths.Add(location);
                RuntimeVariables.GetInstance().Success();
                Logger.GetInstance().LogCommand("Copy " + fileName);
            }
            catch (Exception)
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! Something went wrong during copying " + fileName + ".");
            }

            Clipboard.SetFileDropList(paths);
        }
Ejemplo n.º 13
0
    public void ShootProjectile(GameObject player, int playerID)
    {
        if (projectiles.Count >= 3)
        {
            return;
        }

        // Depending on the playerID change the rotation of the projectile
        if (RuntimeVariables.GetInstance().isSinglePlayerToggled&& playerID == 1)
        {
            gameObject.GetComponent <NPCControl> ().audioManager.PlayShootVirusSound();
        }
        else
        {
            gameObject.GetComponent <PlayerControl> ().audioManager.PlayShootVirusSound();
        }

        GameObject projectileInstance = (GameObject)Instantiate(projectile, new Vector3(player.transform.position.x + offsetFromPlayer, player.transform.position.y, player.transform.position.z), player.transform.rotation);

        projectileInstance.name = "Player" + playerID + "Projectile";
        projectileInstance.GetComponent <Projectile>().SetProperties(playerID, projectileSpeed, player.GetComponent <PlayerMovement>().CurrentLane);

        if (playerID == 0)
        {
            projectileInstance.transform.rotation = playerOneSpawnRot;
        }
        if (playerID == 1)
        {
            projectileInstance.transform.rotation = playerTwoSpawnRot;
        }

        projectiles.Add(projectileInstance);
    }
Ejemplo n.º 14
0
 public BotFunctionStuff(RuntimeVariables _runvars)
 {
     RunVars          = _runvars;
     nonPrivFunctions = new BotFunctions.NonPriviligedFunctions(RunVars);
     PrivFunctions    = new BotFunctions.PriviligedFunctions(RunVars);
     AddFunctions();
 }
Ejemplo n.º 15
0
        protected override void FileAction(string fileName, string rawLocation)
        {
            string location = rawLocation + "\\" + fileName;

            try
            {
                var attributes = File.GetAttributes(location);
                if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                {
                    attributes &= ~FileAttributes.ReadOnly;
                    File.SetAttributes(location, attributes);
                }

                RuntimeVariables.GetInstance().Success();
                Logger.GetInstance().LogCommand("Unlock " + fileName);
            }
            catch (Exception ex)
            {
                RuntimeVariables.GetInstance().Failure();

                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    throw new CommandException("Action ignored! Access denied during unlocking " + fileName + ".");
                }
                else
                {
                    throw new CommandException("Action ignored! Something went wrong during unlocking " + fileName + ".");
                }
            }
        }
Ejemplo n.º 16
0
        protected override void FileAction(string fileName, string rawLocation)
        {
            string location = rawLocation + "\\" + fileName + "\0";

            try
            {
                SHFILEOPSTRUCT shf = new SHFILEOPSTRUCT();
                shf.wFunc  = FO_DELETE;
                shf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION;
                shf.pFrom  = @location;
                SHFileOperation(ref shf);

                RuntimeVariables.GetInstance().Success();
                Logger.GetInstance().LogCommand("Delete " + fileName);
            }
            catch (Exception ex)
            {
                RuntimeVariables.GetInstance().Failure();

                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    throw new CommandException("Action ignored! Access denied during deleting " + fileName + ".");
                }
                else
                {
                    throw new CommandException("Action ignored! Something went wrong during deleting " + fileName + ".");
                }
            }
        }
Ejemplo n.º 17
0
        public override List <string> ToList()
        {
            List <string> result   = new List <string>();
            decimal       oldIndex = RuntimeVariables.GetInstance().GetValueNumber("index");
            string        oldThis  = RuntimeVariables.GetInstance().GetValueString("this");

            RuntimeVariables.GetInstance().Actualize("index", 0);

            foreach (string element in leftSide.ToList())
            {
                RuntimeVariables.GetInstance().Actualize("this", element);

                string value = rightSide.ToString();
                if (unique)
                {
                    if (!result.Contains(value))
                    {
                        result.Add(value);
                    }
                }
                else
                {
                    result.Add(value);
                }

                RuntimeVariables.GetInstance().PlusPlus("index");
            }

            RuntimeVariables.GetInstance().Actualize("index", oldIndex);
            RuntimeVariables.GetInstance().Actualize("this", oldThis);
            return(result);
        }
Ejemplo n.º 18
0
        private static int JumpOverBlockOfCode(List <ICommand> commands, int oldPosition)
        {
            RuntimeVariables.GetInstance().BracketsDown();

            int level       = 0;
            int newPosition = oldPosition + 1;

            while (newPosition < commands.Count())
            {
                ICommand takenCommand = commands[newPosition];

                if (takenCommand is BracketOn)
                {
                    level++;
                }

                if (takenCommand is BracketOff)
                {
                    level--;
                    if (level == -1)
                    {
                        return(newPosition);
                    }
                }
                newPosition++;
            }
            return(newPosition);
        }
Ejemplo n.º 19
0
        public static bool Hidden(string file)
        {
            if (file.Equals(""))
            {
                return(false);
            }

            string location = RuntimeVariables.GetInstance().GetWholeLocation() + "//" + file;

            if (FileValidator.IsDirectory(file))
            {
                if (!Directory.Exists(location))
                {
                    return(false);
                }

                DirectoryInfo info = new DirectoryInfo(location);
                return((info.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden);
            }
            else
            {
                if (!File.Exists(location))
                {
                    return(false);
                }

                return(File.GetAttributes(location).HasFlag(FileAttributes.Hidden));
            }
        }
Ejemplo n.º 20
0
        public NumericLoop(int repeats, int commandNumber)
        {
            this.repeats       = repeats;
            this.commandNumber = commandNumber;

            previousIndex = RuntimeVariables.GetInstance().GetValueNumber("index");
        }
Ejemplo n.º 21
0
        public Inside(List <string> list, int commandNumber)
        {
            this.list          = list;
            this.commandNumber = commandNumber;

            previousThis  = RuntimeVariables.GetInstance().GetValueString("this");
            previousIndex = RuntimeVariables.GetInstance().GetValueNumber("index");
        }
Ejemplo n.º 22
0
        protected override void FileAction(string fileName, string rawLocation)
        {
            string directoryName = destination.ToString();

            if (!FileValidator.IsNameCorrect(directoryName))
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! " + directoryName + " contains not allowed characters.");
            }

            string newFileName = newName.ToString();

            if (!FileValidator.IsNameCorrect(newFileName))
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! " + newFileName + " contains not allowed characters.");
            }
            if (FileValidator.IsDirectory(newFileName))
            {
                string extension = FileInnerVariable.GetExtension(fileName);
                newFileName += "." + extension;
            }

            string oldLocation = rawLocation + "//" + fileName;
            string newLocation = rawLocation + "//" + directoryName + "//" + newFileName;


            if (!Directory.Exists(rawLocation + "//" + directoryName))
            {
                Directory.CreateDirectory(rawLocation + "//" + directoryName);
            }


            try
            {
                if (forced && File.Exists(newLocation))
                {
                    File.Delete(@newLocation);
                }
                File.Move(@oldLocation, @newLocation);

                RuntimeVariables.GetInstance().Success();
                Logger.GetInstance().LogCommand("Move " + fileName + " to " + directoryName + " as " + newFileName);
            }
            catch (Exception ex)
            {
                RuntimeVariables.GetInstance().Failure();

                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    throw new CommandException("Action ignored! Access denied during moving " + fileName + " to " + directoryName + " as " + newFileName + ".");
                }
                else
                {
                    throw new CommandException("Action ignored! Something went wrong during moving " + fileName + " to " + directoryName + " as " + newFileName + ".");
                }
            }
        }
Ejemplo n.º 23
0
    public static RuntimeVariables GetInstance()
    {
        if (instance == null)
        {
            instance = new RuntimeVariables();
        }

        return(instance);
    }
Ejemplo n.º 24
0
        protected override void DirectoryAction(string movingDirectoryName, string rawLocation)
        {
            string directoryName = destination.ToString();

            if (directoryName.Equals(movingDirectoryName))
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! Directory " + directoryName + " cannot be copied to itself.");
            }


            if (!FileValidator.IsNameCorrect(directoryName))
            {
                RuntimeVariables.GetInstance().Failure();
                throw new CommandException("Action ignored! " + directoryName + " contains not allowed characters.");
            }


            string oldLocation = rawLocation + "//" + movingDirectoryName;
            string newLocation = rawLocation + "//" + directoryName + "//" + movingDirectoryName;


            if (!Directory.Exists(rawLocation + "//" + directoryName))
            {
                Directory.CreateDirectory(rawLocation + "//" + directoryName);
            }

            if (!Directory.Exists(rawLocation + "//" + directoryName + "//" + movingDirectoryName))
            {
                Directory.CreateDirectory(rawLocation + "//" + directoryName + "//" + movingDirectoryName);
            }


            try
            {
                if (forced && Directory.Exists(newLocation))
                {
                    Directory.Delete(@newLocation, true);
                }
                DirectoryCopy(@oldLocation, @newLocation);
                RuntimeVariables.GetInstance().Success();
                Logger.GetInstance().LogCommand("Copy " + movingDirectoryName + " to " + directoryName);
            }
            catch (Exception ex)
            {
                RuntimeVariables.GetInstance().Failure();

                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    throw new CommandException("Action ignored! Access denied during coping " + movingDirectoryName + " to " + directoryName + ".");
                }
                else
                {
                    throw new CommandException("Action ignored! Something went wrong during coping " + movingDirectoryName + " to " + directoryName + ".");
                }
            }
        }
Ejemplo n.º 25
0
        public static bool Empty(string file)
        {
            // need to thing about thie method

            if (file.Equals(""))
            {
                return(true);
            }

            string location = RuntimeVariables.GetInstance().GetWholeLocation() + "//" + file;

            if (FileValidator.IsDirectory(file))
            {
                if (Directory.Exists(@location))
                {
                    try
                    {
                        return(Directory.EnumerateFileSystemEntries(location).Any() ? false : true);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                if (File.Exists(@location))
                {
                    try
                    {
                        if (new FileInfo(location).Length == 0)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
        }
Ejemplo n.º 26
0
        public static bool ExistInside(string file, string directory)
        {
            string directoryLocation = RuntimeVariables.GetInstance().GetWholeLocation() + "//" + directory;

            if (!Directory.Exists(@directoryLocation))
            {
                return(false);
            }

            return(Exist(directory + "//" + file));
        }
Ejemplo n.º 27
0
        public override int Run(InterpretedFrame frame)
        {
            var ret = new IStrongBox[_count];

            for (int i = ret.Length - 1; i >= 0; i--)
            {
                ret[i] = (IStrongBox)frame.Pop();
            }

            frame.Push(RuntimeVariables.Create(ret));
            return(+1);
        }
Ejemplo n.º 28
0
    void Start()
    {
        GameObject.Find("WinText").GetComponent <Text>().text = "Player " + (RuntimeVariables.GetInstance().lastPlayerToWin + 1) + " Wins!";

        if (RuntimeVariables.GetInstance().lastPlayerToWin == 0)
        {
            player1Wins.Play();
        }
        else if (RuntimeVariables.GetInstance().lastPlayerToWin == 1)
        {
            player2Wins.Play();
        }
    }
Ejemplo n.º 29
0
        public override DateTime ToTime()
        {
            string file = RuntimeVariables.GetInstance().GetValueString("this");

            try
            {
                return(FileInnerVariable.GetCreation(file));
            }
            catch (Exception)
            {
                return(DateTime.MinValue);
            }
        }
Ejemplo n.º 30
0
    void Start()
    {
        playerID         = GetComponent <PlayerProperties>().playerID;
        playerObj        = gameObject;
        playerMovement   = GetComponent <PlayerMovement>();
        playerShooting   = GetComponent <PlayerShooting>();
        playerBuilding   = GetComponent <PlayerBuilding>();
        runtimeVariables = RuntimeVariables.GetInstance();
        pauseManager     = GameObject.Find("SceneManager").GetComponent <PauseManager>();

        audioManager.StopFirewallBuildingSound();
        SetupControls();
        SetupComputers();
    }
Ejemplo n.º 31
0
 public BotFunctionStuff(RuntimeVariables _runvars)
 {
     RunVars = _runvars;
     nonPrivFunctions = new BotFunctions.NonPriviligedFunctions(RunVars);
     PrivFunctions = new BotFunctions.PriviligedFunctions(RunVars);
     AddFunctions();
 }