Esempio n. 1
0
    /// <summary>
    /// Called when the current active board is completed by the player (ie. they found the last word)
    /// </summary>
    private void BoardComplete()
    {
        string boardId     = Utilities.FormatBoardId(ActiveCategory, ActiveLevelIndex);
        int    awardNumber = 0;

        // Check if the completed category was a daily puzzle, if so check if we want to award a hint
        if (ActiveCategory != dailyPuzzleId)
        {
            bool awardHint = !CompletedLevels.ContainsKey(boardId) || !CompletedLevels[boardId];
            awardNumber = awardHint ? GameConfig.instance.completeNormalLevelAward : 0;
        }
        else
        {
            awardNumber = GameConfig.instance.completeDailyPuzzleAward;
            // Set the next daily puzzle to start at the start of the next day
            NextDailyPuzzleAt = new System.DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, System.DateTime.Now.Day).AddDays(1);
        }

        // Award hints for completing the level or daily puzzle
        AddHint(awardNumber);

        // Set the completed flag on the level
        CompletedLevels[boardId] = true;

        // The board has been completed, we no longer need to save it
        ActiveBoardState = null;

        // Remove the BoardState from the list of saved BoardStates
        SavedBoardStates.Remove(boardId);

        Save();

        UIScreenController.Instance.Show(UIScreenController.CompleteScreenId, false, true, true, Tween.TweenStyle.EaseOut, OnCompleteScreenShown, awardNumber);
        GoogleAnalyticsV3.instance.LogEvent("Level", "Complete Level", boardId, 0);
    }
Esempio n. 2
0
    public void StartLevel(string category, int levelIndex)
    {
        ActiveCategory   = category;
        ActiveLevelIndex = levelIndex;

        // Get the board id for the level and load the WordBoard from Resources
        string    boardId   = Utilities.FormatBoardId(ActiveCategory, ActiveLevelIndex);
        WordBoard wordBoard = Utilities.LoadWordBoard(boardId);

        if (wordBoard == null)
        {
            Debug.LogError("Could not load WordBoard with the boardId: " + boardId);
            return;
        }

        // If a saved BoardState does not already exist then create one
        if (!SavedBoardStates.ContainsKey(boardId))
        {
            SavedBoardStates.Add(boardId, CreateNewBoardState(wordBoard));
        }

        // Try and get a saved board state if one exists
        ActiveBoardState = SavedBoardStates[boardId];

        // Save the game
        Save();

        // Setup the display using the assigned activeBoardState
        SetupActiveBoard();
    }
Esempio n. 3
0
    /// <summary>
    /// Starts the daily puzzle.
    /// </summary>
    public void StartDailyPuzzle()
    {
        if (dailyPuzzles.Count == 0)
        {
            return;
        }

        // Check if we need to pick a new daily puzzle
        if (ActiveDailyPuzzleIndex == -1 || System.DateTime.Now >= NextDailyPuzzleAt)
        {
            if (ActiveDailyPuzzleIndex != -1)
            {
                string boardId = Utilities.FormatBoardId(dailyPuzzleId, ActiveDailyPuzzleIndex);

                // Remove any save data for the previous daily puzzle
                SavedBoardStates.Remove(boardId);
                CompletedLevels.Remove(boardId);
            }

            // Get a new random daily puzzle level index to use
            ActiveDailyPuzzleIndex = Random.Range(0, dailyPuzzles.Count);
        }

        // Start the daily puzzle
        StartLevel(dailyPuzzleId, ActiveDailyPuzzleIndex);
    }
Esempio n. 4
0
    /// <summary>
    /// Called when the current active board is completed by the player (ie. they found the last word)
    /// </summary>
    private void BoardComplete()
    {
        string boardId   = Utilities.FormatBoardId(ActiveCategory, ActiveLevelIndex);
        bool   awardHint = true;

        // Check if the completed category was a daily puzzle, if so check if we want to award a hint
        if (ActiveCategory != dailyPuzzleId)
        {
            // Get the CategoryInfo for the active category
            CategoryInfo categoryInfo = GetCategoryInfo(ActiveCategory);

            bool categoryCompleted = (GetCompletedLevelCount(categoryInfo) == categoryInfo.levelInfos.Count);

            // Award a hint if the category was just completed
            awardHint = ((!CompletedLevels.ContainsKey(boardId) || !CompletedLevels[boardId]) && categoryCompleted);
        }
        else
        {
            // Set the next daily puzzle to start at the start of the next day
            NextDailyPuzzleAt = new System.DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, System.DateTime.Now.Day).AddDays(1);
        }

        // Award a hint for completing the category or daily puzzle
        if (awardHint)
        {
            AddHint();
        }

        // Set the completed flag on the level
        CompletedLevels[boardId] = true;

        // The board has been completed, we no longer need to save it
        ActiveBoardState = null;

        // Remove the BoardState from the list of saved BoardStates
        SavedBoardStates.Remove(boardId);

        Save();

        LevelsToCompleteBeforeAd -= 1;

        UIScreenController.Instance.Show(UIScreenController.CompleteScreenId, false, true, true, Tween.TweenStyle.EaseOut, OnCompleteScreenShown, awardHint);
    }