void ExecuteInitPs1(string installPath, PackageIdentity identity)
        {
            try {
                var toolsPath = Path.Combine(installPath, "tools");
                if (Directory.Exists(toolsPath))
                {
                    AddPathToEnvironment(toolsPath);

                    var scriptPath = Path.Combine(toolsPath, PowerShellScripts.Init);
                    if (File.Exists(scriptPath) &&
                        ConsoleHost.TryMarkInitScriptVisited(identity, PackageInitPS1State.FoundAndExecuted))
                    {
                        var packageScript = new PackageScript(
                            scriptPath,
                            installPath,
                            identity,
                            null);

                        var scriptRunner = (IPackageScriptRunner)this;
                        scriptRunner.Run(packageScript);

                        return;
                    }
                }

                ConsoleHost.TryMarkInitScriptVisited(identity, PackageInitPS1State.NotFound);
            } catch (Exception ex) {
                // If execution of an init.ps1 scripts fails, do not let it crash our console.
                ReportError(ex.Message);
            }
        }
    // spawns 2-3 packages randomly
    public void spawnNextPackage()
    {
        // get random package and destination
        int randomPackage     = 0;
        int randomDestination = 1;

        // offset by 1 since randomDestination starts from 1
        while (randomPackage + 1 == randomDestination)
        {
            randomPackage     = Random.Range(0, packageLocations.childCount);
            randomDestination = Random.Range(1, destinationLocations.childCount);
        }

        GameObject package     = packageLocations.GetChild(randomPackage).gameObject;
        GameObject destination = destinationLocations.GetChild(randomDestination).gameObject;

        PackageScript packageScript = package.GetComponent <PackageScript>();

        // update package value
        packageScript.value = newPackageValue;
        newPackageValue    += NEW_PACKAGE_VALUE;
        packageScript.updateValueText();

        // show package
        package.SetActive(true);

        // assign destination
        packageScript.destination = destination;

        // show destinaton pointer
        // packageScript.destination.GetComponent<DestinationScript>().showPointer(true);
    }
Example #3
0
        public override bool Execute()
        {
            var pkgPath = Package.ItemSpec;

            var defines = Defines.IsNullOrEmpty() ? new string[0] : Defines.Select(each => each.ItemSpec).ToArray();

            try {
                using (var script = new PackageScript(pkgPath)) {
                    if (PackageDirectory.Is())
                    {
                        script.AddNuGetPackageDirectory(PackageDirectory.GetFullPath());
                    }
                    if (defines != null)
                    {
                        foreach (var i in defines)
                        {
                            var p = i.IndexOf("=");
                            var k = p > -1 ? i.Substring(0, p) : i;
                            var v = p > -1 ? i.Substring(p + 1) : "";
                            script.AddMacro(k, v);
                        }
                    }
                    IEnumerable <string> overlayFiles;
                    var pkg = script.Save(PackageTypes.NuGet, true, false, out overlayFiles);

                    OverlayPackages = overlayFiles.Select(each => (ITaskItem) new TaskItem(each)).ToArray();
                    MainPackages    = new ITaskItem[] { new TaskItem(pkg) };
                    OverlayPackages = new ITaskItem[0];

                    /*
                     * AllPackages = script.AllPackages.Select(each => (ITaskItem)new TaskItem(each)).ToArray();
                     *
                     * // AllPackages = script.Packages.Select(each => (ITaskItem)new TaskItem(each)).ToArray();
                     *
                     * OverlayPackages = AllPackages.Where(each => each.ItemSpec.ToLower().IndexOf("overlay") > -1).ToArray();
                     * SymbolsPackages = AllPackages.Where(each => each.ItemSpec.ToLower().IndexOf("symbols") > -1).ToArray();
                     * MainPackages = AllPackages.Where(each => each.ItemSpec.ToLower().IndexOf("overlay") == -1 && each.ItemSpec.ToLower().IndexOf("symbols") == -1).ToArray();
                     *
                     * foreach (var p in OverlayPackages) {
                     *  var n = Path.GetFileNameWithoutExtension(p.ItemSpec);
                     *  var o = n.IndexOf(".overlay.");
                     *
                     *  p.SetMetadata("pkgIdentity", "{0} {1}".format(n.Substring(0, o + 7), n.Substring(o + 8)));
                     * }
                     */


                    NuGetSuccess = true;
                    return(true);
                }
            } catch {
            }
            NuGetSuccess = false;
            return(false);
        }
    void pickupPackage(GameObject target)
    {
        // pickup package
        currentPackage = target;

        // hide package
        target.SetActive(false);

        // activate destination pointer
        PackageScript packageScript = currentPackage.GetComponent <PackageScript>();

        packageScript.destination.GetComponent <DestinationScript>().showPointer(true);
    }
        public override bool Execute() {
            var pkgPath = Package.ItemSpec;

            var defines = Defines.IsNullOrEmpty() ? new string[0] : Defines.Select(each => each.ItemSpec).ToArray();

            try {
                using (var script = new PackageScript(pkgPath)) {
                    if (PackageDirectory.Is()) {
                        script.AddNuGetPackageDirectory(PackageDirectory.GetFullPath());
                    }
                    if (defines != null) {
                        foreach (var i in defines) {
                            var p = i.IndexOf("=");
                            var k = p > -1 ? i.Substring(0, p) : i;
                            var v = p > -1 ? i.Substring(p + 1) : "";
                            script.AddMacro(k, v);
                        }
                    }
                    IEnumerable<string> overlayFiles;
                    var pkg = script.Save(PackageTypes.NuGet, true, false, out overlayFiles);

                    OverlayPackages = overlayFiles.Select(each => (ITaskItem)new TaskItem(each)).ToArray();
                    MainPackages = new ITaskItem[] { new TaskItem(pkg) };
                    OverlayPackages = new ITaskItem[0];

                    /*
                    AllPackages = script.AllPackages.Select(each => (ITaskItem)new TaskItem(each)).ToArray();

                    // AllPackages = script.Packages.Select(each => (ITaskItem)new TaskItem(each)).ToArray();

                    OverlayPackages = AllPackages.Where(each => each.ItemSpec.ToLower().IndexOf("overlay") > -1).ToArray();
                    SymbolsPackages = AllPackages.Where(each => each.ItemSpec.ToLower().IndexOf("symbols") > -1).ToArray();
                    MainPackages = AllPackages.Where(each => each.ItemSpec.ToLower().IndexOf("overlay") == -1 && each.ItemSpec.ToLower().IndexOf("symbols") == -1).ToArray();

                    foreach (var p in OverlayPackages) {
                        var n = Path.GetFileNameWithoutExtension(p.ItemSpec);
                        var o = n.IndexOf(".overlay.");

                        p.SetMetadata("pkgIdentity", "{0} {1}".format(n.Substring(0, o + 7), n.Substring(o + 8)));
                    }
                    */


                    NuGetSuccess = true;
                    return true;
                }
            } catch {
            }
            NuGetSuccess = false;
            return false;
        }
        public Task ExecuteScriptAsync(
            PackageIdentity identity,
            string packageInstallPath,
            string scriptRelativePath,
            IDotNetProject project,
            INuGetProjectContext nuGetProjectContext,
            bool throwOnFailure)
        {
            string scriptPath = Path.Combine(packageInstallPath, scriptRelativePath);

            if (!File.Exists(scriptPath))
            {
                if (IsInitScript(scriptPath))
                {
                    TryMarkVisited(identity, PackageInitPS1State.NotFound);
                }
                return(Task.FromResult(0));
            }

            if (IsInitScript(scriptPath) &&
                !TryMarkVisited(identity, PackageInitPS1State.FoundAndExecuted))
            {
                return(Task.FromResult(0));
            }

            var packageScript = new PackageScript(
                scriptPath,
                packageInstallPath,
                identity,
                project);

            var scriptRunner = nuGetProjectContext as IPackageScriptRunner;

            if (scriptRunner != null)
            {
                scriptRunner.Run(packageScript);
            }

            return(Task.FromResult(0));
        }
    void deliverPackage(GameObject target)
    {
        PackageScript packageScript = currentPackage.GetComponent <PackageScript>();

        bool isStolen = target.name == "home";

        if (target == packageScript.destination || isStolen)
        {
            int packageValue = packageScript.value;

            // add cash
            cash += isStolen ? packageValue * GameManager.instance.STEAL_MULTIPLIER : packageValue;

            // if goal is reached => update goal & new packageValue*1.5 + new time
            if (cash >= goal)
            {
                goal *= 4;
                GameManager.instance.goalWasReached();
            }

            // update score
            UIManager.instance.updateCash(cash, goal);


            // if isStolen => time penalty
            GameManager.instance.timePenalty(isStolen);

            // play audio
            gameObject.GetComponent <AudioSource>().Play();

            // hide destination pointer
            packageScript.destination.GetComponent <DestinationScript>().showPointer(false);

            // release current package;
            currentPackage = null;

            // spawn new package
            GameManager.instance.spawnNextPackage();
        }
    }
Example #8
0
        private void Start(string[] args)
        {
            CurrentTask.Events += new SourceError((code, location, message, objects) => {
                location = location ?? SourceLocation.Unknowns;
                Console.WriteLine("{0}:Error {1}:{2}", location.FirstOrDefault(), code, message.format(objects));
                return(true);
            });

            CurrentTask.Events += new SourceWarning((code, location, message, objects) => {
                location = location ?? SourceLocation.Unknowns;
                Console.WriteLine("{0}:Warning {1}:{2}", location.FirstOrDefault(), message.format(objects));
                return(false);
            });

            CurrentTask.Events += new SourceDebug((code, location, message, objects) => {
                location = location ?? SourceLocation.Unknowns;
                Console.WriteLine("{0}:DebugMessage {1}:{2}", location.FirstOrDefault(), code, message.format(objects));
                return(false);
            });

            CurrentTask.Events += new Error((code, message, objects) => {
                Console.WriteLine("{0}:Error {1}", code, message.format(objects));
                return(true);
            });

            CurrentTask.Events += new Warning((code, message, objects) => {
                Console.WriteLine("{0}:Warning {1}", code, message.format(objects));
                return(false);
            });

            CurrentTask.Events += new Debug((code, message, objects) => {
                Console.WriteLine("{0}:DebugMessage {1}", code, message.format(objects));
                return(false);
            });

            CurrentTask.Events += new Verbose((code, message, objects) => {
                Console.WriteLine("{0}:Verbose {1}", code, message.format(objects));
                return(false);
            });
            CurrentTask.Events += new Message((code, message, objects) => {
                Console.WriteLine("{0}:Message {1}", code, message.format(objects));
                return(false);
            });

#if true
            try {
                Environment.CurrentDirectory = @"C:\root\V2\coapp-packages\openssl\copkg";
                Console.WriteLine("Package script");
                using (var script = new PackageScript("openssl.autopkg")) {
                    script.Save(PackageTypes.NuGet, false);
                }
                Console.WriteLine();
            } catch (Exception e) {
                Console.WriteLine("{0} =>\r\n\r\nat {1}", e.Message, e.StackTrace.Replace("at ClrPlus.Scripting.Languages.PropertySheetV3.PropertySheetParser", "PropertySheetParser"));
            }
#else
            try {
                // Environment.CurrentDirectory = @"C:\project";
                Console.WriteLine("Build script");
                using (var script = new BuildScript("test.buildinfo")) {
                    script.Execute();
                }
            } catch (Exception e) {
                Console.WriteLine("{0} =>\r\n\r\nat {1}", e.Message, e.StackTrace.Replace("at ClrPlus.Scripting.Languages.PropertySheetV3.PropertySheetParser", "PropertySheetParser"));
            }
#endif
            return;
            //
        }
Example #9
0
        protected override void ProcessRecord()
        {
#if USING_RESTABLE_CMDLET
            if (Remote)
            {
                ProcessRecordViaRest();
                return;
            }
#endif

            ProviderInfo packagePathProviderInfo;
            var          pkgPath = SessionState.Path.GetResolvedProviderPathFromPSPath(Package, out packagePathProviderInfo);

            using (var local = LocalEventSource) {
                local.Events += new SourceError((code, location, message, objects) => {
                    location = location ?? SourceLocation.Unknowns;
                    Host.UI.WriteErrorLine("{0}:Error {1}:{2}".format(location.FirstOrDefault(), code, message.format(objects)));
                    return(true);
                });

                if (!NoWarnings)
                {
                    local.Events += new SourceWarning((code, location, message, objects) => {
                        WriteWarning("{0}:Warning {1}:{2}".format((location ?? SourceLocation.Unknowns).FirstOrDefault(), message.format(objects)));
                        return(false);
                    });
                }

                local.Events += new SourceDebug((code, location, message, objects) => {
                    WriteVerbose("{0}:DebugMessage {1}:{2}".format((location ?? SourceLocation.Unknowns).FirstOrDefault(), code, message.format(objects)));
                    return(false);
                });

                using (var script = new PackageScript(pkgPath.FirstOrDefault())) {
                    script.SplitThreshold = SplitThreshold * 1024 * 1024;

                    if (PackageDirectory.Is())
                    {
                        script.AddNuGetPackageDirectory(PackageDirectory.GetFullPath());
                    }
                    if (Defines != null)
                    {
                        foreach (var i in Defines)
                        {
                            var p = i.IndexOf("=");
                            var k = p > -1 ? i.Substring(0, p) : i;
                            var v = p > -1 ? i.Substring(p + 1) : "";
                            script.AddMacro(k, v);
                        }
                    }
                    if (Define != null)
                    {
                        foreach (var i in Define)
                        {
                            var p = i.IndexOf("=");
                            var k = p > -1 ? i.Substring(0, p) : i;
                            var v = p > -1 ? i.Substring(p + 1) : "";
                            script.AddMacro(k, v);
                        }
                    }
                    IEnumerable <string> overlayPackages;
                    var pkgFile = script.Save(PackageTypes.NuGet, !NoClean, GenerateOnly, out overlayPackages);
                }
            }
        }