Example #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();
            }
        }
    }
Example #2
0
    void Start()
    {
        DataPasser.Get().Set("repeat", "false");
        logout.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                 delegate
        {
            buttonSound.Play();
            CloseWidget();
            Application.LoadLevel(0);
        }
                                                 )));



        Deliver();
        if (DataPasser.Get().dic.ContainsKey("tai"))
        {
            tai = (Server.TokenAndId)DataPasser.Get().Get("tai");
        }
        else
        {
            tai = Server.Authorize("einhorn", "795132486");
        }

        SetSetingsPart();

        UnityEngine.Debug.Log("Start lobby");
        Set(tai);
    }
Example #3
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");
     }
 }
    void Start()
    {
        //camera.orthographicSize = (float)Screen.height / (float)600.0 * 1.0f;

        back.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                               delegate
        {
            Application.LoadLevel(0);
        }
                                               )));

        widget = new BrainDuelsLib.widgets.UnitySignupWidget();
        widget.Controls.button               = signUpButton;
        widget.Controls.loginField           = loginInputText;
        widget.Controls.passwordField        = passwordInputText;
        widget.Controls.confirmPasswordFirls = confirmPasswordInputText;

        widget.Callbacks.errorCallback = delegate
        {
            UnityEngine.Debug.Log("error");
            errorMessage.text = "Unexpected error";
        };

        widget.Callbacks.userExists = delegate
        {
            UnityEngine.Debug.Log("error");
            errorMessage.text = "Login is not available";
        };


        widget.Callbacks.incorrectLoginCallback = delegate
        {
            UnityEngine.Debug.Log("Incorrect login");
            errorMessage.text = UnityLoginFormControl.INCORRECT_LOGIN_MESSAGE;
        };

        widget.Callbacks.incorrectPasswordCallback = delegate
        {
            UnityEngine.Debug.Log("Incorrect password");
            errorMessage.text = UnityLoginFormControl.INCORRECT_PASSWORD_MESSAGE;
        };

        widget.Callbacks.passwordsDoNotMatchCallback = delegate
        {
            UnityEngine.Debug.Log("Passwords do not match");
            errorMessage.text = "Passwords do not match";
        };

        widget.Callbacks.succesfullSignUpCallback = delegate(Server.TokenAndId tai)
        {
            errorMessage.text = "Logging in...";
            UnityEngine.Debug.Log("sign up success");
            UnityEngine.Debug.Log("login success");
            DataPasser.Get().Set("tai", tai);
            Application.LoadLevel(2);
        };

        widget.Go();
    }
Example #5
0
 public static DataPasser Get()
 {
     if (instance == null)
     {
         instance = new DataPasser();
     }
     return(instance);
 }
Example #6
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);
    }
Example #7
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();
    }
Example #8
0
    void Start()
    {
        if (DataPasser.Get().dic.ContainsKey("repeat") && DataPasser.Get().Get("repeat").Equals("true"))
        {
            errorMessage.text = "You are logged in from another device";
        }
        Debug.Log(Screen.width + " " + Screen.height);
        //camera.orthographicSize = Screen.height / (float)600.0 * 1.0f;

        Screen.sleepTimeout = SleepTimeout.NeverSleep;
        Debug.Log("Logiiiin");

        /*
         * if (UnityEngine.PlayerPrefs.HasKey("fb") && (UnityEngine.PlayerPrefs.GetString("fb").Equals("true")))
         * {
         *  string fbLogin = UnityEngine.PlayerPrefs.GetString("fb_login");
         *  string fbPassword = UnityEngine.PlayerPrefs.GetString("fb_password");
         *  Server.TokenAndId tai = Server.Authorize(fbLogin, fbPassword);
         *  Debug.Log("to lobby, " + tai);
         *  return;
         * }
         */

        this.toggle.value = false;
        if (UnityEngine.PlayerPrefs.HasKey("remember") && (UnityEngine.PlayerPrefs.GetString("remember").Equals("yes")))
        {
            loginInputText.text.value    = UnityEngine.PlayerPrefs.GetString("login");
            passwordInputText.text.value = UnityEngine.PlayerPrefs.GetString("password");
            this.toggle.value            = true;
        }
        else
        {
        }

        widget = new BrainDuelsLib.widgets.UnityLoginWidget();
        widget.Controls.loginButton           = loginButton;
        widget.Controls.signUpReferenceButton = signUpButton;
        widget.Controls.loginField            = loginInputText;
        widget.Controls.passwordField         = passwordInputText;

        widget.Callbacks.errorCallback = delegate
        {
            UnityEngine.Debug.Log("error");
            errorMessage.text = "Unexpected error";
        };

        widget.Callbacks.wrongLogin = delegate
        {
            UnityEngine.Debug.Log("wrong login");
            errorMessage.text = INCORRECT_LOGIN_MESSAGE;
        };

        widget.Callbacks.wrongPassword = delegate
        {
            UnityEngine.Debug.Log("wrong password");
            errorMessage.text = INCORRECT_PASSWORD_MESSAGE;
        };

        widget.Callbacks.invalidLoginPasswordCallback = delegate
        {
            UnityEngine.Debug.Log("invalid login password");
            errorMessage.text = "Invalid login or password";
        };

        widget.Callbacks.signUpCallback = delegate
        {
            Application.LoadLevel(1);
            UnityEngine.Debug.Log("go to sign up");
        };

        widget.Callbacks.succesfullLoginCallback = delegate(Server.TokenAndId tai)
        {
            errorMessage.text = "Logging in";

            UnityEngine.Debug.Log("login success");
            DataPasser.Get().Set("tai", tai);



            if (toggle.value)
            {
                UnityEngine.PlayerPrefs.SetString("login", loginInputText.text.value);
                UnityEngine.PlayerPrefs.SetString("password", passwordInputText.text.value);
                UnityEngine.PlayerPrefs.Save();
            }
            else
            {
                //UnityEngine.PlayerPrefs.SetString("login", loginInputText.text.value);
                //UnityEngine.PlayerPrefs.SetString("password", passwordInputText.text.value);
                //UnityEngine.PlayerPrefs.Save();
            }
            Application.LoadLevel(2);
        };

        widget.Go();


        toggle.onChange.Add(new EventDelegate(new EventDelegate.Callback(

                                                  delegate()
        {
            if (toggle.value)
            {
                UnityEngine.PlayerPrefs.SetString("remember", "yes");
            }
            else
            {
                UnityEngine.PlayerPrefs.SetString("remember", "no");
            }
        }

                                                  )));
    }
Example #9
0
 void Awake()
 {
     instance = this;
 }