ToString() public method

public ToString ( ) : string
return string
        public void HighScoreToStringTest()
        {
            var highScore = new Highscore("Veli", 10);
            var outputValue = "Veli-10";

            Assert.AreEqual(highScore.ToString(), outputValue);
        }
Esempio n. 2
0
    /// <summary>
    /// Handler to get selected row item
    /// </summary>
    public void OnSelectedRow(Button button)
    {
        int index = Convert.ToInt32(button.name);

        //Debug.Log("Selected index:" + index); //Count
        if (index >= _scores.Count)
        {
            return;
        }
        Highscore score = _scores [index];

        Debug.Log("Selected:" + score.ToString());
        _score = score;         // update editor with selected item
    }
Esempio n. 3
0
        public static void ShowHighScoreDialog(Highscore highScore, int score)
        {
            // Create form
            Size size = new Size(300, 480);
            Font font = new Font("Courier New", 20);

            System.Windows.Forms.Form inputBox = new System.Windows.Forms.Form();

            inputBox.FormBorderStyle = FormBorderStyle.FixedDialog;
            inputBox.ClientSize      = size;
            inputBox.StartPosition   = FormStartPosition.CenterParent;
            inputBox.Text            = "Highscores";
            inputBox.MaximizeBox     = false;
            inputBox.MinimizeBox     = false;

            // Add own score
            Label label = new Label();

            label.Size     = new Size(size.Width - 10, 23);
            label.Location = new Point(20, 5);
            label.Font     = font;
            label.Text     = $"Your score: {score}";
            inputBox.Controls.Add(label);

            // Add other highscores
            Label highScores = new Label();

            highScores.Size     = new Size(size.Width - 10, 370);
            highScores.Location = new Point(20, 50);
            highScores.Font     = font;
            highScores.Text     = $"Highscores:\n\n{highScore.ToString()}";
            inputBox.Controls.Add(highScores);

            // Add an okay button
            Button okButton = new Button();

            okButton.DialogResult = DialogResult.OK;
            okButton.Name         = "okButton";
            okButton.Size         = new Size(75, 40);
            okButton.Text         = "&OK";
            okButton.Font         = font;
            okButton.Location     = new Point((int)(size.Width - 80 - 75 * 1.5), 420);
            inputBox.Controls.Add(okButton);
            inputBox.AcceptButton = okButton;

            inputBox.ShowDialog();
        }
Esempio n. 4
0
    void Update()
    {
        // input
        for(int i = 0; i < playersPlaying.Length; ++i)
        {
            if (playersPlaying[i] && charactersUsed[i] < 3)
            {
                if (charactersUsed[i] < 3 && inputLabels[i].text.Length > 0)
                {
                    inputLabels[i].text = inputLabels[i].text.Substring(0, inputLabels[i].text.Length - 1);
                }

                float moveY = InputDevice.GetAxisY(i);
                if (moveY == 0.0f)
                {
                    movedStick[i] = false;
                }
                if (movedStick[i] == false)
                {
                    if (moveY == 0.0f)
                    {
                    }
                    else if (moveY > 0.001f)
                    {
                        movedStick[i] = true;
                        ++selectedCharacter[i];
                        if (selectedCharacter[i] >= maxChars)
                        {
                            selectedCharacter[i] = 0;
                        }
                    }
                    else if (moveY < 0.001f)
                    {
                        movedStick[i] = true;

                        --selectedCharacter[i];
                        if (selectedCharacter[i] < 0)
                        {
                            selectedCharacter[i] = maxChars - 1;
                        }
                    }
                }

                if (InputDevice.GetA_Up(i))
                {
                    ++charactersUsed[i];
                    inputLabels[i].text += characters[selectedCharacter[i]];
                }
                else if (InputDevice.GetB_Up(i))
                {
                    if (charactersUsed[i] > 0)
                    {
                        --charactersUsed[i];
                        inputLabels[i].text = inputLabels[i].text.Substring(0, inputLabels[i].text.Length - 1);
                    }
                }

                // Add the last selected character to highlight it
                if (charactersUsed[i] < 3)
                {
                    inputLabels[i].text += characters[selectedCharacter[i]];
                }
            }
        }

        bool bothDone = false;
        for (int i = 0; i < playersPlaying.Length; ++i)
        {
            if(playersPlaying[i])
            {
                // If player 2 or higher and previous player IS playing
                if (i > 0 && playersPlaying[0])
                {
                    bothDone = bothDone && charactersUsed[i] == 3;
                }
                else
                {
                    bothDone = charactersUsed[i] == 3;
                }
            }
        }

        timeToInput -= Time.deltaTime;
        if (timeToInput < 0.0f)
        {
            timeToInput = 0.0f;
        }
        timer.text = Mathf.Round(timeToInput).ToString();

        if (timeToInput <= 0.0f || bothDone)
        {
            int playerCount = 1;
            string newName = "";
            if (playersPlaying[0] && playersPlaying[1])
            {
                newName = inputLabels[0].text + " & " + inputLabels[1].text;
                playerCount = 2;
            }
            else if (playersPlaying[0])
            {
                newName = inputLabels[0].text;
            }
            else
            {
                newName = inputLabels[1].text;
            }

            int level = 1;
            Highscore newScore = new Highscore(newName, CGame.Singleton.HighscoreTimer, level);
            CGame.Singleton.SetNewHighscore(playerCount, newScore);

            gameOverLogic.state = GameOverScreenLogic.EScreenState.GameOver;
            gameOverLogic.secondaryGameOverText.text = newScore.ToString();
            gameOverLogic.gameOverPage.SetActive(true);
            gameOverLogic.inputHighscore.SetActive(false);
        }
    }