コード例 #1
0
    public void SetGameWidgetPart(Server.TokenAndId tai, Game game)
    {
        this.tai   = tai;
        this.game  = game;
        gameWidget = new GameWidget(tai, game);
        CrazyGoTimerControl timerControl = new CrazyGoTimerControl(250, timerScript);

        gameWidget.Controls.timer = timerControl;

        gameWidget.Callbacks.updateGameCallback = delegate(string s, int a)
        {
            UpdateGameCallback(s, a);
        };


        gameWidget.Callbacks.eventCallback = delegate(string message)
        {
            OnEvent(message);
        };


        gameWidget.Callbacks.illegalMoveCallback = delegate
        {
            UnityEngine.Debug.Log("Illegal move");
        };


        gameWidget.Callbacks.gameEndedCallback = delegate(string res)
        {
            this.OnGameEnd(res);
        };

        gameWidget.Callbacks.gameEndedCallback = delegate(string s)
        {
            OnGameEnd(s);
            UnityEngine.Debug.Log("Game ended: result is " + s);
        };

        gameWidget.Callbacks.eventCallback = delegate(string s)
        {
            OnEvent(s);
            //UnityEngine.Debug.Log("Event: " + s);
        };


        moveButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                     delegate
        {
            //pressButtonSound.Play();
            Point a = this.controller.GetCurrentMoveIndicator();
            if (a != null)
            {
                gameWidget.MakeAMove(a.x + "-" + a.y);
            }
        }
                                                     )));

        resignButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                       delegate
        {
            pressButtonSound.Play();
            Utils.MakeVisible(resignPopup.transform);
        }
                                                       )));

        yesResignButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                          delegate
        {
            pressButtonSound.Play();
            Utils.MakeUnvisible(resignPopup.transform);
            gameWidget.MakeAMove("resign");
        }
                                                          )));


        this.yesTry.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                      delegate
        {
            pressButtonSound.Play();
            Utils.MakeUnvisible(this.tryPopup.transform);
            gameWidget.MakeAMove("yes");
        }
                                                      )));

        this.noTry.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                     delegate
        {
            pressButtonSound.Play();
            Utils.MakeUnvisible(this.tryPopup.transform);
            gameWidget.MakeAMove("no");
        }
                                                     )));


        this.passButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                          delegate
        {
            pressButtonSound.Play();
            Utils.MakeUnvisible(resignPopup.transform);
            gameWidget.MakeAMove("pass");
        }
                                                          )));

        this.agreeButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                           delegate
        {
            pressButtonSound.Play();
            Utils.MakeUnvisible(resignPopup.transform);
            gameWidget.MakeAMove("agree");
        }
                                                           )));

        this.askButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                         delegate
        {
            pressButtonSound.Play();
            Utils.MakeUnvisible(resignPopup.transform);
            gameWidget.MakeAMove("ask");
        }
                                                         )));

        this.goButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                        delegate
        {
            gameWidget.MakeAMove("go");
        }
                                                        )));

        noResignButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                         delegate
        {
            pressButtonSound.Play();
            Utils.MakeUnvisible(resignPopup.transform);
            //gameWidget.MakeAMove("resign");
        }
                                                         )));


        exitButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                     delegate
        {
            GoToLobby();
        }
                                                     )));

        /*
         * this.board.SetUserTogglePoint(delegate (Point a)
         * {
         *  if (a.x >= 0 && a.x < this.board.GetN())
         *  {
         *      if (a.y >= 0 && a.y < this.board.GetN())
         *      {
         *          gameWidget.MakeAMove(a.x + "-" + a.y);
         *      }
         *  }
         * });
         */

        gameWidget.Go();
        SetInitialData();
        StartChat();
    }