Ejemplo n.º 1
0
    void OnApplicationQuit()
    {
        DBSocketRequest.Close();

        UnityEngine.Debug.Log("Game quit");
        StopChat();

        if (lw != null)
        {
            UnityEngine.Debug.Log("stop toy lobby");
            lw.Stop();
        }

        if (gameWidget != null)
        {
            UnityEngine.Debug.Log("stop game");
            gameWidget.Stop();
        }

        if (!isTest)
        {
            LobbyWidget lobby = (LobbyWidget)DataPasser.Get().Get("lobby");
            if (lobby != null)
            {
                UnityEngine.Debug.Log("stop actual lobby");
                lobby.Stop();
            }
        }
    }
Ejemplo n.º 2
0
 public void InitGameWidgetPart()
 {
     board = b;
     if (!isTest)
     {
         Server.TokenAndId tai = (Server.TokenAndId)DataPasser.Get().Get("tai");
         Game    game          = (Game)DataPasser.Get().Get("game");
         Boolean isObserver    = (Boolean)DataPasser.Get().Get("is_observer");
         SetGameWidgetPart(tai, game);
     }
     else
     {
         Server.TokenAndId tai = Server.Authorize("!!FB!!103018196855905", "uskjlrvkovscfzzwbtsr");
         lw = new LobbyWidget(tai);
         LobbyBackendWidget backgroud = new LobbyBackendWidget(tai);
         backgroud.Controls.timer = new CrazyGoTimerControl(1000, lobbyTimer);
         lw.Controls.backgroud    = backgroud;
         lw.Callbacks.goToGameAsPlayerCallback = delegate(Game g)
         {
             lw.Discard();
             Debug.Log("Go to game as player");
             SetGameWidgetPart(tai, g);
         };
         lw.Go();
         lw.Controls.backgroud.OpenForRandomChallenge("hidden-move-go", "board_size-19|komi-7.5|first_player-0|randomize-1|hm_count-7|time-b3600#60#5");
     }
 }
Ejemplo n.º 3
0
    public void GoToLobby()
    {
        DataPasser.Get().Set("tai", tai);

        LobbyWidget lobby = (LobbyWidget)DataPasser.Get().Get("lobby");

        if (lobby != null)
        {
            UnityEngine.Debug.Log("stop lobby");
            lobby.Stop();
        }

        if (gameWidget != null)
        {
            gameWidget.Stop();
            UnityEngine.Debug.Log("stop game widget");
        }

        StopChat();

        Application.LoadLevel(2);
    }
Ejemplo n.º 4
0
    void Set(Server.TokenAndId tai)
    {
        moi         = this;
        lobbyWidget = new LobbyWidget(tai);
        LobbyBackendWidget backgroud = new LobbyBackendWidget(tai);

        backgroud.Controls.timer       = new CrazyGoTimerControl(1000, timerScriptLobby);
        lobbyWidget.Controls.backgroud = backgroud;
        lobbyWidget.Callbacks.goToGameAsPlayerCallback = delegate(Game g)
        {
            lobbyWidget.Discard();
            newGameSound.Play();
            UnityEngine.Debug.Log("Go to game");


            DataPasser.Get().Set("lobby", lobbyWidget);
            DataPasser.Get().Set("tai", tai);
            DataPasser.Get().Set("is_observer", false);
            DataPasser.Get().Set("game", g);
            CloseWidget();
            Application.LoadLevel(3);
        };

        lobbyWidget.Callbacks.repeatedCallback = delegate()
        {
            lobbyWidget.Discard();
            UnityEngine.Debug.Log("Already connected");
            CloseWidget();
            DataPasser.Get().Set("repeat", "true");
            Application.LoadLevel(0);
        };


        SetUserInfo();
        SetPlayBarPart(lobbyWidget);
        lobbyWidget.Go();
    }
Ejemplo n.º 5
0
    public void SetPlayBarPart(LobbyWidget lobbyWidget)
    {
        this.gamesListSprite.spriteName  = "nicht";
        this.playerListSprite.spriteName = "nicht";

        GameScrollableList.me = tai.id;
        this.gamesList.transform.localPosition         = new Vector3(0, 0, 0);
        this.playersList.transform.localPosition       = new Vector3(0, -10, 0);
        this.createGamePopup.transform.localPosition   = new Vector3(this.createGamePopup.transform.localPosition.x, 0, 0);
        this.newChallengePopup.transform.localPosition = new Vector3(this.newChallengePopup.transform.localPosition.x, 0, 0);

        lobbyWidget.Callbacks.gamesCallback      = UpdateGames;
        lobbyWidget.Callbacks.getPlayersCallback = UpdatePlayers;
        //setMock();


        Utils.MakeUnvisible(createGamePopup.transform);
        Utils.MakeUnvisible(this.newChallengePopup.transform);


        createGameButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                           delegate
        {
            callCreateGamePopup(false, delegate
            {
                Settings settings = createGamePopup.GetSettings();
                String title      = createGamePopup.GetGame();
                if (title.Equals("hidden-move-go"))
                {
                    settings.handi = false;
                }
                this.lobbyWidget.CreateNewGame(2, title, Settings.Save(settings));


                if (!Utils.IsUnvisible(createGamePopup.transform))
                {
                    Utils.MakeUnvisible(createGamePopup.transform);
                }
            });
        }
                                                           )));

        lobbyWidget.Callbacks.rejectedChallengeCallback = delegate(int a, string aa, string aaa, int aaaa)
        {
            if (Utils.IsUnvisible(createGamePopup.transform))
            {
                //Utils.MakeVisible(createGamePopup.transform);
            }
            else
            {
                Utils.MakeUnvisible(createGamePopup.transform);
            }
        };



        lobbyWidget.Callbacks.newChallengeCallback = delegate(int a, string aa, string aaa, int aaaa)
        {
            for (int i = 0; i < this.incomingChallenges.Count(); i++)
            {
                lobbyWidget.RejectChallenge(incomingChallenges[i].ch, incomingChallenges[i].title, incomingChallenges[i].settings, incomingChallenges[i].id);
            }
            incomingChallenges.Clear();

            IncomingChallenge me = new IncomingChallenge();
            int    id            = a;
            string title         = aa;
            string settings      = aaa;
            int    chId          = aaaa;
            me.ch       = id;
            me.title    = title;
            me.settings = settings;
            me.id       = chId;
            incomingChallenges.Add(me);

            if (Utils.IsUnvisible(newChallengePopup.transform))
            {
                Utils.MakeVisible(newChallengePopup.transform);
            }

            User     opponent = Server.GetUser(tai, id);
            Settings set      = Settings.Load(settings);
            newChallengeFromLabel.text = opponent.login + "(" + opponent.GetRankString() + ")";
            if (title.Equals("go"))
            {
                this.newChallengeGameString.text = "Go";
            }

            if (title.Equals("one-color-go"))
            {
                this.newChallengeGameString.text = "One color Go";
            }

            if (title.Equals("blind-go"))
            {
                this.newChallengeGameString.text = "Blind Go";
            }

            if (title.Equals("hidden-move-go"))
            {
                this.newChallengeGameString.text = "Hidden move Go";
            }

            this.newChallengeTimeString.text  = set.GetTimeControl();
            this.newChallengeHandiString.text = set.GetHandi() ? "Yes" : "No";
            this.newChallengeSizeString.text  = set.size + "*" + set.size;

            acceptChallengeButton.onClick.Clear();
            acceptChallengeButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                                    delegate
            {
                lobbyWidget.AcceptChallenge(a, aa, aaa, aaaa);
            }
                                                                    )));

            rejectChallengeButton.onClick.Clear();
            this.rejectChallengeButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                                         delegate
            {
                lobbyWidget.RejectChallenge(a, aa, aaa, aaaa);
                incomingChallenges.Clear();

                if (Utils.IsUnvisible(newChallengePopup.transform))
                {
                    Utils.MakeVisible(newChallengePopup.transform);
                }
                else
                {
                    Utils.MakeUnvisible(newChallengePopup.transform);
                }
            }
                                                                         )));
        };


        lobbyWidget.Callbacks.expiredChallengeCallback = delegate(int chId)
        {
            Debug.Log("Expired " + chId);
            if (incomingChallenges.Count > 0)
            {
                int last = incomingChallenges[incomingChallenges.Count - 1].id;
                Debug.Log("Last " + last);
                if (last == chId)
                {
                    Debug.Log("Delete " + chId);
                    if (!Utils.IsUnvisible(newChallengePopup.transform))
                    {
                        Debug.Log("deleted");
                        Utils.MakeUnvisible(newChallengePopup.transform);
                    }
                }
            }
        };
    }