Exemplo n.º 1
0
        /// <summary>
        ///     Create a new GhostscriptJob instance
        /// </summary>
        /// <param name="jobInfo">JobInfo of the job to convert</param>
        /// <param name="profile">Profile that determines the conversion process</param>
        /// <param name="tempFolder">
        ///     TempFolderProvider that gives the full Temp path, i.e. C:\Users\Admin\Local
        ///     Settings\Temp\clawPDF
        /// </param>
        /// <param name="jobTranslations">Translations needed for the job</param>
        /// <param name="fileWrap">Only for testing</param>
        /// <param name="directoryWrap">Only for testing</param>
        public GhostscriptJob(IJobInfo jobInfo, ConversionProfile profile, JobTranslations jobTranslations,
                              ITempFolderProvider tempFolder, IFile fileWrap, IDirectory directoryWrap)
            : base(jobInfo, profile, jobTranslations, fileWrap, directoryWrap)
        {
            var gsVersion = new GhostscriptDiscovery().GetBestGhostscriptInstance();

            if (gsVersion == null)
            {
                Logger.Error("No valid Ghostscript version found.");
                throw new InvalidOperationException("No valid Ghostscript version found.");
            }

            Logger.Debug("Ghostscript Version: " + gsVersion.Version + " loaded from " + gsVersion.DllPath);
            _ghostScript = new GhostScript(gsVersion);

            JobTempFolder = PathSafe.Combine(tempFolder.TempFolder,
                                             "Job_" + PathSafe.GetFileNameWithoutExtension(PathSafe.GetRandomFileName()));
            JobTempOutputFolder = PathSafe.Combine(JobTempFolder, "tempoutput");
            DirectoryWrap.CreateDirectory(JobTempFolder);
            DirectoryWrap.CreateDirectory(JobTempOutputFolder);

            // Shorten the temp folder for GS compatibility
            //缩短临时文件夹以实现GS兼容性
            JobTempFolder = JobTempFolder;
        }
Exemplo n.º 2
0
    void Start()
    {
        this.aud = GetComponent <AudioSource>();
        //this.aud.PlayOneShot(startSE);

        navMeshsurfase.BuildNavMesh();

        pacmanScript = pacman.GetComponent <PlayerScript>();

        blinky.GetComponent <NavMeshAgent>().enabled = false;
        inky.GetComponent <NavMeshAgent>().enabled   = false;
        pinky.GetComponent <NavMeshAgent>().enabled  = false;
        clyde.GetComponent <NavMeshAgent>().enabled  = false;

        blinkyScript = blinky.GetComponent <GhostScript>();
        inkyScript   = inky.GetComponent <GhostScript>();
        pinkyScript  = pinky.GetComponent <GhostScript>();
        clydeScript  = clyde.GetComponent <GhostScript>();

        blinkyScript.SetState(GhostState.usual);
        inkyScript.SetState(GhostState.waiting);
        pinkyScript.SetState(GhostState.waiting);
        clydeScript.SetState(GhostState.waiting);

        sightBlinky.SetActive(true);
        navRouteBlinky.SetActive(true);

        StartCoroutine(LetsStart());
        StartCoroutine(ShowFruits(30));
    }
Exemplo n.º 3
0
    void Explode()
    {
        explosionSound.Play();
        GameObject explosionObject = Instantiate(explosionEffect, transform.position, transform.rotation) as GameObject;

        explosionObject.transform.localScale = new Vector3(explosionSize, explosionSize, explosionSize);
        Destroy(explosionObject, 1.9f);

        Collider[] colliders = Physics.OverlapSphere(transform.position, radius);

        foreach (Collider nearbyObject in colliders)
        {
            Rigidbody rb = nearbyObject.GetComponent <Rigidbody>();

            /*if (rb != null)
             * {
             *  rb.AddExplosionForce(force, transform.position, radius);
             * }*/

            if (nearbyObject.tag == "bozu")
            {
                GhostScript ghost = nearbyObject.GetComponent <GhostScript>();
                if (ghost != null)
                {
                    ghost.Die();
                }
            }
        }
        Destroy(gameObject);
    }
Exemplo n.º 4
0
        private string GetPageImageWithGhostScript(int pageNumber, string sessionName)
        {
            GhostScript g       = new GhostScript(GhostScriptPath, _dpi);
            string      imgFile = g.ConvertPdfToBitmap(SourcePdf, pageNumber, pageNumber, sessionName);

            return(imgFile);
        }
Exemplo n.º 5
0
    IEnumerator Pickup(Collider player)
    {
        Instantiate(pickupEffect, transform.position, transform.rotation);

        GetComponent <MeshRenderer> ().enabled = false;
        GetComponent <Collider> ().enabled     = false;

        ghost = GameObject.Find("GhostRed").GetComponent <GhostScript> ();
        ghost.makeGhostBlue();
        ghost = GameObject.Find("GhostYellow").GetComponent <GhostScript> ();
        ghost.makeGhostBlue();
        ghost = GameObject.Find("GhostGreen").GetComponent <GhostScript> ();
        ghost.makeGhostBlue();
        ghost = GameObject.Find("GhostCyan").GetComponent <GhostScript> ();
        ghost.makeGhostBlue();

        yield return(new WaitForSeconds(duration));

        ghost = GameObject.Find("GhostRed").GetComponent <GhostScript> ();
        ghost.getDefaultColorback();
        ghost = GameObject.Find("GhostYellow").GetComponent <GhostScript> ();
        ghost.getDefaultColorback();
        ghost = GameObject.Find("GhostGreen").GetComponent <GhostScript> ();
        ghost.getDefaultColorback();
        ghost = GameObject.Find("GhostCyan").GetComponent <GhostScript> ();
        ghost.getDefaultColorback();

        Destroy(gameObject);
    }
Exemplo n.º 6
0
        public string NextPage(string sessionID)
        {
            var bytes       = (byte[])TempData["pdfBin_" + sessionID];
            int currentPage = (int)TempData["pageNumber_" + sessionID];

            TempData.Remove("pdfBin_" + sessionID);
            TempData.Remove("pageNumber_" + sessionID);
            TempData.Add("pdfBin_" + sessionID, bytes);

            if (bytes == null)
            {
                return("");
            }

            var base64string = GhostScript.RasterizePdf(bytes).ToBase64Strings();
            int totalPage    = base64string.Count();

            if (currentPage < totalPage)
            {
                TempData.Add("pageNumber_" + sessionID, currentPage + 1);
                return(base64string[currentPage]);
            }
            else
            {
                TempData.Add("pageNumber_" + sessionID, currentPage);
                return(base64string[currentPage - 1]);
            }
        }
Exemplo n.º 7
0
    IEnumerator Pickup(Collider player)
    {
        Instantiate(pickupEffect, transform.position, transform.rotation);

        GetComponent <MeshRenderer> ().enabled = false;
        GetComponent <Collider> ().enabled     = false;

        ghost = GameObject.Find("GhostRed").GetComponent <GhostScript> ();
        ghost.makeGhostSlow();
        ghost = GameObject.Find("GhostYellow").GetComponent <GhostScript> ();
        ghost.makeGhostSlow();
        ghost = GameObject.Find("GhostGreen").GetComponent <GhostScript> ();
        ghost.makeGhostSlow();
        ghost = GameObject.Find("GhostCyan").GetComponent <GhostScript> ();
        ghost.makeGhostSlow();

        yield return(new WaitForSeconds(duration));

        ghost = GameObject.Find("GhostRed").GetComponent <GhostScript> ();
        ghost.makeGhostFast();
        ghost = GameObject.Find("GhostYellow").GetComponent <GhostScript> ();
        ghost.makeGhostFast();
        ghost = GameObject.Find("GhostGreen").GetComponent <GhostScript> ();
        ghost.makeGhostFast();
        ghost = GameObject.Find("GhostCyan").GetComponent <GhostScript> ();
        ghost.makeGhostFast();

        //powerUpCube.SetActive (false);


        Destroy(gameObject);
    }
Exemplo n.º 8
0
 public void RotateGhost()
 {
     if (GhostObject != null)
     {
         GhostScript ghostScript = GhostObject.GetComponent <GhostScript>();
         ghostScript.Rotate();
     }
 }
Exemplo n.º 9
0
 // Poruszanie obiektem Ghost
 private void GhostMove(float up, float down, float left, float right)
 {
     if (GhostObject != null)
     {
         GhostScript ghostScript = GhostObject.GetComponent <GhostScript>();
         ghostScript.MoveGhost(up, down, left, right);
     }
 }
Exemplo n.º 10
0
 void enableElevatorGhosts()
 {
     GameObject[] elevatorGhosts = GameObject.FindGameObjectsWithTag("ElevatorGhost");
     foreach (GameObject ghost in elevatorGhosts)
     {
         GhostScript script = ghost.GetComponent <GhostScript>();
         script.StartMoving();
     }
 }
Exemplo n.º 11
0
    public void Unpossess(GhostScript argGhost)
    {
        argGhost.Show();
        argGhost.Transform.position = Renderer.bounds.max + Vector3.up;
        print("I AM GETTING CALLED");
        DisablePlayerControl();
        print("NO REALLY I AM PLEASE BELIVE ME");
        print("I'LL DO ANYTHING");
        argGhost.EnablePlayerControl();

        argGhost.Transform.LookAt(Transform);
    }
Exemplo n.º 12
0
 public void Pickup(GhostScript player)
 {
     if (player.poss) {
         gameManager.flashText(collectedText);
         gameManager.pickupTotem (transform.name);
         audio.clip = pickupClip;
         audio.Play();
         Destroy (gameObject, audio.clip.length);
     } else {
         gameManager.flashText(lockedText);
         audio.clip = failClip;
         audio.Play();
     }
 }
Exemplo n.º 13
0
    // Use this for initialization
    void Start()
    {
        lifeManager = GameObject.Find("LifeManager").GetComponent <LoseLifeManager> ();
        QualitySettings.vSyncCount = 0;
        count     = 0;
        countLife = lifeManager.getLifesCounter();
        SetCountText();

        initialPosition = transform.position;
        animator        = GetComponent <Animator>();
        ghost           = GameObject.Find("GhostRed").GetComponent <GhostScript> ();

        Reset();
    }
Exemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        cannonScript     = cannonObject.GetComponent <CannonScript>();
        source           = this.GetComponent <AudioSource>();
        ghostShip        = ghostShipObject.GetComponent <GhostShipScript>();
        ghost            = ghostObject.GetComponent <GhostScript>();
        difficultyScript = GameObject.FindGameObjectWithTag("Difficulty").GetComponent <DifficultyScript>();

        if (difficultyScript.isLegendaryMode == true)
        {
            ghost.GetComponentInChildren <SkinnedMeshRenderer>().material = legendaryGhost;
            ghost.LegendaryGhost();
        }
    }
Exemplo n.º 15
0
        public Tuple <byte[], string> CreateSearchablePdf(byte[] fileData, PdfMeta metaData)
        {
            try
            {
                int    PageCountStart = GetPages(fileData);
                string sessionName    = TempData.Instance.CreateNewSession();
                OnCompressorEvent?.Invoke("Created Session:" + sessionName);
                string inputDataFilePath  = TempData.Instance.CreateTempFile(sessionName, ".pdf");
                string outputDataFilePath = TempData.Instance.CreateTempFile(sessionName, ".pdf");
                if (fileData == null || fileData.Length == 0)
                {
                    throw new Exception("No Data in fileData");
                }
                using (FileStream writer = new FileStream(inputDataFilePath, FileMode.Create, FileAccess.Write))
                {
                    writer.Write(fileData, 0, fileData.Length);
                    writer.Flush(true);
                }

                OnCompressorEvent?.Invoke(sessionName + " Wrote binary to file");
                OnCompressorEvent?.Invoke(sessionName + " Begin Compress and Ocr");
                string pageBody       = CompressAndOcr(sessionName, inputDataFilePath, outputDataFilePath, metaData);
                string outputFileName = outputDataFilePath;
                if (PdfSettings.CompressFinalPdf)
                {
                    OnCompressorEvent?.Invoke(sessionName + " Compressing output");
                    GhostScript gs = new GhostScript(GhostScriptPath, PdfSettings.Dpi);
                    outputFileName = gs.CompressPdf(outputDataFilePath, sessionName, PdfSettings.PdfCompatibilityLevel, PdfSettings.DistillerMode,
                                                    PdfSettings.DistillerOptions);
                }

                byte[] outFile      = File.ReadAllBytes(outputFileName);
                int    PageCountEnd = GetPages(outFile);
                OnCompressorEvent?.Invoke(sessionName + " Destroying session");
                TempData.Instance.DestroySession(sessionName);

                if (PageCountEnd != PageCountStart)
                {
                    throw new PageCountMismatchException("Page count is different", PageCountStart, PageCountEnd);
                }

                return(new Tuple <byte[], string>(outFile, pageBody));
            }
            catch (Exception e)
            {
                OnExceptionOccurred?.Invoke(this, e);
                throw new FailedToGenerateException("Error in: CreateSearchablePdf", e);
            }
        }
Exemplo n.º 16
0
    private void Awake()
    {
        _gameManager = GameObject.Find("GameManager").GetComponent <GameManager>() as GameManager;
        _playerGhost = Ghost.GetComponent <GhostScript>() as GhostScript;

        _rounds           = _gameManager.Rounds;
        _ghostWin         = _gameManager.Score[0];
        _minerWin         = _gameManager.Score[1];
        LanternsCollected = 0;

        TxtRounds.text            = "Round: " + _currentround;
        TxtGhostWins.text         = "GhostWins: " + _ghostWin;
        TxtMinerWins.text         = "MinerWins: " + _minerWin;
        TxtLanternsCollected.text = "Lanterns Collected: " + LanternsCollected;
    }
Exemplo n.º 17
0
    void SpawnBozu()
    {
        if (bozuAmt < maxBozuAmt)
        {
            float spawnX = Random.Range(minX, maxX);
            float spawnZ = Random.Range(minZ, maxZ);
            float spawnY = yCoord;


            Ray        ray = new Ray(new Vector3(spawnX, 100f, spawnZ), Vector3.down);
            RaycastHit hit;

            bool wallCollide = false;

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.tag.Equals("wall"))
                {
                    wallCollide = true;
                    SpawnBozu();
                }
            }

            Vector3 spawnLoc = new Vector3(spawnX, spawnY, spawnZ);
            if (!wallCollide && (player == null || Vector3.Distance(spawnLoc, player.transform.position) > 40f))
            {
                GameObject  current = Instantiate(bozu, spawnLoc, Quaternion.identity);
                GhostScript ghost   = current.GetComponent <GhostScript>();
                ghost.moveSpeed = bozuSpeed;

                bozuAmt++;
                if (bozuWander)
                {
                    ghost.wander = true;
                    ghost.Pause();
                }
            }
            else
            {
                // if (player != null)
                {
                    SpawnBozu();
                }
            }
        }
    }
Exemplo n.º 18
0
    void disableGhosts()
    {
        foreach (GameObject ghost in ghosts)
        {
            GhostScript script = ghost.GetComponent <GhostScript>();
            if (script != null)
            {
                script.StopMoving();
            }
        }
        //special hacky fix for up-down ghosts :/
        GameObject[] upDownGhosts = GameObject.FindGameObjectsWithTag("upDownGhost");
        foreach (GameObject ghost in upDownGhosts)
        {
            upDownGhost script = ghost.GetComponent <upDownGhost>();
            if (script != null)
            {
                script.upDownGhostsMoving = false;
            }
        }
        //special hacky fix for up-down ghosts :/
        GameObject[] squareGhosts = GameObject.FindGameObjectsWithTag("squareGhost");
        foreach (GameObject ghost in squareGhosts)
        {
            squareGhost script = ghost.GetComponent <squareGhost>();
            if (script != null)
            {
                script.squareGhostMoving = false;
            }
        }

        GameObject upDownDoor = GameObject.FindGameObjectWithTag("upDownDoor");

        if (upDownDoor != null)
        {
            upDownDoor doorScript = upDownDoor.GetComponent <upDownDoor>();
            if (doorScript != null)
            {
                doorScript.upDownDoorMoving = false;
            }
        }
    }
Exemplo n.º 19
0
    private void ActivateGhostObject()
    {
        // Activate following button to move object
        GhostFollowingButton.SetActive(true);
        GhostFollowingButtonScript ghostFollowScript = GhostFollowingButton.GetComponent <GhostFollowingButtonScript>();

        ghostFollowScript.SetGhostObject(GhostObject);

        GhostScript ghostScript = GhostObject.GetComponent <GhostScript>();

        ghostScript.isGhost = true;

        // Zapamiętywanie pozycji w razie anulowania
        Building buildingScript = GhostObject.GetComponent <Building>();

        if (buildingScript.IsPlacedForReal)
        {
            ghostOriginalPosition = GhostObject.transform.position;
        }

        Helper.GetGUIManager().EditMode_SetGhostPositionGroupVisible(true);
    }
Exemplo n.º 20
0
    /// <summary>
    /// Zamienia obiekt Ghost na budynek
    /// </summary>
    public void DropObject()
    {
        GhostScript ghost = GhostObject.GetComponent <GhostScript>();

        if (ghost.canPlace)
        {
            // Place object
            ghost.isGhost = false;

            // Hide following button to place button
            GhostFollowingButtonScript ghostFollowScript = GhostFollowingButton.GetComponent <GhostFollowingButtonScript>();
            ghostFollowScript.UnsetGhostObject();
            GhostFollowingButton.SetActive(false);

            // Ustawianie budynku jako child grupy budynków
            GhostObject.transform.SetParent(Helper.GetBuildingsGroup().transform);

            // Informowanie budowli, że została wybudowana
            Building buildingScript = GhostObject.GetComponent <Building>();
            if (buildingScript != null)
            {
                if (!buildingScript.IsPlacedForReal)
                {
                    buildingScript.IsPlacedForReal = true;

                    // Wydanie pieniędzy
                    GameStats.Instance.SpendMoney(buildingScript.GetCost());
                    GameStats.Instance.AddExperience(buildingScript.BuildingBuyExperience);
                }
            }

            GhostObject = null;
            Helper.GetGUIManager().EditMode_SetGhostPositionGroupVisible(false);
            Helper.GetGUIManager().GameStats_TotalPeopleCountUpdate();
        }
    }
Exemplo n.º 21
0
        public JsonResult ReadReport(string sessionID)
        {
            var result = new Libs.KmoAjaxResult()
            {
                success = false
            };

            var rptReq = TempData["rptReq_" + sessionID] as Libs.ReportRequest;

            TempData.Remove("rptReq_" + sessionID);
            TempData.Add("rptReq_" + sessionID, rptReq);

            try
            {
                if (!TempData.ContainsKey("pdfbin_" + rptReq.SessionID))
                {
                    Libs.ReportParameterCollection rptPars;
                    if (!string.IsNullOrEmpty(rptReq.RecordSelectionFormula))
                    {
                        rptPars = Application.Report_Crpt_BuildParameters(rptReq.ReportName, rptReq.RecordSelectionFormula);
                    }
                    else
                    {
                        rptPars = Application.Report_Crpt_BuildParameters(rptReq.ReportName);
                    }

                    rptPars.AddRange(rptReq.Parameters.ToArray());

                    var pdfBin = Application.Report_Crpt_BuildRptPdf(rptPars).Result;

                    var base64string = GhostScript.RasterizePdf(pdfBin).ToBase64Strings();

                    var rptView = new Libs.ReportViewModel();
                    rptView.CurrentPage = 1;
                    rptView.TotalPage   = base64string.Count();
                    rptView.PageData    = base64string[0];
                    rptView.SessionID   = sessionID;
                    result.data         = rptView;

                    if (TempData.ContainsKey("pageNumber_" + rptReq.SessionID))
                    {
                        TempData.Remove("pageNumber_" + rptReq.SessionID);
                    }
                    TempData.Add("pdfbin_" + rptReq.SessionID, pdfBin);
                    TempData.Add("pageNumber_" + rptReq.SessionID, (Int32)1);
                    result.success = true;
                }
                else
                {
                    var pdfBin       = (byte[])TempData["pdfbin_" + rptReq.SessionID];
                    var base64string = GhostScript.RasterizePdf(pdfBin).ToBase64Strings();

                    var page    = base64string[0];
                    var rptView = new Libs.ReportViewModel();
                    rptView.CurrentPage = 1;
                    rptView.TotalPage   = base64string.Count();
                    rptView.PageData    = base64string[0];
                    rptView.SessionID   = sessionID;
                    result.data         = rptView;

                    if (TempData.ContainsKey("pageNumber_" + rptReq.SessionID))
                    {
                        TempData.Remove("pageNumber_" + rptReq.SessionID);
                    }
                    TempData.Add("pageNumber_" + rptReq.SessionID, (Int32)1);
                    TempData.Remove("pdfbin_" + rptReq.SessionID);
                    TempData.Add("pdfbin_" + rptReq.SessionID, pdfBin);
                    result.success = true;
                }
            }
            catch (Exception x)
            {
                result.message = x.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 22
0
    /// <summary>
    /// Updates the game.
    /// </summary>
    /// <remarks>
    /// Invoked by Update. Update animation.
    /// </remarks>
    void UpdateGame()
    {
        // 1. Check whether the character is moving, i.e., has not finished movement.
        // This is for the agent's movement
        if (!isMoving)
        {
            int dRow = (int)GameConstants.RelativeDirX[action];
            int dCol = (int)GameConstants.RelativeDirY[action];

            int playerRow = Mathf.RoundToInt(this.transform.position.x);
            int playerCol = Mathf.RoundToInt(this.transform.position.z);

            // 0 is floor, 2 is goal
            if (dRow + dCol != 0)
            {
                if (levelGenerator.levelData.map[playerRow + dRow, playerCol + dCol] > 0)
                {
                    isMoving    = true;
                    movingSteps = 0;
                }
                else
                {
                    action = (int)GameConstants.actions.unchanged;
                }
            }
            else if (action == (int)GameConstants.actions.shoot)
            {
                isMoving    = true;
                movingSteps = 0;

                // if there is a ghost nearby, can shoot
                GameObject[] gos;
                gos = GameObject.FindGameObjectsWithTag("GhostNPC");
                int myNode = levelGenerator.levelData.gridNodeLabel[playerRow, playerCol];
                int ghostNode;
                foreach (GameObject go in gos)
                {
                    ghostNode = levelGenerator.levelData.gridNodeLabel
                                [Mathf.RoundToInt(go.transform.position.x),
                                 Mathf.RoundToInt(go.transform.position.z)];

                    // reduce HP of attackedGhost
                    GhostScript gScript = go.GetComponent <GhostScript>();

                    if (!gScript.isSolved && levelGenerator.levelData.shortestPath[myNode, ghostNode] <=
                        levelGenerator.ghostShotDistance)
                    {
                        attackedGhost = go;

                        gScript.HP--;
                        levelGenerator.state.mazeProperties[gScript.myIndex][3]--;
                        break;
                    }
                }
            }
        }
        else          // if moving, only animation happens here.
                      //debugText = "Moving";
        {
            if (action == (int)GameConstants.actions.shoot)
            {
                // shooting animation
                // TODO
                if (attackedGhost != null)
                {
                    if (movingSteps == 0)
                    {
                        // change color of ghost to red
                        attackedColor = attackedGhost.renderer.material.color;
                        Color       colr    = attackedColor;
                        GhostScript gScript = attackedGhost.GetComponent <GhostScript>();
                        if (gScript.HP <= 0)
                        {
                            colr.r = 0f;
                            colr.b = 1f;
                            colr.g = 0f;
                        }
                        else
                        {
                            colr.r = 1f;
                            colr.b = 0f;
                            colr.g = 0f;
                        }

                        attackedGhost.renderer.material.color = colr;
                    }
                }
            }
            else
            {
                Utilities.animateMovement(action, this.gameObject);
            }

            movingSteps++;

            // Finish moving
            isMoving = !(movingSteps == GameConstants.NumAnimsPerStep);

            if (!isMoving)
            {
                // player's coords
                levelGenerator.state.playerProperties[0, 0] = (int)Mathf.Round(this.transform.position.x);                // playerRow+dRow;
                levelGenerator.state.playerProperties[0, 1] = (int)Mathf.Round(this.transform.position.z);                // playerRow+dCol;
                //action = (int)GameConstants.actions.unchanged;

                if (attackedGhost != null)
                {
                    // change color of ghost back to normal
                    GhostScript gScript = attackedGhost.GetComponent <GhostScript>();

                    // only when the ghost is still alive do we change the color back
                    // to its original color.
                    if (gScript.HP > 0)
                    {
                        attackedGhost.renderer.material.color = attackedColor;
                    }
                    attackedGhost = null;
                }
            }
        }
    }
Exemplo n.º 23
0
        private void countPDF(string inputPDFFile, string outputFile)
        {
            Logger.Log("countPDF()");

            // override pdfCounter variable
            GhostScript pdfcounter = new GhostScript();
            string ars = pdfcounter.ars;
            string ghostScriptPath = pdfcounter.ghostScriptPath;
            Process gsProc = pdfcounter.proc;

            //using (FileStream stream = new FileStream(outputFile, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
            //{
            //    // Does reading  here.
            //    using (TextReader tr = new StreamReader(stream))
            //    {
            //        ars = "-dNOPAUSE -sDEVICE=inkcov -o " + tr + " " + inputPDFFile;
            //    }
            //}

            ars = "-dNOPAUSE -sDEVICE=inkcov -o " + outputFile + " " + inputPDFFile;

            Logger.Log("GhostScript command: "+ ars);

            // set up process
            gsProc.StartInfo.FileName = ghostScriptPath;
            gsProc.StartInfo.Arguments = ars;
            gsProc.StartInfo.CreateNoWindow = true;
            gsProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

            // putting process execution on separate thread to avoid UI hang
            Thread gsThread = new Thread(() =>
            {
                Logger.Log("gsThread stating");
                this.Dispatcher.Invoke((Action)(() =>
                {
                    processStopwatch = Stopwatch.StartNew();
                    Logger.Log("Making prgBar visible");
                    prgbarProcessGhostscript.Visibility = Visibility.Visible;
                }));

                gsProc.Start();
                gsProc.WaitForExit();

                while (!gsProc.HasExited)
                {
                    // wait until process has finished before preceeding
                }

                this.Dispatcher.Invoke((Action)(() =>
                {
                    Logger.Log("gsProc complete - making invisible");
                    prgbarProcessGhostscript.Visibility = Visibility.Hidden;
                    processStopwatch.Stop();
                    elapsedMs = processStopwatch.ElapsedMilliseconds;
                    elapsedMs = elapsedMs / 1000;
                    elapsedMs = Math.Round(elapsedMs, 2);
                    analyseOutput();
                    calculateCosts();
                }));
            });

            aTimer = new System.Timers.Timer(10);
            //aTimer.Elapsed += new ElapsedEventHandler(countOutputLines);

            // Set the Interval to 2 seconds (2000 milliseconds).
            aTimer.Interval = 10;
            aTimer.Enabled = true;
            gsThread.Start();
        }
Exemplo n.º 24
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        string temp2 = UploadPdfFile();

        if (temp2 == "File uploaded!")
        {
            string temp1 = NameTextBox.Text;
            int    chk   = temp1.IndexOf(" ");
            if ((IsAlphaNumeric(NameTextBox.Text)) && chk == -1)
            {
                Issue newIssue = new Issue();
                newIssue.IssueId        = NameTextBox.Text;
                newIssue.IssueDirectory = ConfigurationManager.AppSettings["imagepath"] + NameTextBox.Text;
                if (Directory.Exists(newIssue.IssueDirectory))
                {
                    StatusLabel.Text = "Folder already exists!";
                }
                else
                {
                    if (!File.Exists(HttpContext.Current.Server.MapPath("~/pdf") + @"\temp.pdf"))
                    {
                        StatusLabel.Text = "Please upload PDF file first!";
                    }
                    else
                    {
                        Directory.CreateDirectory(newIssue.IssueDirectory);
                        newIssue.Resolution           = ResolutionDropDownList.SelectedValue;
                        newIssue.Quality              = QualityTextBox.Text;
                        newIssue.TextAntialiasing     = TxtAliasingDropDownList.SelectedValue;
                        newIssue.GraphicsAntialiasing = GraphAliasingDropDownList.SelectedValue;
                        //StatusLabel.Text = CreateImages.CreateImagesGhostScript(newIssue);
                        string        pdfpath   = HttpContext.Current.Server.MapPath("~/pdf");
                        string        sourcePDF = pdfpath + @"\temp.pdf";
                        List <string> fileList;
                        GhostScript.DeviceOption[] options = GhostScript.DeviceOptions.jpg(int.Parse(newIssue.Quality), int.Parse(newIssue.TextAntialiasing), int.Parse(newIssue.GraphicsAntialiasing));
                        GhostScript gs = new GhostScript(ConfigurationManager.AppSettings["gspath"]);
                        fileList = gs.Convert(GhostScript.OutputDevice.jpeg, options, sourcePDF, newIssue.IssueDirectory, "%d.jpg", pdfpath, int.Parse(newIssue.Resolution));
                        gs.Dispose();
                        string destinationPDF = newIssue.IssueDirectory + @"\" + newIssue.IssueId + ".pdf";
                        File.Move(sourcePDF, destinationPDF);
                        if (fileList.Count == 0)
                        {
                            MagazineData.CreateIssue(newIssue);
                            CreateXML.CreatePagesXMLFile(newIssue.IssueId);
                            btnPreview.Visible        = true;
                            btnUploadOnServer.Visible = true;
                            StatusLabel.Text          = "Image files created!";
                        }
                        else
                        {
                            StatusLabel.Text = "Error!";
                        }
                    }
                }
            }
            else
            {
                StatusLabel.Text = "Enter valid Issue name";
            }
        }
        else
        {
            StatusLabel.Text = temp2;
        }
    }
Exemplo n.º 25
0
 public PrintingAction(GhostScript ghostscript)
 {
     _ghostscript = ghostscript;
 }
Exemplo n.º 26
0
    public void Possess(GhostScript argGhost)
    {
        argGhost.Hide();

        EnablePlayerControl();
    }
Exemplo n.º 27
0
 // Start is called before the first frame update
 void Start()
 {
     line        = GetComponent <LineRenderer>();
     ghostScript = ghost.GetComponent <GhostScript>();
     GetComponent <LineRenderer>().enabled = false;
 }
Exemplo n.º 28
0
 private void Start()
 {
     gs = ghost.GetComponent <GhostScript>();
 }
Exemplo n.º 29
0
 private void Start()
 {
     actualDurability = durability;
     gs = ghost.GetComponent <GhostScript>();
 }
Exemplo n.º 30
0
    public IEnumerator Execute(GhostScript ghost)
    {
        enabled = false;

        StartCoroutine(ghost.Absorb(this));

        yield return StartCoroutine(NotifyUser());

        ghost.Energy += _Value;

        Destroy(gameObject);
    }
Exemplo n.º 31
0
 private void OnTriggerEnter(Collider other)
 {
     //Debug.Log(other.gameObject);
     if (other.gameObject.CompareTag(PowUpTag))
     {
         other.gameObject.SetActive(false);
         UpdateScore(PowUpSc);
         //set Ghosts to frightened mode
         GameObject[] g = GameObject.FindGameObjectsWithTag(GhostTag);
         for (int i = 0; i < g.Length; i++)
         {
             //Debug.Log(g[i]);
             //Debug.Log(i+" "+g.Length+g);
             g[i].GetComponent <GhostScript>().SetFrightenedState();
         }
     }
     else if (other.gameObject.CompareTag(CoinTag))
     {
         other.gameObject.SetActive(false);
         //increment score
         UpdateScore(CoinSc);
         //gameLogic for finished maze in UpdateScore()
     }
     else if (other.gameObject.CompareTag(GhostTag))
     {
         Debug.Log("here");
         //script instance
         GhostScript gs = other.gameObject.GetComponent <GhostScript>();
         //if the Ghost is frightened
         if (gs.GetState() == GhostScript.States.frightened)
         {
             //kill ghost
             //determine if ghost has already been killed in succession
             //other.transform.position = new Vector3(0, .5f, 0);
             UpdateScore(200);
             other.GetComponent <GhostScript>().ResetGhost();
         }
         else
         {
             //kill pacman, deduct one life, reload scene
             gameObject.transform.position = startVec;
             respawnTime = 5f;
             //Decrement Lives
             GameSaveScr gss = GameObject.Find("GameSave").GetComponent <GameSaveScr>();
             gss.PlayerLivesLeft--;
             Debug.Log(gss.PlayerLivesLeft);
             if (gss.PlayerLivesLeft == 0)
             {
                 gss.score = LocalScore;
                 //GameOver
                 gss.CurLevelName = "";
                 bool nhs   = false;//new high score
                 int  place = 0;
                 if (gss.score < PlayerSettingsScript.PlayerSettings.HighScore1)
                 {
                     if (gss.score < PlayerSettingsScript.PlayerSettings.HighScore2)
                     {
                         if (gss.score < PlayerSettingsScript.PlayerSettings.HighScore3)
                         {
                             if (gss.score < PlayerSettingsScript.PlayerSettings.HighScore4)
                             {
                                 if (gss.score < PlayerSettingsScript.PlayerSettings.HighScore5)
                                 {
                                     if (gss.score < PlayerSettingsScript.PlayerSettings.HighScore6)
                                     {
                                         if (gss.score < PlayerSettingsScript.PlayerSettings.HighScore7)
                                         {
                                             if (gss.score < PlayerSettingsScript.PlayerSettings.HighScore8)
                                             {
                                                 if (gss.score < PlayerSettingsScript.PlayerSettings.HighScore9)
                                                 {
                                                     if (gss.score < PlayerSettingsScript.PlayerSettings.HighScore10)
                                                     {
                                                         //Do nothing, not a high score
                                                     }
                                                     else
                                                     {
                                                         PlayerSettingsScript.PlayerSettings.HighScore10 = gss.score;
                                                         nhs   = true;
                                                         place = 10;
                                                     }
                                                 }
                                                 else
                                                 {
                                                     PlayerSettingsScript.PlayerSettings.HighScore10 = PlayerSettingsScript.PlayerSettings.HighScore9;
                                                     PlayerSettingsScript.PlayerSettings.HighScore9  = gss.score;
                                                     nhs   = true;
                                                     place = 9;
                                                 }
                                             }
                                             else
                                             {
                                                 PlayerSettingsScript.PlayerSettings.HighScore9  = PlayerSettingsScript.PlayerSettings.HighScore8;
                                                 PlayerSettingsScript.PlayerSettings.HighScore10 = PlayerSettingsScript.PlayerSettings.HighScore9;
                                                 PlayerSettingsScript.PlayerSettings.HighScore8  = gss.score;
                                                 nhs   = true;
                                                 place = 8;
                                             }
                                         }
                                         else
                                         {
                                             PlayerSettingsScript.PlayerSettings.HighScore10 = PlayerSettingsScript.PlayerSettings.HighScore9;
                                             PlayerSettingsScript.PlayerSettings.HighScore9  = PlayerSettingsScript.PlayerSettings.HighScore8;
                                             PlayerSettingsScript.PlayerSettings.HighScore8  = PlayerSettingsScript.PlayerSettings.HighScore7;
                                             PlayerSettingsScript.PlayerSettings.HighScore7  = gss.score;
                                             nhs   = true;
                                             place = 7;
                                         }
                                     }
                                     else
                                     {
                                         PlayerSettingsScript.PlayerSettings.HighScore10 = PlayerSettingsScript.PlayerSettings.HighScore9;
                                         PlayerSettingsScript.PlayerSettings.HighScore9  = PlayerSettingsScript.PlayerSettings.HighScore8;
                                         PlayerSettingsScript.PlayerSettings.HighScore8  = PlayerSettingsScript.PlayerSettings.HighScore7;
                                         PlayerSettingsScript.PlayerSettings.HighScore7  = PlayerSettingsScript.PlayerSettings.HighScore6;
                                         PlayerSettingsScript.PlayerSettings.HighScore6  = gss.score;
                                         nhs   = true;
                                         place = 6;
                                     }
                                 }
                                 else
                                 {
                                     PlayerSettingsScript.PlayerSettings.HighScore10 = PlayerSettingsScript.PlayerSettings.HighScore9;
                                     PlayerSettingsScript.PlayerSettings.HighScore9  = PlayerSettingsScript.PlayerSettings.HighScore8;
                                     PlayerSettingsScript.PlayerSettings.HighScore8  = PlayerSettingsScript.PlayerSettings.HighScore7;
                                     PlayerSettingsScript.PlayerSettings.HighScore7  = PlayerSettingsScript.PlayerSettings.HighScore6;
                                     PlayerSettingsScript.PlayerSettings.HighScore6  = PlayerSettingsScript.PlayerSettings.HighScore5;
                                     PlayerSettingsScript.PlayerSettings.HighScore5  = gss.score;
                                     nhs   = true;
                                     place = 5;
                                 }
                             }
                             else
                             {
                                 PlayerSettingsScript.PlayerSettings.HighScore10 = PlayerSettingsScript.PlayerSettings.HighScore9;
                                 PlayerSettingsScript.PlayerSettings.HighScore9  = PlayerSettingsScript.PlayerSettings.HighScore8;
                                 PlayerSettingsScript.PlayerSettings.HighScore8  = PlayerSettingsScript.PlayerSettings.HighScore7;
                                 PlayerSettingsScript.PlayerSettings.HighScore7  = PlayerSettingsScript.PlayerSettings.HighScore6;
                                 PlayerSettingsScript.PlayerSettings.HighScore6  = PlayerSettingsScript.PlayerSettings.HighScore5;
                                 PlayerSettingsScript.PlayerSettings.HighScore5  = PlayerSettingsScript.PlayerSettings.HighScore4;
                                 PlayerSettingsScript.PlayerSettings.HighScore4  = gss.score;
                                 nhs   = true;
                                 place = 4;
                             }
                         }
                         else
                         {
                             PlayerSettingsScript.PlayerSettings.HighScore10 = PlayerSettingsScript.PlayerSettings.HighScore9;
                             PlayerSettingsScript.PlayerSettings.HighScore9  = PlayerSettingsScript.PlayerSettings.HighScore8;
                             PlayerSettingsScript.PlayerSettings.HighScore8  = PlayerSettingsScript.PlayerSettings.HighScore7;
                             PlayerSettingsScript.PlayerSettings.HighScore7  = PlayerSettingsScript.PlayerSettings.HighScore6;
                             PlayerSettingsScript.PlayerSettings.HighScore6  = PlayerSettingsScript.PlayerSettings.HighScore5;
                             PlayerSettingsScript.PlayerSettings.HighScore5  = PlayerSettingsScript.PlayerSettings.HighScore4;
                             PlayerSettingsScript.PlayerSettings.HighScore4  = PlayerSettingsScript.PlayerSettings.HighScore3;
                             PlayerSettingsScript.PlayerSettings.HighScore3  = gss.score;
                             nhs   = true;
                             place = 3;
                         }
                     }
                     else
                     {
                         PlayerSettingsScript.PlayerSettings.HighScore10 = PlayerSettingsScript.PlayerSettings.HighScore9;
                         PlayerSettingsScript.PlayerSettings.HighScore9  = PlayerSettingsScript.PlayerSettings.HighScore8;
                         PlayerSettingsScript.PlayerSettings.HighScore8  = PlayerSettingsScript.PlayerSettings.HighScore7;
                         PlayerSettingsScript.PlayerSettings.HighScore7  = PlayerSettingsScript.PlayerSettings.HighScore6;
                         PlayerSettingsScript.PlayerSettings.HighScore6  = PlayerSettingsScript.PlayerSettings.HighScore5;
                         PlayerSettingsScript.PlayerSettings.HighScore5  = PlayerSettingsScript.PlayerSettings.HighScore4;
                         PlayerSettingsScript.PlayerSettings.HighScore4  = PlayerSettingsScript.PlayerSettings.HighScore3;
                         PlayerSettingsScript.PlayerSettings.HighScore3  = PlayerSettingsScript.PlayerSettings.HighScore2;
                         PlayerSettingsScript.PlayerSettings.HighScore2  = gss.score;
                         nhs   = true;
                         place = 2;
                     }
                 }
                 else
                 {
                     PlayerSettingsScript.PlayerSettings.HighScore10 = PlayerSettingsScript.PlayerSettings.HighScore9;
                     PlayerSettingsScript.PlayerSettings.HighScore9  = PlayerSettingsScript.PlayerSettings.HighScore8;
                     PlayerSettingsScript.PlayerSettings.HighScore8  = PlayerSettingsScript.PlayerSettings.HighScore7;
                     PlayerSettingsScript.PlayerSettings.HighScore7  = PlayerSettingsScript.PlayerSettings.HighScore6;
                     PlayerSettingsScript.PlayerSettings.HighScore6  = PlayerSettingsScript.PlayerSettings.HighScore5;
                     PlayerSettingsScript.PlayerSettings.HighScore5  = PlayerSettingsScript.PlayerSettings.HighScore4;
                     PlayerSettingsScript.PlayerSettings.HighScore4  = PlayerSettingsScript.PlayerSettings.HighScore3;
                     PlayerSettingsScript.PlayerSettings.HighScore3  = PlayerSettingsScript.PlayerSettings.HighScore2;
                     PlayerSettingsScript.PlayerSettings.HighScore2  = PlayerSettingsScript.PlayerSettings.HighScore1;
                     PlayerSettingsScript.PlayerSettings.HighScore1  = gss.score;
                     nhs   = true;
                     place = 1;
                 }
                 gss.score = 0;
                 PlayerSettingsScript.PlayerSettings.SaveSettings();
                 gss.SaveGame();
                 if (nhs)
                 {
                     PlayerPrefs.SetInt("score", LocalScore);
                     PlayerPrefs.SetInt("place", place);
                     SceneManager.LoadScene("NewHS Page", LoadSceneMode.Single);
                 }
                 else
                 {
                     SceneManager.LoadScene("StartMenu", LoadSceneMode.Single);
                 }
             }
             else
             {
                 //Keep on keeping on
             }
         }
     }
 }