Exemple #1
0
    private void SelectSide(PinZiPP side)
    {
        if (!isPlaying)
        {
            return;
        }
        if (curSelections [0] == null)
        {
            displayController.SelectSide(side);
            curSelections [0] = side.sidename;
            Debug.Log("curSelection[0] is " + side.sidename);
        }
        else
        {
            if (curSelections [0] == side.sidename)
            {
                curSelections = new string[2];
                Debug.Log("curSelection[0] is " + "de-selected.");
                displayController.SelectSide(side);
            }
            else
            {
                displayController.SelectSide(side);
                curSelections [1] = side.sidename;
                Debug.Log("curSelection[1] is " + side.sidename);

                if (HasPlayerWon())
                {
                    if (hasWon)
                    {
                        Debug.Log("has already won this round");
                        return;
                    }
                    hasWon    = true;
                    isPlaying = false;
                    audioSource.PlayOneShot(winSound);
                    displayController.DisplayWin();
                    dataController.WinThisRound();
                }
                else
                {
                    Debug.Log("Wrong Selection!" + " Correct answer is" + curWord.correctSides[0] + ", " + curWord.correctSides[1]);
                    displayController.UnselectAllSides();
                    curSelections = new string[2];
                    audioSource.PlayOneShot(loseSound);
                    isPlaying = false;
                    displayController.DisplayLose();
                }
            }
        }
    }