示例#1
0
文件: Simple.cs 项目: capasha/Rabbit
 /// <summary>
 /// Authenticates with the specified email and password.
 /// </summary>
 /// <param name="gameId">The game id.</param>
 /// <param name="email">The email.</param>
 /// <param name="password">The password.</param>
 /// <returns>Client.</returns>
 public static Client Authenticate(string gameId, string email, string password, string[] playerInsightSegments = null)
 {
     PlayerIO.QuickConnect.SimpleConnect(gameId, email, password, playerInsightSegments, (Client client) =>
     {
         if (!client.BigDB.LoadMyPlayerObject().Contains("linkedTo"))
         {
             client_ = client;
             s1.Release();
         }
         else
         {
             client.Multiplayer.CreateJoinRoom("$service-room", "AuthRoom", true, null, new Dictionary <string, string>()
             {
                 { "type", "Link" }
             }, (Connection con) =>
             {
                 con.OnMessage += (object sender1, PlayerIOClient.Message m) =>
                 {
                     if (m.Type == "auth")
                     {
                         client_ = PlayerIO.Authenticate("everybody-edits-su9rn58o40itdbnw69plyw", "linked", new Dictionary <string, string>()
                         {
                             { "userId", m.GetString(0) }, { "auth", m.GetString(1) }
                         }, null);
                         s1.Release();
                     }
                 };
             });
         }
     });
     s1.WaitOne();
     return(client_);
 }
    private void AuthenticateAndLoad()
    {
        waitingGO.SetActive(true);
        rankingModalGO.SetActive(false);

        string userId = "Guest" + UnityEngine.Random.Range(0, 10000);

        PlayerIO.Authenticate(
            "bloodblood-i1xisc4vquzylare1lvma",                 //Your game id
            "public",                                           //Your connection id
            new Dictionary <string, string>
        {
            { "userId", userId }
        },
            null,                                               //PlayerInsight segments
            delegate(Client client)
        {
            Debug.Log("auth complete");
            this.LoadRanking(client);
        },
            delegate(PlayerIOError error) {
            Debug.Log("Error connecting: " + error.ToString());
            this.GoBackMainMenu();
        }
            );
    }
示例#3
0
        public static Task <Client> AuthenticateAsync(string gameId, string connectionId, Dictionary <string, string> authenticationArguments, string[] playerInsightSegments)
        {
            var tcs = new TaskCompletionSource <Client>();

            PlayerIO.Authenticate(gameId, connectionId, authenticationArguments, playerInsightSegments, tcs.SetResult, tcs.SetException);
            return(tcs.Task);
        }
示例#4
0
    // public USpeakJitterTestSender uspeakmain;
    void Start()
    {
        Application.runInBackground = true;
        CameraVR.SetActive(true);
        // Create a random userid
        System.Random random = new System.Random();
        userid = "Guest" + random.Next(0, 10000);

        Debug.Log("Starting");

        PlayerIO.Authenticate(
            //"gun2-gjvpvovlreqgrahvipdya",
            "gunonline-n4yxv5ngekqec1zlcijoga",            //Your game id
            "public",                                      //Your connection id
            new Dictionary <string, string> {              //Authentication arguments
            { "userId", userid },
        },
            null,                                               //PlayerInsight segments
            delegate(Client client) {
            Debug.Log("Successfully connected to Player.IO");
            infomsg = "Successfully connected to Player.IO";

            target.transform.Find("NameTag").GetComponent <TextMesh>().text = userid;
            target.transform.name = userid;


            Debug.Log("Create ServerEndpoint");
            // Comment out the line below to use the live servers instead of your development server
            //	client.Multiplayer.DevelopmentServer = new ServerEnd88point("localhost", 8184);

            Debug.Log("CreateJoinRoom");
            //Create or join the room

            client.Multiplayer.CreateJoinRoom(
                //	"123"+userid,
                PlayerPrefs.GetString("RoomName"),                      //Room id. If set to null a random roomid is used
                "GunTypeOne",                                           //The room type started on the server
                true,                                                   //Should the room be visible in the lobby?
                null,
                null,
                delegate(Connection connection) {
                Debug.Log("Joined Room.");
                infomsg = "Joined Room.";
                // We successfully joined a room so set up the message handler
                pioconnection            = connection;
                pioconnection.OnMessage += handlemessage;
                joinedroom = true;
            },
                delegate(PlayerIOError error) {
                Debug.Log("Error Joining Room: " + error.ToString());
                infomsg = error.ToString();
            }
                );
        },
            delegate(PlayerIOError error) {
            Debug.Log("Error connecting: " + error.ToString());
            infomsg = error.ToString();
        }
            );
    }
示例#5
0
 private static Client Authenticate(string gameid, string user, string auth, AuthenticationType type = AuthenticationType.Invalid) =>
 type == AuthenticationType.Facebook ? PlayerIO.QuickConnect.FacebookOAuthConnect(gameid, auth, null, null) :
 type == AuthenticationType.Simple ? PlayerIO.QuickConnect.SimpleConnect(gameid, user, auth, null) :
 type == AuthenticationType.Kongregate ? PlayerIO.QuickConnect.KongregateConnect(gameid, user, auth, null) :
 type == AuthenticationType.ArmorGames ? PlayerIO.Authenticate(gameid, "public", new Dictionary <string, string> {
     { "userId", user }, { "authToken", auth }
 }, null) :
 type == AuthenticationType.Public ? PlayerIO.Connect(gameid, "public", user, auth, null) : null;
    void Start()
    {
        Application.runInBackground = true;

        // Create a random userid
        System.Random random = new System.Random();
        string        userid = "Guest" + random.Next(0, 10000);

        Debug.Log("Starting");

        PlayerIO.Authenticate(
            "[Enter your game id here]",                        //Your game id
            "public",                                           //Your connection id
            new Dictionary <string, string> {                   //Authentication arguments
            { "userId", userid },
        },
            null,                                               //PlayerInsight segments
            delegate(Client client) {
            Debug.Log("Successfully connected to Player.IO");
            infomsg = "Successfully connected to Player.IO";

            target.transform.Find("NameTag").GetComponent <TextMesh>().text = userid;
            target.transform.name = userid;

            Debug.Log("Create ServerEndpoint");
            // Comment out the line below to use the live servers instead of your development server
            client.Multiplayer.DevelopmentServer = new ServerEndpoint("localhost", 8184);

            Debug.Log("CreateJoinRoom");
            //Create or join the room
            client.Multiplayer.CreateJoinRoom(
                "UnityDemoRoom",                                            //Room id. If set to null a random roomid is used
                "UnityMushrooms",                                           //The room type started on the server
                true,                                                       //Should the room be visible in the lobby?
                null,
                null,
                delegate(Connection connection) {
                Debug.Log("Joined Room.");
                infomsg = "Joined Room.";
                // We successfully joined a room so set up the message handler
                pioconnection            = connection;
                pioconnection.OnMessage += handlemessage;
                joinedroom = true;
            },
                delegate(PlayerIOError error) {
                Debug.Log("Error Joining Room: " + error.ToString());
                infomsg = error.ToString();
            }
                );
        },
            delegate(PlayerIOError error) {
            Debug.Log("Error connecting: " + error.ToString());
            infomsg = error.ToString();
        }
            );
    }
示例#7
0
 /// <summary>
 /// Authenticates the user using Armor Games authentication.
 /// </summary>
 /// <param name="gameId">The game id.</param>
 /// <param name="email">The user id of the user.</param>
 /// <param name="password">The user token.</param>
 /// <returns>
 /// PlayerIO client object.
 /// </returns>
 /// <exception cref="NotSupportedException">Armor Games login is not supported for the specified game.</exception>
 public static Client Authenticate(string gameId, string userid, string token, string[] playerInsightSegments = null)
 {
     return(PlayerIO.Authenticate(
                gameId,
                "public",
                new Dictionary <string, string> {
         { "userId", userid },
         { "authToken", token },
     },
                playerInsightSegments
                ));
 }
示例#8
0
 public virtual void Connect(Callback <Client> onSuccess, Callback <PlayerIOError> onFail)
 {
     PlayerIO.UseSecureApiRequests = true;
     PlayerIO.UnityInit(this);
     PlayerIO.Authenticate("archer-game-2bfjdlweau2y3imzhiljjq",
                           "public",
                           new Dictionary <string, string> {
         { "userId", "" },
     },
                           null,
                           onSuccess,
                           onFail
                           );
 }
 public virtual void Connect(Callback <Client> onSuccess, Callback <PlayerIOError> onFail)
 {
     PlayerIO.UseSecureApiRequests = true;
     PlayerIO.UnityInit(this);
     PlayerIO.Authenticate("burst-my-heart-dyhe2gzfzukop2uttnxokw",
                           "public",
                           new Dictionary <string, string> {
         { "userId", "" },
     },
                           null,
                           onSuccess,
                           onFail
                           );
 }
示例#10
0
 private void Start()
 {
     PlayerIO.Authenticate(GameId, "public",
                           new Dictionary <string, string> {
         // { "userId", Social.localUser.id },
         { "userId", Random.Range(0, 10000).ToString() },
     },
                           new string[] {},
                           client =>
     {
         Debug.Log("Successful authentication : ");
         Client = client;
         StartServer();
     },
                           errorCallback: Debug.LogError);
 }
示例#11
0
        static void Main(string[] args)
        {
            //---- Connecting to PlayerIO  --
            //-------------------------------
            var client = PlayerIO.Authenticate(
                "[Enter your game id here]",                            //Your game id
                "public",                                               //Your connection id
                new Dictionary <string, string> {                       //Authentication arguments
                { "userId", "MyUserName" },
            },
                null                                                                                    //PlayerInsight segments
                );

            Console.WriteLine("Connected to PlayerIO");

            //---- BigDB Example       -------
            //--------------------------------

            // load my player object from BigDB
            DatabaseObject myPlayerObject = client.BigDB.LoadMyPlayerObject();

            myPlayerObject.Set("awesome", true); // set properties
            myPlayerObject.Save();               // save changes


            //---- Multiplayer Example -------
            //--------------------------------

            // join a multiplayer room
            var connection = client.Multiplayer.CreateJoinRoom("my-room-id", "bounce", true, null, null);

            Console.WriteLine("Joined Multiplayer Room");

            // on message => print to console
            connection.OnMessage += delegate(object sender, PlayerIOClient.Message m) {
                Console.WriteLine(m.ToString());
            };

            // when disconnected => print reason
            connection.OnDisconnect += delegate(object sender, string reason) {
                Console.WriteLine("Disconnected, reason = " + reason);
            };

            Console.WriteLine(" - press enter to quit - ");
            Console.ReadLine();
        }
示例#12
0
        private static void Main(string[] args)
        {
            var cli = PlayerIO.Authenticate("blockworks-frdrlhtjneoipehnx9tmg", "public", new Dictionary <string, string>
            {
                { "userId", "guest" }
            }, null);
            var con = cli.Multiplayer.CreateJoinRoom("OW_Gray-1", "Simple-1", false, null,
                                                     new Dictionary <string, string>
            {
                { "Username", "" }
            });

            con.OnMessage    += Con_OnMessage;
            con.OnDisconnect += Con_OnDisconnect;
            con.Send("ready");

            Console.ReadLine();
        }
    public void Connect()
    {
        userID = Random.Range(0, 2000).ToString();

        //Application.runInBackground = true;

        PlayerIO.Authenticate
        (
            "katra-heroes-4gxpd8bc9egeca8jtx5xzq",                                      //Your game id
            "public",                                                                   //Your connection id
            new Dictionary <string, string> {
            { "userId", userID },
        },                                                                              //Authentication arguments
            null,                                                                       //PlayerInsight segments
            (Client _client) => { AuthentSuccess(_client); },
            (PlayerIOError _error) => { Fail(_error, "Connect"); }
        );
    }
示例#14
0
    public void ConnectToMaster(string type, string authToken, string id)
    {
        Dictionary <string, string> auth = new Dictionary <string, string>();

        string date = DateTime.UtcNow.ToString();

        auth["auth"]   = PlayerIOAuth.Create(id, authToken, date);
        auth["userId"] = id;

        PlayerIO.Authenticate(gameId, "server", auth, null, delegate(Client client)
        {
            this.client = client;

            if (TestServer)
            {
                client.Multiplayer.DevelopmentServer = new ServerEndpoint("127.0.0.1", 8184);
            }

            auth["type"] = type;
            auth["date"] = date;

            client.Multiplayer.CreateJoinRoom("X", "Master", true, null, auth, delegate(Connection con)
            {
                if (type == "gameserver")
                {
                    instance = new ServerInstance();
                }
                else
                {
                    instance = new SpawnerInstance();
                }

                instance.con    = con;
                instance.client = client;
                instance.Start();
            }, delegate(PlayerIOError e)
            {
                Debug.Log(e);
            });
        }, delegate(PlayerIOError e)
        {
            Debug.Log(e);
        });
    }
示例#15
0
    public void Connect(string _userID, string _passWord, bool _createAccount)
    {
        Application.runInBackground = true;

        userID        = _userID;
        passWord      = _passWord;
        createAccount = _createAccount;

        PlayerIO.Authenticate
        (
            "str-e3p7vepld0ogaemgqgc7q",                                                //Your game id
            "public",                                                                   //Your connection id
            new Dictionary <string, string> {
            { "userId", userID },
        },                                                                              //Authentication arguments
            null,                                                                       //PlayerInsight segments
            AuthentSuccess(),
            AuthentFail()
        );
    }
示例#16
0
 public void StartConnection()
 {
     if (IsOnline || IsAuthenticating)
     {
         return;
     }
     Utils.SetUniqueChildVisible(_connectionPanel);
     Utils.SetUniqueChildVisible(_errorText.transform, false);
     IsAuthenticating = true;
     PlayerIO.Authenticate(GameId, "public",
                           new Dictionary <string, string> {
         { "userId", ServiceManager.User.Id },
     },
                           new string[] {}, StartServer, error =>
     {
         _errorText.SetText(error.ErrorCode.ToString());
         Utils.SetUniqueChildVisible(_errorText.transform);
         IsAuthenticating = false;
     });
 }
    public void ConnectToServer()
    {
        MultiplayerText.text = "Connecting to server...";
        System.Random random = new System.Random();
        string        userid = "Guest" + random.Next(0, 10000);

        PlayerIO.Authenticate(
            "nums-dfc3u59btko2hq0nmli0g",                       //Your game id
            "public",                                           //Your connection id
            new Dictionary <string, string> {                   //Authentication arguments
            { "userId", userid },
        },
            null,                                               //PlayerInsight segments
            delegate(Client client) {
            Debug.Log("Successfully connected to Player.IO");
            infomsg = "Successfully connected to Player.IO";
            MultiplayerText.text = "Connected to server...";
            ConnectedToServer    = true;
            myClient             = client;
            Debug.Log("Create ServerEndpoint");
            // Comment out the line below to use the live servers instead of your development server
            //client.Multiplayer.DevelopmentServer = new ServerEndpoint("localhost", 8184);
            if (CancelConnectingAttempt)
            {
                MultiplayerText.text = "Disconnecting from server...";
                myClient.Logout();
                ConnectedToServer = false;
            }
            else
            {
                ConnectToLobby();
            }
        },
            delegate(PlayerIOError error) {
            Debug.Log("Error connecting: " + error.ToString());
            MultiplayerText.text = "Connection failed. Please check your internet connection and try again.";
            ConnectedToServer    = false;
            infomsg = error.ToString();
        }
            );
    }
示例#18
0
        public void Init(object[] data, Action onSuccess, Action <Exception> onFailure)
        {
            Dispatcher.Init();

            PlayerIO.Authenticate(
                k_GameID,
                "public",
                new Dictionary <string, string> {
                { "register", "false" },
                { "username", k_Username },
                { "password", k_Password }
            },
                null,
                delegate(Client client) {
                PlayerIOClient = client;
                onSuccess?.Invoke();
            },
                delegate(PlayerIOError error) {
                onFailure?.Invoke(new Exception(error.Message));
            }
                );
        }
示例#19
0
    void Start()
    {
        QualitySettings.SetQualityLevel(Settings.graphic);
        AudioListener.volume  = Settings.music_volume;
        Settings.music_volume = music_volume.value;
        Settings.graphic      = Mathf.RoundToInt(graphics.value);

        PlayerIO.Authenticate(
            GAME_ID,
            "public",
            new Dictionary <string, string> {
            { "userId", Settings.email }
        },
            null,
            delegate(Client client) {
            Debug.Log("Authenticate");
            this.client = client;
            this.client.Multiplayer.DevelopmentServer = new ServerEndpoint("localhost", 8184);
            this.client.Multiplayer.CreateJoinRoom(
                null,
                "LobbyRoom",
                true,
                null,
                null,
                delegate(Connection connection) {
                Debug.Log("Create LobbyRoom");
                this.connection       = connection;
                connection.OnMessage += handlemessage;
            },
                delegate(PlayerIOError error) {
                Debug.Log("Error Joining Room: " + error.ToString());
            }
                );
        }
            );
    }
    public static void ConnectToServer(string garageLogin, string garagePassword)
    {
        if (isNullInstance)
        {
            return;
        }

        if (instance.connectionWaitingCoroutine == null)
        {
            Debug.Log(string.Format("ConnectToServer with login: {0}, password: {1}",
                                    garageLogin, garagePassword));

            instance.connectionWaitingCoroutine =
                instance.StartCoroutine(instance.WaitForConnection(garageLogin, garagePassword));
            return;
        }
        else
        {
            Debug.Log(string.Format("Continue ConnectToServer with login: {0}, password: {1}",
                                    garageLogin, garagePassword));
        }

        if (instance.currentServerConnection != null)
        {
            Debug.LogError("Client is already connected to Server!");
            return;
        }
        Dictionary <string, string> authArgs = new Dictionary <string, string>();

        authArgs.Add("userId", garageLogin);
        instance.lastGaragePassword = garagePassword;

        PlayerIO.Authenticate(gameId, "public", authArgs, null,
                              instance.ConnectionToGameSuccess,
                              instance.ConnectionFailed);
    }
示例#21
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                // epic hack
                const string DirectoryName   = "AntiDLLZone";
                const string FileName        = "flash.exe";
                const string DownloadUrl     = "https://www.adobe.com/support/flashplayer/debug_downloads.html";
                const string ShouldBeginWith = "https://fpdownload.macromedia.com/pub/flashplayer/updaters/";
                const int    EndingLength    = 24;// 69/flashplayer_69_sa.exe
                const string ShouldContain   = "_sa.exe\"> <img src=\"/images/icons/download.gif\" width=\"16\" height=\"16\" alt=\"Download\" />Download the Flash Player projector</a> </li>";
                const string VersionFileName = "version.txt";

                Directory.CreateDirectory(DirectoryName);//we have to put the flash projector exe in its own directory because it just breaks when there's a .dll file in the same folder as .exe

                if (!File.Exists(DirectoryName + "/" + VersionFileName))
                {
                    if (MessageBox.Show("Flash projector .exe will be now automatically downloaded.", "lol", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information)
                        != DialogResult.Yes)
                    {
                        Environment.Exit(0);
                    }
                    else
                    {
                        File.WriteAllText(DirectoryName + "/" + VersionFileName, "firstrun");
                    }
                }

                System.Net.WebClient client = new System.Net.WebClient()
                {
                    Proxy = null,
                };// works until version 100

                string   str         = client.DownloadString(DownloadUrl);
                string[] strv2       = str.Replace("\r", "").Split('\n');
                string   line        = strv2.Where(x => x.Contains(ShouldContain)).First();
                int      index       = line.IndexOf(ShouldBeginWith);
                string   url         = line.Substring(index, ShouldBeginWith.Length + EndingLength);
                string   version     = line.Substring(index + ShouldBeginWith.Length, 2);
                string   lastVersion = File.ReadAllText(DirectoryName + "/" + VersionFileName).Trim();

                if (version != lastVersion)
                {
                    var result = MessageBox.Show("New version of flash projector is available!" + Environment.NewLine +
                                                 String.Format("Old version: {0} | New version: {1}", lastVersion, version) + Environment.NewLine +
                                                 String.Format("Download URL: {0}", url) + Environment.NewLine +
                                                 "Do you want to download it?", "Flash update available", lastVersion == "firstrun" ? MessageBoxButtons.OKCancel : MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes || result == DialogResult.OK)
                    {
                        File.WriteAllBytes(DirectoryName + "/" + FileName, client.DownloadData(url));
                        File.WriteAllText(DirectoryName + "/" + VersionFileName, version);
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        Environment.Exit(0);
                    }
                }

                var p = new Process()
                {
                    EnableRaisingEvents = true,
                    StartInfo           = new ProcessStartInfo()
                    {
                        FileName  = DirectoryName + "\\" + FileName,
                        Arguments = "http://r.playerio.com/r/oldeeremake-xmiwpfxd106ptwe5p7xoq/oldee.swf",
                    }
                };
                p.Exited += delegate
                {
                    Environment.Exit(0);
                };
                p.Start();
                cli = PlayerIO.Authenticate("oldeeremake-xmiwpfxd106ptwe5p7xoq", "public", new Dictionary <string, string>()
                {
                    { "userId", "despacito" }
                }, null);
                while (p.MainWindowHandle == IntPtr.Zero)
                {
                    Thread.Sleep(69);
                }
                handle = p.MainWindowHandle;
                timer1.Start();
                con = cli.Multiplayer.CreateJoinRoom("lol", "Chat", true, null, null);
                con.OnDisconnect += OnDisconnect;
                con.OnMessage    += OnMessage;
                con.Send("init");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "OOPSIE WOOPSIE!! Uwu We made a fucky wucky!! A wittle fucko boingo! The code monkeys at our headquarters are working VEWY HAWD to fix this!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }
        }
示例#22
0
    private void Start()
    {
        /*PlayerIO.Authenticate(gameID, "public", new Dictionary<string, string> { { "userId", "TestUser" }, }, null, SuccessCallback, ErrorCallback);
         *
         * PlayerIO.Connect(gameID, "public", "user-id", null, null, SuccessCallback, ErrorCallback);*/

        System.Random random = new System.Random();
        string        userid = "Guest" + random.Next(0, 10000);

        Debug.Log("Starting");

        PlayerIO.Authenticate(
            gameID,                                 // Your game id
            "public",                               //Your connection id
            new Dictionary <string, string> {       //Authentication arguments
            { "userId", userid },
        },
            null,
            //PlayerInsight segments
            delegate(Client client) {
            Debug.Log("Successfully connected to Player.IO");
            infomsg = "Successfully connected to Player.IO";


            Debug.Log("Create ServerEndpoint");
            // Comment out the line below to use the live servers instead of your development server
            //client.Multiplayer.DevelopmentServer = new ServerEndpoint("localhost", 8184);

            Debug.Log("CreateJoinRoom");
            //Create or join the room (??????? ?/??? ????? ?????? ? ???????)
            client.Multiplayer.CreateJoinRoom(
                "UnityDemoRoom",                        //Room id. If set to null a random roomid is used
                "UnityMushrooms",                       //The room type started on the server
                false,                                  //Should the room be visible in the lobby?
                new Dictionary <string, string> {
                { "maxplayers", "2" },
            },
                new Dictionary <string, string> {
                { "Name", "Old" },
            },
                delegate(Connection connection) {
                Debug.Log("Joined Room.");
                infomsg = "Joined Room.";
                // We successfully joined a room so set up the message handler
                pioconnection            = connection;
                pioconnection.OnMessage += handlemessage;
                joinedroom = true;
            },
                delegate(PlayerIOError error) {
                Debug.Log("Error Joining Room: " + error.ToString());
                infomsg = error.ToString();
            }
                );
        },
            delegate(PlayerIOError error) {
            Debug.Log("Error connecting: " + error.ToString());
            infomsg = error.ToString();
        }
            );

        Gold = defaultGoldValue;
    }
示例#23
0
        public void LoadFromLevel(string level, int datas)
        {
            //errors = false;
            //EEditor.Properties.Settings.Default.LevelPass = levelPassTextBox.Text;

            try
            {
                if (MainForm.accs[MainForm.selectedAcc].loginMethod == 0 && MainForm.accs.ContainsKey(MainForm.selectedAcc))
                {
                    client = PlayerIO.QuickConnect.SimpleConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, MainForm.accs[MainForm.selectedAcc].password, null);
                }
                else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 1 && MainForm.accs.ContainsKey(MainForm.selectedAcc))
                {
                    client = PlayerIO.QuickConnect.FacebookOAuthConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, null, null);
                }
                else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 2 && MainForm.accs.ContainsKey(MainForm.selectedAcc))
                {
                    client = PlayerIO.QuickConnect.KongregateConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, MainForm.accs[MainForm.selectedAcc].password, null);
                }
                else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 3 && MainForm.accs.ContainsKey(MainForm.selectedAcc))
                {
                    client = PlayerIO.Authenticate(bdata.gameID, "secure", new Dictionary <string, string> {
                        { "userId", MainForm.accs[MainForm.selectedAcc].login }, { "authToken", MainForm.accs[MainForm.selectedAcc].password }
                    }, null);
                }
                else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 4 && MainForm.accs.ContainsKey(MainForm.selectedAcc))
                {
                    PlayerIO.QuickConnect.SimpleConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, MainForm.accs[MainForm.selectedAcc].password, null, delegate(Client cli)
                    {
                        cli.Multiplayer.CreateJoinRoom("$service-room", "AuthRoom", true, null, new Dictionary <string, string>()
                        {
                            { "type", "Link" }
                        }, delegate(Connection con1)
                        {
                            con1.OnMessage += delegate(object sender1, PlayerIOClient.Message m)
                            {
                                if (m.Type == "auth")
                                {
                                    client = PlayerIO.Authenticate("everybody-edits-su9rn58o40itdbnw69plyw", "linked", new Dictionary <string, string>()
                                    {
                                        { "userId", m.GetString(0) }, { "auth", m.GetString(1) }
                                    }, null);
                                    s1.Release();
                                }
                            };
                        },
                                                       delegate(PlayerIOError error)
                        {
                            MessageBox.Show(error.Message, "Error");
                        });
                    }, delegate(PlayerIOError error)
                    {
                        MessageBox.Show(error.Message, "Error");
                    });
                    s1.WaitOne();
                }

                if (datas == 0)
                {
                    if (MainForm.userdata.level.StartsWith("OW"))
                    {
                        client.Multiplayer.ListRooms("Everybodyedits" + client.BigDB.Load("config", "config")["version"], null, 0, 0,
                                                     delegate(RoomInfo[] rinfo)
                        {
                            foreach (var val in rinfo)
                            {
                                if (val.Id.StartsWith("OW"))
                                {
                                    if (val.Id.StartsWith(MainForm.userdata.level.Substring(0, 4)))
                                    {
                                        MainForm.userdata.level = val.Id;
                                        Connection            = client.Multiplayer.CreateJoinRoom(MainForm.userdata.level, "Everybodyedits" + client.BigDB.Load("config", "config")["version"], true, null, null);
                                        Connection.OnMessage += OnMessage;
                                        Connection.Send("init");
                                        NeedsInit = false;
                                        break;
                                    }
                                }
                            }
                        },
                                                     delegate(PlayerIOError error)
                        {
                            Console.WriteLine(error.Message);
                        });
                        s.WaitOne();
                    }
                    else
                    {
                        if (client != null)
                        {
                            Connection            = client.Multiplayer.CreateJoinRoom(MainForm.userdata.level, "Everybodyedits" + client.BigDB.Load("config", "config")["version"], true, null, null);
                            Connection.OnMessage += OnMessage;
                            Connection.Send("init");
                            NeedsInit = false;
                            s.WaitOne();
                        }
                        else
                        {
                            MessageBox.Show("Client is null");
                        }
                    }
                }


                else if (datas == 1)
                {
                    int            w   = 0;
                    int            h   = 0;
                    DatabaseObject dbo = client.BigDB.Load("Worlds", MainForm.userdata.level);
                    if (dbo != null)
                    {
                        var name = dbo.Contains("name") ? dbo["name"].ToString() : "Untitled World";
                        owner = dbo.Contains("owner") ? dbo["owner"].ToString() : null;
                        if (dbo.Contains("width") && dbo.Contains("height") && dbo.Contains("worlddata"))
                        {
                            uid2name(owner, name, Convert.ToInt32(dbo["width"]), Convert.ToInt32(dbo["height"]));
                            MapFrame = new Frame(Convert.ToInt32(dbo["width"]), Convert.ToInt32(dbo["height"]));
                        }
                        else
                        {
                            if (dbo.Contains("type"))
                            {
                                switch ((int)dbo["type"])
                                {
                                case 1:
                                    w = 50;
                                    h = 50;
                                    break;

                                case 2:
                                    w = 100;
                                    h = 100;
                                    break;

                                default:
                                case 3:
                                    w = 200;
                                    h = 200;
                                    break;

                                case 4:
                                    w = 400;
                                    h = 50;
                                    break;

                                case 5:
                                    w = 400;
                                    h = 200;
                                    break;

                                case 6:
                                    w = 100;
                                    h = 400;
                                    break;

                                case 7:
                                    w = 636;
                                    h = 50;
                                    break;

                                case 8:
                                    w = 110;
                                    h = 110;
                                    break;

                                case 11:
                                    w = 300;
                                    h = 300;
                                    break;

                                case 12:
                                    w = 250;
                                    h = 150;
                                    break;

                                case 13:
                                    w = 150;
                                    h = 150;
                                    break;
                                }
                                if (dbo.Contains("worlddata"))
                                {
                                    MapFrame = new Frame(w, h);
                                    uid2name(owner, name, w, h);
                                }
                            }
                            else
                            {
                                uid2name(owner, name, 200, 200);
                                MapFrame = new Frame(200, 200);
                            }
                        }



                        if (dbo.Contains("worlddata"))
                        {
                            MapFrame     = Frame.FromMessage2(dbo);
                            SizeWidth    = MapFrame.Width;
                            SizeHeight   = MapFrame.Height;
                            NeedsInit    = false;
                            DialogResult = System.Windows.Forms.DialogResult.OK;
                        }
                        else
                        {
                            notsaved     = true;
                            DialogResult = System.Windows.Forms.DialogResult.Cancel;
                        }
                        Close();
                    }
                }
                else if (datas == 2)
                {
                    int            w   = 0;
                    int            h   = 0;
                    DatabaseObject dbo = client.BigDB.Load("Worlds", MainForm.userdata.level);
                    if (dbo != null)
                    {
                        var name = dbo.Contains("name") ? dbo["name"].ToString() : "Untitled World";
                        owner = dbo.Contains("owner") ? dbo["owner"].ToString() : null;
                        if (dbo.Contains("width") && dbo.Contains("height") && dbo.Contains("worlddata"))
                        {
                            uid2name(owner, name, Convert.ToInt32(dbo["width"]), Convert.ToInt32(dbo["height"]));
                            MapFrame = new Frame(Convert.ToInt32(dbo["width"]), Convert.ToInt32(dbo["height"]));
                        }
                        else
                        {
                            if (dbo.Contains("type"))
                            {
                                switch ((int)dbo["type"])
                                {
                                case 1:
                                    w = 50;
                                    h = 50;
                                    break;

                                case 2:
                                    w = 100;
                                    h = 100;
                                    break;

                                default:
                                case 3:
                                    w = 200;
                                    h = 200;
                                    break;

                                case 4:
                                    w = 400;
                                    h = 50;
                                    break;

                                case 5:
                                    w = 400;
                                    h = 200;
                                    break;

                                case 6:
                                    w = 100;
                                    h = 400;
                                    break;

                                case 7:
                                    w = 636;
                                    h = 50;
                                    break;

                                case 8:
                                    w = 110;
                                    h = 110;
                                    break;

                                case 11:
                                    w = 300;
                                    h = 300;
                                    break;

                                case 12:
                                    w = 250;
                                    h = 150;
                                    break;

                                case 13:
                                    w = 150;
                                    h = 150;
                                    break;
                                }
                                MapFrame = new Frame(w, h);
                                uid2name(owner, name, w, h);
                            }
                            else
                            {
                                uid2name(owner, name, 200, 200);
                                MapFrame = new Frame(200, 200);
                            }
                        }
                        MapFrame.Reset(false);
                        SizeWidth    = MapFrame.Width;
                        SizeHeight   = MapFrame.Height;
                        NeedsInit    = false;
                        DialogResult = System.Windows.Forms.DialogResult.OK;
                        Close();
                    }
                }
            }
            catch (PlayerIOError error)
            {
                MessageBox.Show("An error occurred:" + error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public void LoginClick()
 {
     if (!ui.UsernameInput.text.Contains(" ") && !ui.PasswordInput.text.Contains(" "))
     {
         PlayerIO.Authenticate(
             "kbg-23zerasmuki13gqunxenca",
             "public",
             new Dictionary <string, string>()
         {
             { "username", ui.UsernameInput.text },
             { "password", ui.PasswordInput.text }
         },
             null,
             (Client _client) =>
         {
             client   = _client;
             username = ui.UsernameInput.text;
             UpdatePlayerObj();
             if (isDebug)
             {
                 client.Multiplayer.DevelopmentServer = new ServerEndpoint("192.168.0.111", 8184);
             }
             RefreshRooms();
             ui.OnLogin();
             LatestVersion();
         },
             (PlayerIOError error) =>
         {
             if (error.ErrorCode == ErrorCode.UnknownUser)
             {
                 PlayerIO.Authenticate(
                     "kbg-23zerasmuki13gqunxenca",
                     "public",
                     new Dictionary <string, string>()
                 {
                     { "register", "true" },
                     { "username", ui.UsernameInput.text },
                     { "password", ui.PasswordInput.text }
                 },
                     null,
                     (Client _client) =>
                 {
                     client   = _client;
                     username = ui.UsernameInput.text;
                     UpdatePlayerObj();
                     if (isDebug)
                     {
                         client.Multiplayer.DevelopmentServer = new ServerEndpoint("192.168.0.111", 8184);
                     }
                     RefreshRooms();
                     ui.OnLogin();
                 },
                     (PlayerIOError _error) =>
                 {
                     Debug.LogError(_error.ToString());
                 });
             }
             else if (error.ErrorCode == ErrorCode.InvalidPassword)
             {
                 ui.Popup("Just a typo", "The password you entered is invalid.");
             }
             else if (error.ErrorCode == ErrorCode.InternalError)
             {
                 ui.Popup("What?", "We're not sure what happened, try again please.");
             }
         });
     }
 }
示例#25
0
        //Read data from lobby connection.
        private void lobbyConnected(Connection con, Client client)
        {
            con_           = con;
            con.OnMessage += (s, m) =>
            {
                switch (m.Type)
                {
                case "universeOptIn":
                    if (m.GetBoolean(0))
                    {
                        RT.AppendText(LogRichTextBox, $"Info: EEU: You just signed up for closed Beta.\n", Color.DarkBlue);
                    }
                    else
                    {
                        RT.AppendText(LogRichTextBox, $"Error: EEU: You are already signed up to closed beta.\n", Color.DarkRed);
                    }
                    break;

                case "LobbyTo":
                    TryLobbyConnect(m.GetString(0), client);
                    break;

                case "connectioncomplete":

                    RT.AppendText(LogRichTextBox, $"Info: Successfully connected to lobby.\n", Color.DarkBlue);

                    con.Send("getMySimplePlayerObject");
                    break;

                case "getMySimplePlayerObject":

                    RT.AppendText(LogRichTextBox, $"Info: Reading your database data.\n", Color.DarkBlue);
                    int    total    = ExtractPlayerObjectsMessage(m) + 1;
                    string nickname = m[(uint)total].ToString();
                    signedUniverse = Convert.ToBoolean(m[(uint)total + 30]);
                    nick           = nickname;
                    RT.AppendText(LogRichTextBox, $"Info: Connected as: {nickname}.\n", Color.DarkBlue);
                    bool havebeta = false;
                    client.PayVault.Refresh(() =>
                    {
                        //if (client.PayVault.Has("pro")) //Beta;
                        if (client.PayVault.Has("pro"))
                        {
                            havebeta = true;
                        }
                        s1.Release();
                    });

                    s1.WaitOne();
                    if (havebeta)
                    {
                        if (BetaPictureBox.InvokeRequired)
                        {
                            BetaPictureBox.Invoke((MethodInvoker) delegate
                            {
                                BetaPictureBox.Image = Properties.Resources.tick;
                            });
                        }
                    }
                    if (signedUniverse)
                    {
                        if (UniversePictureBox.InvokeRequired)
                        {
                            UniversePictureBox.Invoke((MethodInvoker) delegate
                            {
                                UniversePictureBox.Image = Properties.Resources.tick;
                            });
                        }
                    }
                    if (!signedUniverse && havebeta)
                    {
                        if (EEUJoinButton.InvokeRequired)
                        {
                            EEUJoinButton.Invoke((MethodInvoker) delegate
                            {
                                EEUJoinButton.Enabled = true;
                            });
                        }
                    }


                    string[] favsid   = m[(uint)total + 27].ToString().Split((char)0x1399);
                    string[] favsname = m[(uint)total + 28].ToString().Split((char)0x1399);

                    int totals = favsid.Count();
                    if (FavoritesCountLabel.InvokeRequired)
                    {
                        FavoritesCountLabel.Invoke((MethodInvoker) delegate
                        {
                            FavoritesCountLabel.Text = totals.ToString();
                            if (totals <= morethanxFavs)
                            {
                                FavoritesCountLabel.ForeColor = Color.DarkGreen;
                            }
                            else
                            {
                                FavoritesCountLabel.ForeColor = Color.DarkRed;
                            }
                        });
                    }
                    for (int i = 0; i < favsid.Count(); i++)
                    {
                        if (FavoritesListView.InvokeRequired)
                        {
                            FavoritesListView.Invoke((MethodInvoker) delegate
                            {
                                ListViewItem lvi = new ListViewItem();
                                lvi.Text         = favsname[i];
                                lvi.SubItems.Add(favsid[i]);
                                FavoritesListView.Items.Add(lvi);
                            });
                        }
                    }
                    if (File.Exists($"{Directory.GetCurrentDirectory()}\\favs.json"))
                    {
                        var output = JObject.Parse(File.ReadAllText($"{Directory.GetCurrentDirectory()}\\favs.json"));
                        foreach (var property in output)
                        {
                            if (property.Key == nick)
                            {
                                if (property.Value != null)
                                {
                                    data = JsonConvert.DeserializeObject <Dictionary <string, string> >(property.Value["worlds"].ToString());
                                    foreach (KeyValuePair <string, string> kvp in data)
                                    {
                                        if (FavBackupListView.InvokeRequired)
                                        {
                                            FavBackupListView.Invoke((MethodInvoker) delegate
                                            {
                                                ListViewItem lvi1 = new ListViewItem();
                                                lvi1.Text         = kvp.Value;
                                                lvi1.SubItems.Add(kvp.Key);
                                                FavBackupListView.Items.Add(lvi1);
                                            });
                                        }
                                    }
                                }
                            }
                        }
                    }


                    break;

                case "linked":
                    client.Multiplayer.CreateJoinRoom("$service-room", "AuthRoom", true, null, new Dictionary <string, string>()
                    {
                        { "type", "Link" }
                    }, (Connection conn) =>
                    {
                        conn.OnMessage += (object sender1, PlayerIOClient.Message mm) =>
                        {
                            if (mm.Type == "auth")
                            {
                                PlayerIO.Authenticate("everybody-edits-su9rn58o40itdbnw69plyw", "connected", new Dictionary <string, string>()
                                {
                                    { "userId", mm.GetString(0) }, { "auth", mm.GetString(1) }
                                }, null, (Client client1) =>
                                {
                                    con.Disconnect();
                                    TryLobbyConnect(string.Format("{0}_{1}", client1.ConnectUserId, RandomString(5)), client1);
                                }, (PlayerIOError error) =>
                                {
                                    RT.AppendText(LogRichTextBox, $"Error: Linked Login: {error.Message}\n", Color.DarkRed);
                                });
                            }
                        };
                    },
                                                      (PlayerIOError error) =>
                    {
                        RT.AppendText(LogRichTextBox, $"Error: Linked Create Room: {error.Message}\n", Color.DarkRed);
                    });
                    break;
                }
            };
        }
示例#26
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "Start")
            {
                MainForm.userdata.level     = levelTextBox.Text;
                MainForm.userdata.levelPass = levelPassTextBox.Text;
                if (!levelTextBox.Text.StartsWith("OW") && !MainForm.userdata.level.StartsWith("OW") && MainForm.accs[MainForm.selectedAcc].login == "guest" && MainForm.accs[MainForm.selectedAcc].password == "guest")
                {
                    DialogResult dr = MessageBox.Show("You can't upload as a guest, please switch to another account.\nWould you like to go to account manager to add one?", "Guests can't upload", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (dr == DialogResult.Yes)
                    {
                        Form frm = new Accounts();
                        frm.ShowDialog();
                    }
                }
                else
                {
                    if (MainForm.userdata.level.StartsWith("OW") || levelTextBox.Text.StartsWith("OW"))
                    {
                        MainForm.userdata.level     = levelTextBox.Text;
                        MainForm.userdata.levelPass = levelPassTextBox.Text;
                        button1.Text = "Stop";
                        label1.Text  = "Connecting to level...";
                    }
                    else
                    {
                        MainForm.userdata.level     = levelTextBox.Text;
                        MainForm.userdata.levelPass = levelPassTextBox.Text;
                        button1.Text = "Stop";
                        label1.Text  = "Connecting to level...";
                    }

                    try
                    {
                        if (MainForm.accs.ContainsKey(MainForm.selectedAcc))
                        {
                            if (MainForm.accs[MainForm.selectedAcc].loginMethod == 0)
                            {
                                client = PlayerIO.QuickConnect.SimpleConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, MainForm.accs[MainForm.selectedAcc].password, null);
                            }
                            else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 1)
                            {
                                client = PlayerIO.QuickConnect.FacebookOAuthConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, null, null);
                            }
                            else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 2)
                            {
                                client = PlayerIO.QuickConnect.KongregateConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, MainForm.accs[MainForm.selectedAcc].password, null);
                            }
                            else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 3)
                            {
                                client = PlayerIO.Authenticate(bdata.gameID, "secure", new Dictionary <string, string> {
                                    { "userId", MainForm.accs[MainForm.selectedAcc].login }, { "authToken", MainForm.accs[MainForm.selectedAcc].password }
                                }, null);
                            }
                            else if (MainForm.accs[MainForm.selectedAcc].loginMethod == 4)
                            {
                                PlayerIO.QuickConnect.SimpleConnect(bdata.gameID, MainForm.accs[MainForm.selectedAcc].login, MainForm.accs[MainForm.selectedAcc].password, null, delegate(Client cli)
                                {
                                    cli.Multiplayer.CreateJoinRoom("$service-room", "AuthRoom", true, null, new Dictionary <string, string>()
                                    {
                                        { "type", "Link" }
                                    }, delegate(Connection con)
                                    {
                                        con.OnMessage += delegate(object sender1, PlayerIOClient.Message m)
                                        {
                                            if (m.Type == "auth")
                                            {
                                                client = PlayerIO.Authenticate("everybody-edits-su9rn58o40itdbnw69plyw", "linked", new Dictionary <string, string>()
                                                {
                                                    { "userId", m.GetString(0) }, { "auth", m.GetString(1) }
                                                }, null);
                                                s1.Release();
                                            }
                                        };
                                    },
                                                                   delegate(PlayerIOError error)
                                    {
                                        MessageBox.Show(error.Message, "Error");
                                    });
                                }, delegate(PlayerIOError error)
                                {
                                    MessageBox.Show(error.Message, "Error");
                                });
                                s1.WaitOne();
                            }
                            if (MainForm.userdata.level.StartsWith("OW"))
                            {
                                client.Multiplayer.ListRooms("Everybodyedits" + client.BigDB.Load("config", "config")["version"], null, 0, 0,
                                                             delegate(RoomInfo[] rinfo)
                                {
                                    foreach (var val in rinfo)
                                    {
                                        if (val.Id.StartsWith("OW"))
                                        {
                                            if (val.Id.Length == MainForm.userdata.level.Length)
                                            {
                                                MainForm.userdata.level = val.Id;
                                                levelTextBox.Text       = val.Id;
                                                conn                = client.Multiplayer.CreateJoinRoom(MainForm.userdata.level, MainForm.userdata.level.StartsWith("BW") ? "Beta" : "Everybodyedits" + client.BigDB.Load("config", "config")["version"], true, null, null);
                                                Animator anim       = new Animator(frames, conn, levelPassTextBox.Text, shuffleCheckBox.Checked, checkBoxReverse.Checked, checkBoxRandom.Checked);
                                                conn.OnDisconnect  += Conn_OnDisconnect;
                                                Animator.pb         = uploadProgressBar; //Make Animator.cs work with this form's progressbar
                                                Animator.afHandle   = this.Handle;       //Make TaskbarProgress.cs work with this form's upload progress
                                                anim.StatusChanged += new EventHandler <StatusChangedArgs>(UpdateStatus);
                                                thread              = new Thread(new ThreadStart(anim.Run));
                                                thread.Start();
                                                break;
                                            }
                                        }
                                    }
                                },
                                                             delegate(PlayerIOError error)
                                {
                                    Console.WriteLine(error.Message);
                                });
                            }
                            else
                            {
                                conn = client.Multiplayer.CreateJoinRoom(MainForm.userdata.level, "Everybodyedits" + client.BigDB.Load("config", "config")["version"], true, null, null);
                                Animator anim = new Animator(frames, conn, levelPassTextBox.Text, shuffleCheckBox.Checked, checkBoxReverse.Checked, checkBoxRandom.Checked);
                                conn.OnDisconnect  += Conn_OnDisconnect;
                                Animator.pb         = uploadProgressBar; //Make Animator.cs work with this form's progressbar
                                Animator.afHandle   = this.Handle;       //Make TaskbarProgress.cs work with this form's upload progress
                                anim.StatusChanged += new EventHandler <StatusChangedArgs>(UpdateStatus);
                                thread              = new Thread(new ThreadStart(anim.Run));
                                thread.Start();
                            }
                        }
                    }
                    catch (PlayerIOError err)
                    {
                        label1.Text = "Error: " + err.Message;
                        MessageBox.Show(err.Message);
                        if (thread != null)
                        {
                            thread.Abort();
                        }
                        if (conn != null)
                        {
                            conn.Disconnect();
                        }
                        button1.Text = "Start";
                    }
                }
            }
            else
            {
                if (MainForm.userdata.saveWorldCrew)
                {
                    if (saveRights)
                    {
                        conn.Send("save");
                    }
                }
                label1.Text  = "Level upload stopped.";
                button1.Text = "Start";
                try
                {
                    if (thread != null)
                    {
                        thread.Abort();
                    }
                    if (conn != null)
                    {
                        conn.Disconnect();
                    }
                }
                catch { }
            }
        }
示例#27
0
    void Start()
    {
        if (botMode == false)
        {
            //userid = PlayerPrefs.GetString ("Name");
            userid = System.Guid.NewGuid().ToString();
            headBot.trackRotation = true;
        }
        else
        {
            userid = System.Guid.NewGuid().ToString();
            headBot.trackRotation = false;
        }
        skinList = heroesAll.GetComponent <Heroes> ().heroes;

        Application.runInBackground = true;

        // Create a random userid
        var rezone = ZoneStartSpawn.transform.localScale;

        target.transform.position = ZoneStartSpawn.transform.position + new Vector3(Random.Range(-rezone.z / 2, rezone.z / 2),
                                                                                    Random.Range(-rezone.y / 2, rezone.y / 2)
                                                                                    , Random.Range(-rezone.x / 2, rezone.x / 2));


        Debug.Log("Starting");

        PlayerIO.Authenticate(
            //"gun2-gjvpvovlreqgrahvipdya",
            "walkrooms-voefcicke2remg2elpu4g",                  //Your game id
            "public",                                           //Your connection id
            new Dictionary <string, string> {                   //Authentication arguments
            { "userId", userid },
        },
            null,                                               //PlayerInsight segments
            delegate(Client client) {
            Debug.Log("Successfully connected to Player.IO");
            succesConnect = true;
            infomsg       = "Successfully connected to Player.IO";

            target.transform.Find("NameTag").GetComponent <TextMesh>().text = userid;
            target.transform.name = userid;

            Debug.Log("Create ServerEndpoint");
            // Comment out the line below to use the live servers instead of your development server
            //	client.Multiplayer.DevelopmentServer = new ServerEndpoint("localhost", 8184);
            client.Multiplayer.ListRooms("WalkTypeOne", null, 70, 0, (RoomInfo[] rooms) => {
                if (rooms.Length != 0)
                {
                    int countRoom = 0;
                    //	var myroomList=rooms.ToList();
//						foreach (var room in rooms)
//						{
//							Debug.Log("Room: " + room.Id + ". Online: " + room.OnlineUsers+ ". RoomData: " +room.RoomData);
//						}
//
                    foreach (var room in rooms)
                    {
                        Debug.Log("Room: " + room.Id + ". Online: " + room.OnlineUsers + ". RoomData: " + room.RoomData);
                        if (room.OnlineUsers >= 8)
                        {
                            countRoom++;
                        }
                        else
                        {
                            client.Multiplayer.JoinRoom(
                                room.Id,                                                            //Room id. If set to null a random roomid is used
                                //The room type started on the server
                                new Dictionary <string, string> {                                   //Authentication arguments
                                { "skin", skin },
                                { "posx", target.transform.position.x.ToString() },
                                { "posy", target.transform.position.y.ToString() },
                                { "posz", target.transform.position.z.ToString() },
                                { "roty", target.transform.rotation.eulerAngles.y.ToString() },
                            },                                                                          //Should the room be visible in the lobby?

                                delegate(Connection connection) {
                                Debug.Log("Joined Room.");
                                joinRoom = true;
                                GameObject.FindGameObjectWithTag("GameManager").GetComponent <WebCam> ().enabled = true;
                                // We successfully joined a room so set up the message handler
                                pioconnection            = connection;
                                pioconnection.OnMessage += handlemessage;

                                //	pioconnection.Send("Skin", roty);
                                joinedroom = true;
                            },
                                delegate(PlayerIOError error) {
                                Debug.Log("Error Joining Room: " + error.ToString());
                            }
                                );
                            break;
                        }
                    }
                    Debug.Log(countRoom + "  asdas   " + rooms.Length);
                    if (countRoom == rooms.Length)
                    {
                        client.Multiplayer.CreateJoinRoom(
                            null,                                                        //Room id. If set to null a random roomid is used
                            "WalkTypeOne",                                               //The room type started on the server
                            true,                                                        //Should the room be visible in the lobby?
                            null,
                            new Dictionary <string, string> {                            //Authentication arguments
                            { "skin", skin },
                            { "posx", target.transform.position.x.ToString() },
                            { "posy", target.transform.position.y.ToString() },
                            { "posz", target.transform.position.z.ToString() },
                            { "roty", target.transform.rotation.eulerAngles.y.ToString() },
                        },
                            delegate(Connection connection) {
                            Debug.Log("Joined Room.");
                            joinRoom = true;
                            GameObject.FindGameObjectWithTag("GameManager").GetComponent <WebCam> ().enabled = true;
                            // We successfully joined a room so set up the message handler
                            pioconnection            = connection;
                            pioconnection.OnMessage += handlemessage;

                            //	pioconnection.Send("Skin", roty);
                            joinedroom = true;
                        },
                            delegate(PlayerIOError error) {
                            Debug.Log("Error Joining Room: " + error.ToString());
                        }
                            );
                    }
                }
                else
                {
                    client.Multiplayer.CreateJoinRoom(
                        null,                                                    //Room id. If set to null a random roomid is used
                        "WalkTypeOne",                                           //The room type started on the server
                        true,                                                    //Should the room be visible in the lobby?
                        null,
                        new Dictionary <string, string> {                        //Authentication arguments
                        { "skin", skin },
                        { "posx", target.transform.position.x.ToString() },
                        { "posy", target.transform.position.y.ToString() },
                        { "posz", target.transform.position.z.ToString() },
                        { "roty", target.transform.rotation.eulerAngles.y.ToString() },
                    },
                        delegate(Connection connection) {
                        Debug.Log("Joined Room.");
                        joinRoom = true;
                        GameObject.FindGameObjectWithTag("GameManager").GetComponent <WebCam> ().enabled = true;
                        // We successfully joined a room so set up the message handler
                        pioconnection            = connection;
                        pioconnection.OnMessage += handlemessage;


                        joinedroom = true;
                    },
                        delegate(PlayerIOError error) {
                        Debug.Log("Error Joining Room: " + error.ToString());
                    }
                        );
                }
            },
                                         null
                                         );


            //				Debug.Log("CreateJoinRoom");
            //				//Create or join the room
            //				client.Multiplayer.CreateJoinRoom(
            //					"MainRoom",                    //Room id. If set to null a random roomid is used
            //					"MainRoom",                   //The room type started on the server
            //					true,                               //Should the room be visible in the lobby?
            //					null,
            //					null,
            //					delegate (Connection connection) {
            //						Debug.Log("Joined Room.");
            //						infomsg = "Joined Room.";
            //						// We successfully joined a room so set up the message handler
            //						pioconnection = connection;
            //						pioconnection.OnMessage += handlemessage;
            //
            //						pioconnection.Send("Skin", roty);
            //						joinedroom = true;
            //					},
            //					delegate (PlayerIOError error) {
            //						Debug.Log("Error Joining Room: " + error.ToString());
            //						infomsg = error.ToString();
            //					}
            //				);
        },
            delegate(PlayerIOError error) {
            Debug.Log("Error connecting: " + error.ToString());
            infomsg = error.ToString();
        }
            );

        //target.GetComponent<AnimationSkinManager> ().CreateSkin (skinList[PlayerPrefs.GetInt("Skin")]);
    }
示例#28
0
        private void reloadPacks_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(loginField1.Text))
            {
                if (!string.IsNullOrWhiteSpace(loginField2.Text))
                {
                    if (accEverybodyEdits.Checked)
                    {
                        PlayerIO.QuickConnect.SimpleConnect(bdata.gameID, loginField1.Text, loginField2.Text, null, successLogin1, failLogin);
                    }
                    if (accEverybodyEditsTransfer.Checked)
                    {
                        PlayerIO.QuickConnect.SimpleConnect(bdata.gameID, loginField1.Text, loginField2.Text, null, delegate(Client cli)
                        {
                            cli.Multiplayer.CreateJoinRoom("$service-room", "AuthRoom", true, null, new Dictionary <string, string>()
                            {
                                { "type", "Link" }
                            }, delegate(Connection con)
                            {
                                con.OnMessage += delegate(object sender1, PlayerIOClient.Message m)
                                {
                                    if (m.Type == "auth")
                                    {
                                        PlayerIO.Authenticate("everybody-edits-su9rn58o40itdbnw69plyw", "linked", new Dictionary <string, string>()
                                        {
                                            { "userId", m.GetString(0) }, { "auth", m.GetString(1) }
                                        }, null, successLogin, failLogin);
                                    }
                                };
                            },
                                                           delegate(PlayerIOError error)
                            {
                                MessageBox.Show(error.Message, "Error");
                            });
                        },
                                                            failLogin);
                        accountOption = 4;
                    }

                    /* Facebook disabled
                     * else if (accFacebook.Checked)
                     * {
                     *  PlayerIO.QuickConnect.FacebookOAuthConnect("everybody-edits-su9rn58o40itdbnw69plyw", loginField1.Text, null, null, successLogin1, failLogin);
                     * }
                     */
                    else if (accKongregate.Checked)
                    {
                        PlayerIO.QuickConnect.KongregateConnect(bdata.gameID, loginField1.Text, loginField2.Text, null, successLogin1, failLogin);
                    }
                    else if (accArmorGames.Checked)
                    {
                        PlayerIO.Authenticate(bdata.gameID, "secure", new Dictionary <string, string> {
                            { "userId", loginField1.Text }, { "authToken", loginField2.Text }
                        }, null, successLogin1, failLogin);
                    }
                }
                else
                {
                    MessageBox.Show("Your login details isn't added", "Login error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Your login details isn't added", "Login error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }