Пример #1
0
    public void OnButtonClickAction()
    {
        // If submitting name, submit the score
        if (SaveDataController.GetInstance().IsSubmitting)
        {
            SoundController.PlaySound(SoundType.UIAction, false);
            int rank = SubmitScore();

            // Enable the high scores
            Submission.SetActive(false);
            HighScores.SetActive(true);

            // If submitted score was high enough to be on high scores,
            // then highlight it
            if (rank < NUM_LISTINGS)
            {
                ScoreboardListings[rank].Name.color  = SUBMITTED_SCORE_COLOUR;
                ScoreboardListings[rank].Score.color = SUBMITTED_SCORE_COLOUR;
            }

            // Update the scoreboard to show the newly submitted score
            UpdateScoreboard();

            return;
        }
    }
Пример #2
0
 public void OnButtonClickBack()
 {
     if (!SaveDataController.GetInstance().IsSubmitting)
     {
         ReturnToMainMenu();
     }
 }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("GameController.cs");

        // Load the current level
        _dataController  = SaveDataController.GetInstance();
        _currentLevelNum = _dataController.LoadData().CurrentLevel;
        LoadLevel(_currentLevelNum);

        // Stop any music being played
        SoundController.StopMusic();

        // Start the game paused before the countdown
        _isPaused         = true;
        _updateEveryFrame = UpdateEveryFrame;

        GameInput.AttachInput(
            actionClick: OnButtonClickAction,
            skillClick: OnButtonClickSkill,
            backClick: OnButtonClickBack,
            leftClick: OnButtonClickLeft,
            rightClick: OnButtonClickRight,
            downClick: OnButtonClickDown,
            upClick: OnButtonClickUp);

        // Start the countdown sequence
        StartCountdown();
    }
Пример #4
0
    private void SaveScores()
    {
        //_data.HighScores = serialized;
        SaveDataController save = SaveDataController.GetInstance();

        save.SaveData(_data);
        save.SaveDataToDisk();
    }
Пример #5
0
    private void OnSubmitButtonSelect()
    {
        // Submit score
        Debug.Log("Submit button is selected");

        // Flag submit request to true to indicate that a score is being
        // submitted
        SaveDataController.GetInstance().IsSubmitting = true;
        ChangeState(GameStateLoader.GAME_STATES.SCOREBOARD);
    }
Пример #6
0
 public void OnButtonClickRight()
 {
     // If submitting name, move one slot to the right
     if (SaveDataController.GetInstance().IsSubmitting)
     {
         _selectedNameSlot = Mathf.Min(NameSlots.Length - 1, _selectedNameSlot + 1);
         UpdateNameSlots();
         SoundController.PlaySound(SoundType.UIClick, false);
         return;
     }
 }
Пример #7
0
 public void OnButtonClickLeft()
 {
     // If submitting name, move one slot to the left
     if (SaveDataController.GetInstance().IsSubmitting)
     {
         _selectedNameSlot = Mathf.Max(0, _selectedNameSlot - 1);
         UpdateNameSlots();
         SoundController.PlaySound(SoundType.UIClick, false);
         return;
     }
 }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        // Get all existing scores
        _data = SaveDataController.GetInstance().LoadData();

        // Handle score submit
        if (SaveDataController.GetInstance().IsSubmitting)
        {
            // Hide the high scores
            HighScores.SetActive(false);

            // Enable name submission
            _selectedNameSlot = 0;
            _slotLetters      = new int[NameSlots.Length];
            UpdateNameSlots();

            // Set the score text
            ScoreValueText.text = "$ " + SaveDataController.GetInstance().ScoreToSubmit.ToString();
        }
        else
        {
            // Hide the name submission
            Submission.SetActive(false);

            // Display all the scores
            UpdateScoreboard();
        }

        // Press any key to return to main menu
        GameInput.AttachInput(
            actionClick: OnButtonClickAction,
            backClick: OnButtonClickBack,
            leftClick: OnButtonClickLeft,
            rightClick: OnButtonClickRight,
            downClick: OnButtonClickDown,
            upClick: OnButtonClickUp);

        // Show the appropriate help text for the platform
        if (HelperFunctions.IsRunningOnDesktop())
        {
            ScoreboardDesktop.SetActive(true);
            SubmissionDesktop.SetActive(true);
        }
        else if (HelperFunctions.IsRunningOnPS4())
        {
            ScoreboardPS4.SetActive(true);
            SubmissionPS4.SetActive(true);
        }
    }
Пример #9
0
 public void OnButtonClickDown()
 {
     // If submitting name, move to next letter
     if (SaveDataController.GetInstance().IsSubmitting)
     {
         int letterIndex = _slotLetters[_selectedNameSlot] + 1;
         if (letterIndex >= LETTERS.Length)
         {
             letterIndex = 0;
         }
         UpdateSlotLetter(letterIndex);
         SoundController.PlaySound(SoundType.UIClick, false);
         return;
     }
 }
Пример #10
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("MainMenu.cs");

        GameInput.AttachInput(
            actionClick: OnButtonClickAction,
            skillClick: OnButtonClickSkill,
            backClick: OnButtonClickBack,
            leftClick: OnButtonClickLeft,
            rightClick: OnButtonClickRight,
            downClick: OnButtonClickDown,
            upClick: OnButtonClickUp);

        // Initialize menu options
        AddMenuOption(PLAY_BUTTON, OnPlayButtonSelect);
        AddMenuOption(INSTRUCTIONS_BUTTON, OnInstructionsButtonSelect);
        AddMenuOption(SCOREBOARD_BUTTON, OnScoreboardButtonSelect);

        SelectDefaultButton();

        // Play title music
        SoundController.PlayMusic(MusicType.Title);

        // Show the appropriate help text for the platform
        if (HelperFunctions.IsRunningOnDesktop())
        {
            HelpTextDesktop.SetActive(true);

            // Add the exit button for desktop
            AddMenuOption(EXIT_BUTTON, OnExitButtonSelect);
        }
        else if (HelperFunctions.IsRunningOnPS4())
        {
            HelpTextPS4.SetActive(true);

            // Remove the exit button for the PS4
            ExitButton.SetActive(false);
        }

        // Set play button to read "Continue" if the player is not on the first level
        GameData data = SaveDataController.GetInstance().LoadData();

        if (data.CurrentLevel > 1)
        {
            PlayText.text = CONTINUE_TEXT + " (Lv. " + data.CurrentLevel + ")";
        }
    }
Пример #11
0
    // Submit the score and return the index of the submitted score
    // This index corresponds to the "rank" of the score in the high scores list
    private int SubmitScore()
    {
        ListingValues listing;

        listing.Name  = GetSubmittedName();
        listing.Score = SaveDataController.GetInstance().ScoreToSubmit;

        // Insert this score in appropriate order
        bool isInserted = false;
        int  rank       = 0;

        for (int i = 0; i < _data.HighScores.Count; ++i)
        {
            if (listing.Score > _data.HighScores[i].Score)
            {
                _data.HighScores.Insert(i, listing);
                isInserted = true;
                rank       = i;
                break;
            }
        }

        // If the listing hasn't been added yet, just push to the back of
        // the list
        if (!isInserted)
        {
            _data.HighScores.Add(listing);
            rank = _data.HighScores.Count - 1;
        }

        // Remove the lowest score if there too many listings
        if (_data.HighScores.Count > NUM_LISTINGS)
        {
            _data.HighScores.RemoveAt(_data.HighScores.Count - 1);
        }

        // Save the score using SaveDataController
        SaveScores();

        // Done with submit request
        SaveDataController.GetInstance().IsSubmitting = false;

        return(rank);
    }
Пример #12
0
 private void GetDataFromController()
 {
     dataController = SaveDataController.GetInstance();
     data           = dataController.LoadData();
 }