Пример #1
0
    private void PieceSelected(PuzzlePiece piece)
    {
        Debug.Log("this the one pop? " + piece.ID);

        if (stateManager.CurrentState != states[2])
        {
            return;
        }

        audioSource.clip = buttonSound;
        audioSource.Play();

        if (selected == players.Count)
        {
            return;
        }

        selected++;

        PuzzleController currentPuzzle = puzzleMap[piece];

        if (piece.isLeftSide)
        {
            isSpawningLeft = false;
            leftPick       = piece;
            foreach (PuzzleController puz in puzzlesInPlayPool)
            {
                if (puz.IsLeftSide())
                {
                    puz.SetActive(false);
                    puz.SetVisable(false);
                }
            }
        }
        else
        {
            isSpawningRight = false;
            rightPick       = piece;
            foreach (PuzzleController puz in rightPuzzlePool)
            {
                puz.SetActive(false);
                puz.SetVisable(false);
            }
        }

        currentPuzzle.SetVisable(true);
        puzzlesInPlayPool.Remove(currentPuzzle);

        if (selected == players.Count)
        {
            if (leftPick.ID == rightPick.ID)
            {
                winLoseAudio.clip = correctSound;
                winLoseAudio.Play();

                mainScreen.FillHeart(.2f);
                mainScreen.AddTime(0);
            }
            else
            {
                winLoseAudio.clip = wrongSount;
                winLoseAudio.Play();
            }

            foreach (PlayerModel model in playerModels)
            {
                model.HasSelected = false;
            }

            PuzzleController LcurrentPuzzle = puzzleMap[leftPick];
            PuzzleController RcurrentPuzzle = puzzleMap[rightPick];

            LcurrentPuzzle.SetVisable(false);
            RcurrentPuzzle.SetVisable(false);

            leftPick  = null;
            rightPick = null;

            isSpawningRight = true;
            isSpawningLeft  = true;

            DisplaySpawned();

            selected = 0;
        }
    }