Пример #1
0
    //返回主選單
    public IEnumerator BackToMenu()
    {
        AudioManagerScript.Instance.Stop(0);

        UIController.Instance.rot_blackChess.SetRotating(false); //停止棋盆旋轉
        UIController.Instance.rot_whiteChess.SetRotating(false);

        ChessBehavior.Instance.ai_black = null; //AI重置
        ChessBehavior.Instance.ai_white = null;

        yield return(new WaitForSeconds(0.5f));

        UIController.Instance.animScript_gameMenu.PlayAnimation("GamingMenu_FadeOut", new AnimationBehavior(PlayMode.狀態延續)
        {
            disableObject = true
        }, false);                                                                               //遊戲選單淡出

        Vector2 blackPoint = UIController.Instance.rot_blackChess.gameObject.transform.position; //黑子棋盆位置
        Vector2 whitePoint = UIController.Instance.rot_whiteChess.gameObject.transform.position; //白子棋盆位置
        float   freq       = 0.02f;                                                              //頻率

        ChessBehavior.Instance.lastChessIcon.SetActive(false);                                   //隱藏最後下棋點提示
        for (int i = 0; i < ChessBehavior.Instance.chessLine.Count; i++)                         //清除棋盤上的所有棋子(動畫展示)
        {
            ChessType       t = ChessBehavior.Instance.chessLine[i].GetComponent <ChessAttribute>().thisChess;
            AnimationScript animationScript = ChessBehavior.Instance.chessLine[i].GetComponent <AnimationScript>();
            if (animationScript.animationPlaying)
            {
                animationScript.animationPlaying = false;
            }
            animationScript.AnimationCommand(new PositionScript(UIController.Instance.chessReturnCurve, t == ChessType.白子 ? whitePoint : blackPoint, true), new AnimationBehavior(PlayMode.狀態延續)
            {
                destroyThis = true
            });
            AudioManagerScript.Instance.PlayAudioClip("chess_return");
            yield return(new WaitForSeconds(freq));
        }

        ChessBehavior.Instance.chessLine = new List <GameObject>(); //初始化棋子隊列

        yield return(new WaitForSeconds(UIController.Instance.chessReturnCurve.keys[UIController.Instance.chessReturnCurve.keys.Length - 1].time));

        UIController.Instance.animScript_mainMenu.PlayAnimation("MainMenuGameOver", new AnimationBehavior(PlayMode.狀態延續, new ActionSetting(() => { UIController.Instance.cg_mainMenu.blocksRaycasts = true; }, TaskMode.僅結束時)), false); //選單UI復歸

        yield return(new WaitForSeconds(0.9f));

        UIController.Instance.animSript_curtain.AnimationCommand(new AlphaScript(0.35f, 0.7f), new AnimationBehavior(PlayMode.狀態延續)); //遮布淡入
        AudioManagerScript.Instance.PlayAudioClip("music_main_menu");                                                                 //撥放音樂
    }
Пример #2
0
    //再來一局
    public IEnumerator PlayAgain()
    {
        UIController.Instance.rot_blackChess.SetRotating(false); //停止棋盆旋轉
        UIController.Instance.rot_whiteChess.SetRotating(false);

        Vector2 blackPoint = UIController.Instance.rot_blackChess.gameObject.transform.position; //黑子棋盆位置
        Vector2 whitePoint = UIController.Instance.rot_whiteChess.gameObject.transform.position; //白子棋盆位置
        float   freq       = 0.02f;                                                              //頻率

        ChessBehavior.Instance.lastChessIcon.SetActive(false);                                   //隱藏最後下棋點提示
        for (int i = 0; i < ChessBehavior.Instance.chessLine.Count; i++)                         //清除棋盤上的所有棋子(動畫展示)
        {
            ChessType       t = ChessBehavior.Instance.chessLine[i].GetComponent <ChessAttribute>().thisChess;
            AnimationScript animationScript = ChessBehavior.Instance.chessLine[i].GetComponent <AnimationScript>();
            if (animationScript.animationPlaying)
            {
                animationScript.animationPlaying = false;
            }
            animationScript.AnimationCommand(new PositionScript(UIController.Instance.chessReturnCurve, t == ChessType.白子 ? whitePoint : blackPoint, true), new AnimationBehavior(PlayMode.狀態延續)
            {
                destroyThis = true
            });
            AudioManagerScript.Instance.PlayAudioClip("chess_return");
            yield return(new WaitForSeconds(freq));
        }

        ChessBehavior.Instance.turn      = UIController.Instance.senteChess;     //設定先手
        ChessBehavior.Instance.chessLine = new List <GameObject>();              //初始化棋子隊列

        UIController.Instance.retractRemain         = UIController.retractTimes; //重置悔棋次數
        UIController.Instance.tx_retractRemain.text = "剩下  " + UIController.Instance.retractRemain + "  次";
        UIController.Instance.RetractButtonState(false);                         //因棋盤上的棋子數<2, 禁用悔棋按鈕

        yield return(new WaitForSeconds(0.3f));

        UIController.Instance.animScrip_interlude.PlayAnimation("Interlude_GameStart", new AnimationBehavior(PlayMode.初始化, new ActionSetting(
                                                                                                                 () =>
        {
            UIController.Instance.cg_gameMenu.blocksRaycasts = true;
            ChessBehavior.Instance.GameInitialization();
        },
                                                                                                                 TaskMode.僅結束時)), false);
    }
Пример #3
0
    //改變玩家類型(upOrDown true=上,false=下 , senteOrGote true=先手,false=後手)
    //內部執行方法
    private void _ChangePlayerType(bool upOrDown, bool blackOrWhite)
    {
        int index     = blackOrWhite ? (int)blackPlayer : (int)whitePlayer;
        int nextIndex = upOrDown ? ((index + 1) % (playerTypeList.Count)) : (index - 1 < 0 ? playerTypeList.Count - 1 : index - 1);

        if (blackOrWhite)
        {
            tx_blackPlayerType.text      = playerTypeList[index];
            tx_blackPlayerType_hide.text = playerTypeList[nextIndex];
            blackPlayer = (PlayerType)nextIndex;
        }
        else
        {
            tx_whitePlayerType.text      = playerTypeList[index];
            tx_whitePlayerType_hide.text = playerTypeList[nextIndex];
            whitePlayer = (PlayerType)nextIndex;
        }

        int buttonCount = blackOrWhite ? blackSelectionButtons.Length : whiteSelectionButtons.Length;

        Button[] buttons = blackOrWhite ? blackSelectionButtons : whiteSelectionButtons;

        float   animTime     = 0.18f; //圖示顯亮or顯暗作動時間
        Color32 enableColor  = new Color32(255, 255, 255, 255);
        Color32 disableColor = new Color32(100, 100, 100, 255);

        for (int i = 0; i < buttonCount; i++)
        {
            if ((PlayerType)nextIndex == PlayerType.玩家)
            {
                if (blackOrWhite)
                {
                    animScript_blackAiButtonFrame.AnimationCommand(new ColorScript(animTime, disableColor), new AnimationBehavior(PlayMode.狀態延續));
                    tx_blackAiType.text      = aiTypeList[(int)blackAi];
                    tx_blackAiType_hide.text = "-";
                    animScript_changeBlackAi.PlayAnimation("SelectionSwitchOver_TurnUp", new AnimationBehavior(PlayMode.狀態延續), false);
                }
                else
                {
                    animScript_whiteAiButtonFrame.AnimationCommand(new ColorScript(animTime, disableColor), new AnimationBehavior(PlayMode.狀態延續));
                    tx_whiteAiType.text      = aiTypeList[(int)whiteAi];
                    tx_whiteAiType_hide.text = "-";
                    animScript_changeWhiteAi.PlayAnimation("SelectionSwitchOver_TurnUp", new AnimationBehavior(PlayMode.狀態延續), false);
                }
                buttons[i].interactable = false;
            }
            else
            {
                if (blackOrWhite)
                {
                    animScript_blackAiButtonFrame.AnimationCommand(new ColorScript(animTime, enableColor), new AnimationBehavior(PlayMode.狀態延續));
                    if (tx_blackAiType_hide.text == "-")
                    {
                        tx_blackAiType.text      = "-";
                        tx_blackAiType_hide.text = aiTypeList[(int)blackAi];
                        animScript_changeBlackAi.PlayAnimation("SelectionSwitchOver_TurnUp", new AnimationBehavior(PlayMode.狀態延續), false);
                    }
                }
                else
                {
                    animScript_whiteAiButtonFrame.AnimationCommand(new ColorScript(animTime, enableColor), new AnimationBehavior(PlayMode.狀態延續));
                    if (tx_whiteAiType_hide.text == "-")
                    {
                        tx_whiteAiType.text      = "-";
                        tx_whiteAiType_hide.text = aiTypeList[(int)whiteAi];
                        animScript_changeWhiteAi.PlayAnimation("SelectionSwitchOver_TurnUp", new AnimationBehavior(PlayMode.狀態延續), false);
                    }
                }
                buttons[i].interactable = true;
            }
        }

        if (blackOrWhite)
        {
            animScript_changeBlackPlayer.PlayAnimation(upOrDown ? "SelectionSwitchOver_TurnUp" : "SelectionSwitchOver_TurnDown", new AnimationBehavior(PlayMode.狀態延續), false);
        }
        else
        {
            animScript_changeWhitePlayer.PlayAnimation(upOrDown ? "SelectionSwitchOver_TurnUp" : "SelectionSwitchOver_TurnDown", new AnimationBehavior(PlayMode.狀態延續), false);
        }
    }