Ejemplo n.º 1
0
        private void OnVictory()
        {
            GameTimerUpdater.StopTimer();
            _audioSource.PlayOneShot(OnVictorySound);

            var decryptedText = Steganography.Decode(Image);

            var amount = LocalStorage.GetInt(StorageKeys.DecryptedAmountKey).Value + 1;

            StartCoroutine(WebServiceManager.SetTopScore(ScoreCounter.GetScore(), (score) =>
            {
                Debug.Log("Score correctly pushed: " + score);
            }));

            OnCompletedPopupText.text = "You won 1 Herc token and decrypted\nHerciD: " + amount.ToString("000-000-000");
            OnCompletedPopup.gameObject.SetActive(true);

            LocalStorage.Store(StorageKeys.DecryptedAmountKey, amount);
        }
Ejemplo n.º 2
0
    // WIN [

    public IEnumerator CheckForComplete()
    {
        yield return(null);

        while (Complete == false)
        {
            // iterate over all the tiles and check if they are in the correct position.
            Complete = true;
            for (int j = Height - 1; j >= 0; j--)
            {
                for (int i = 0; i < Width; i++)
                {
                    // check if this tile has the correct grid display location.
                    if (TileDisplayArray[i, j].GetComponent <ST_PuzzleTile>().CorrectLocation == false)
                    {
                        Complete = false;
                    }
                }
            }

            yield return(null);
        }

        // if we are still complete then all the tiles are correct.
        if (Complete)
        {
            GameTimerUpdater.StopTimer();
            string msg       = Steganography.Decode(PuzzleImage);
            var    scoreTemp = CalculateScore(PuzzleMoves, (int)GameTimerUpdater.ElapsedSeconds);

            WaitingValidationPopup.gameObject.SetActive(true);

            PuzzleManager.ValidatePuzzleResult(PuzzleManager.PuzzleData.puzzleId, scoreTemp, msg, Moves, (isValid) =>
            {
                if (isValid)
                {
                    if (AudioSource == null)
                    {
                        AudioSource = GetComponent <AudioSource>();
                    }
                    AudioSource.PlayOneShot(VictorySound);

                    var score = CalculateScore(PuzzleMoves, (int)GameTimerUpdater.ElapsedSeconds);

                    CompletingText.text = "Nicely done! You scored " + score +
                                          "!\nBe sure to accept the transaction, or your score will not be added in the leaderboard!";

                    WaitingValidationPopup.gameObject.SetActive(false);
                    CompletingPopup.gameObject.SetActive(true);
                }
                else
                {
                    CompletingText.text = "Uhm, it seems you did not decrypted correctly this hash. But you can retry!";

                    CompletingPopup.gameObject.SetActive(true);
                }
            });
        }

        yield return(null);
    }