Пример #1
0
    /// <summary>
    /// Called when a user click on a block and answered a question related to that block
    /// </summary>
    /// <param name="isCorrect">If set to <c>true</c> is correct.</param>
    public void OnChoiceSelected(bool isCorrect)
    {
        Debug.Log("OnChoiceSelected: " + isCorrect + ", ActiveNode: " + activeNode + ", NodeType: " + activeNode.nodeType);
        ShowHud(true);

        if (isCorrect)
        {
            GameBoard.MovePlayer(GetCurrentPlayerController(), activeNode.gameObject, (p) =>
            {
                switch (activeNode.nodeType)
                {
                case NodeType.JumpToAnyPillar:
                    GameBoard.HighlightPillarBlocks(p);
                    HUDController.DisplayMessage("Select the pillar to jump");
                    break;

                case NodeType.AnswerEasyToWinTwoJump:
                    Debug.Log("Win 2 Jumps");
                    HUDController.DisplayMessage("Select the block for free jump");
                    HighlightBlock(GetCurrentPlayerController(), 2);
                    break;

                case NodeType.WinAPillarOrGoToSchool:
                    ProcessAfterPlayerMovedToWinAPillarOrGoToSchool(GetCurrentPlayerController());
                    Debug.Log("Player win a free pillar");
                    break;

                default:
                    ProcessAfterPlayerMoved(p);
                    Debug.Log("Moved normally");
                    break;
                }
            });
        }
        else
        {
            // If a player is tapping a Win A Pillar or go to school, but failed to answer then punish them
            if (activeNode.nodeType == NodeType.WinAPillarOrGoToSchool)
            {
                GameBoard.MovePlayer(GetCurrentPlayerController(), gameBoard.schoolBoxBlock.gameObject, ProcessAfterPlayerMoved);
            }
            else
            {
                activeNode = null;
                GameClientPlugin.EndTurn(null);
            }
        }
    }