Exemplo n.º 1
0
    public static bool UpdateScore(SubmitWordLogEntry dbEntry)
    {
        // firebase logging
        SubmitWordLogEntry.SubmitWordPayload payload = new SubmitWordLogEntry.SubmitWordPayload();
        payload.word    = currentWord;
        payload.letters = GetLetterPayloadsFromCurrentWord();
        dbEntry.payload = payload;

        if (IsValidWord(currentWord))
        {
            // Update the score based on the word
            long submittedScore = GetScore(currentWord, payload);
            score += submittedScore;
            if (scoreText != null)
            {
                scoreText.text = "Points: " + score;
            }

            payload.success    = true;
            payload.scoreTotal = submittedScore;

            // update the highest scoring word if necessary
            if (submittedScore > GameManagerScript.myHighestScoringWordScore)
            {
                GameManagerScript.myHighestScoringWord      = currentWord;
                GameManagerScript.myHighestScoringWordScore = (int)submittedScore;
            }

            if (score > GameManagerScript.myHighScore)
            {
                GameManagerScript.myHighScore        = score;
                GameManagerScript.myHighScoreUpdated = true;
            }

            // Do something celebratory! highlight in green briefly before removing from screen
            // and also display a congratulatory message depending on how rare the word was
            instance.StartCoroutine(instance.AnimateSelectedTiles(GetWordFreq(currentWord), submittedScore));

            // Update the high score, if applicable
            // TODO: debug this
            //DBManager.instance.LogScore(score);

            return(true);
        }
        else
        {
            // firebase logging
            payload.success    = false;
            payload.rarity     = -1;
            payload.scoreBase  = -1;
            payload.scoreTotal = -1;

            ClearAllSelectedTiles();

            return(false);
        }
    }
Exemplo n.º 2
0
    /**
     * Method that selects the tile at the given coordinate (pos)
     */
    public static void SelectTile(Vector2 pos)
    {
        currentSelection.Add(pos);
        GameObject gameObject = grid[(int)pos.x, (int)pos.y].gameObject;
        BoxScript  boxScript  = gameObject.GetComponent <BoxScript>();

        currentWord += boxScript.Letter;

        /*****************************************************************
        * FEATURE: Highlighting color gradient based on frequency feature
        *****************************************************************/
        DisplayHighlightFeedback();

        // ALSO: display the border around the tile
        boxScript.DisplayBorder();

        /******************************************************************
        * FEATURE: Obstructions- disable / enable button depending on
        *          word's validity
        ******************************************************************/
        if (GameManagerScript.obstructionProductive || GameManagerScript.obstructionUnproductive)
        {
            GameManagerScript.gameManager.UpdatePlayButton();
        }

        /*****************************************************************
        * FEATURE: Shiny particles whenever you select a tile!
        * Productive Juice. Unproductive juice produces particles every touch
        *****************************************************************/
        if (GameManagerScript.juiceProductive)
        {
            boxScript.PlayShinySelectParticles();
        }

        /******************************************************************
        * FEATURE: juice: turn on this flag so that the tile
        *          bounces around/animates when selected
        ******************************************************************/
        boxScript._isSelected = true;

        //=====================================================================
        //  FEATURE: Juice: extra animations/bouncing if tile is selected.
        //=====================================================================
        if (GameManagerScript.juiceUnproductive || GameManagerScript.juiceProductive)
        {
            // Animate the tile
            boxScript.StartCoroutine(boxScript.AnimateBouncingTile());
        }

        //=====================================================================
        //  FEATURE: Unproductive Juice: camera shakes and explosions when
        //           selecting letters.
        //=====================================================================
        if (GameManagerScript.juiceUnproductive)
        {
            CameraShaker.instance.ShakeOnce(3f, 3.5f, .1f, .3f);
        }

        // Play sound effect
        AudioManager.instance.Play("Select");

        DisplaySelectedScore();
    }