コード例 #1
0
        public SaveObjectChangesModule()
        {
            this.Post("/api/88", ctx =>
            {
                var args  = Serializer.Deserialize <SaveObjectChangesArgs>(this.Request.Body);
                var token = this.Request.Headers["playertoken"].FirstOrDefault();
                var game  = GameManager.GetGameFromToken(token);

                var versions = new List <string>();

                foreach (var set in args.Changesets)
                {
                    var dbo = game.BigDB.Load(set.Table, set.Key);

                    if (set.FullOverwrite)
                    {
                    }

                    versions.Add("1");
                }

                return(PlayerIO.CreateResponse(token, true, new SaveObjectChangesOutput()
                {
                    Versions = versions
                }));
            });
        }
コード例 #2
0
ファイル: 2328OT_04_06.cs プロジェクト: ssmktr/ExampleNetwork
    void Start()
    {
        PlayerIO.UnityInit(this);

        PlayerIO.Connect("YourGameIDHere", "public", "YourUserIDHere", null, null,
                         delegate(Client c)
        {
            // connected successfully
            client = c;
            Debug.Log("Connected");

            // if we're using the dev server, connect to the local IP
            if (UseDevServer)
            {
                client.Multiplayer.DevelopmentServer = new ServerEndpoint("127.0.0.1", 8184);

                GetRoomList();
            }
        },
                         delegate(PlayerIOError error)
        {
            // did not connect successfully
            Debug.Log(error.Message);
        });
    }
コード例 #3
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();
        }
            );
    }
コード例 #4
0
        public SimpleRegisterModule()
        {
            this.Post("/api/403", ctx =>
            {
                var args     = Serializer.Deserialize <SimpleRegisterArgs>(this.Request.Body);
                var token    = args.GameId + ":" + args.Username;
                var location = Path.Combine("games", "EverybodyEdits", "accounts", args.GameId);

                if (File.Exists(Path.Combine(location, args.Username + ".tson")))
                {
                    throw new Exception($"An account already exists with the username '{args.Username}' in game '{args.GameId}'");
                }

                File.WriteAllText(Path.Combine(location, args.Username + ".tson"),
                                  new DatabaseObject()
                                  .Set("gameId", args.GameId)
                                  .Set("email", args.Email ?? "")
                                  .Set("username", args.Username)
                                  .Set("password", args.Password)
                                  .ToString());

                return(PlayerIO.CreateResponse(token, true, new SimpleRegisterOutput()
                {
                    UserId = args.Username,
                    Token = token,
                    ShowBranding = true
                }));
            });
        }
コード例 #5
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_);
 }
コード例 #6
0
    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();
        }
            );
    }
コード例 #7
0
        private static void Main()
        {
            Console.Title = "EECloud.PlayerIO Test Application";

            do
            {
                Console.CursorVisible = false;
                Console.Write("Testing... (Start time: " + DateTime.Now.ToString("G") + ")");


                // Connecting...
                Watch.Start();
                var client = PlayerIO.Connect("test-szf4hpjepkayftx3jm5wxa", "public", "testuser");
                Watch.Stop();
                WriteElapsedMilliseconds("Connected");

                // Loading a BigDB PlayerData item...
                Watch.Restart();
                var playerObject = client.BigDB.LoadMyPlayerObject();
                var item         = playerObject.Item("11_Object");
                Watch.Stop();
                WriteElapsedMilliseconds("Loaded a BigDB PlayerData item");


                Console.WriteLine(Environment.NewLine +
                                  "Done! Total time elapsed: " + TotalElapsedMilliseconds + "ms");
                TotalElapsedMilliseconds = 0;

                Console.CursorVisible = true;
                Console.ReadKey(true);
                Console.WriteLine();
                Watch.Reset();
            } while (true);
        }
コード例 #8
0
        public PayVaultConsumeModule()
        {
            this.Post("/api/166", ctx =>
            {
                var args  = Serializer.Deserialize <PayVaultConsumeArgs>(this.Request.Body);
                var token = this.Request.Headers["playertoken"].FirstOrDefault();
                var game  = GameManager.GetGameFromToken(token);
                var items = game.BigDB.LoadRange("PayVaultItems", "PriceCoins", null, null, 1000);

                // TODO: actually remove the items.

                return(PlayerIO.CreateResponse(token, true, new PayVaultConsumeOutput()
                {
                    VaultContents = new PayVaultContents()
                    {
                        Coins = 1,
                        Version = "22040806-3e9f-438e-97eb-51069207926d",
                        Items = items.Select(x => new PayVaultItem()
                        {
                            Id = "pvi" + x.Key, ItemKey = x.Key, Properties = DatabaseObjectExtensions.FromDatabaseObject(x)
                        }).ToList()
                    }
                }));
            });
        }
コード例 #9
0
        public static Task <Client> ConnectAsync(string gameId, string connectionId, string userId, string auth, string partnerId, string[] playerInsightSegments)
        {
            var tcs = new TaskCompletionSource <Client>();

            PlayerIO.Connect(gameId, connectionId, userId, auth, partnerId, playerInsightSegments, tcs.SetResult, tcs.SetException);
            return(tcs.Task);
        }
コード例 #10
0
    //Player IO
    public void SendMessage(PlayerIO command)
    {
        string jsonToBeSent = "2";

        jsonToBeSent += JsonUtility.ToJson(command);
        SendJSONMessageToGame(jsonToBeSent, QosType.Unreliable);
    }
コード例 #11
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);
        }
コード例 #12
0
ファイル: World.cs プロジェクト: Epicguru/NotQuiteDead
    public void Save()
    {
        if (!isServer)
        {
            return;
        }

        // Save all tile layers to file.
        TileMap.SaveAll();

        // Save the player inventory:
        // This will only save the host's inventory. TODO support other clients saving inventory data.
        InventoryIO.SaveInventory(RealityName);

        // Save current gear held and worn by local player. TODO see above.
        InventoryIO.SaveGear(RealityName, Player.Local);

        // Save currently held item. TODO see above.
        InventoryIO.SaveHolding(RealityName, Player.Local);

        // Save player state (position, health, etc.)
        PlayerIO.SavePlayerState(RealityName, Player.Local);

        // Save all world items to file.
        ItemIO.ItemsToFile(RealityName, GameObject.FindObjectsOfType <Item>());

        // Save placed furniture...
        FurnitureIO.SaveFurniture(RealityName, Furniture.GetAllFurniture());

        // Save the building inventory...
        BuildingIO.SaveBuildingInventory(RealityName, Player.Local);

        // Save the world state to file.
        WorldIO.SaveWorldState(this);
    }
コード例 #13
0
ファイル: GameManager.cs プロジェクト: tpearce01/ICS168
 // Called by ServerConnection when a client sends in move commands
 public void PlayerActions(int playerID, PlayerIO command)
 {
     if (playerReferences[playerID - 2] != null)
     {
         playerReferences[playerID - 2].GetComponent <PlayerActions>().RequestAction(command);
     }
 }
コード例 #14
0
 public override TagCompound Save()
 {
     return(new TagCompound {
         { "items", PlayerIO.SaveInventory(_items) },
         { "dyes", PlayerIO.SaveInventory(_dyes) },
     });
 }
コード例 #15
0
ファイル: DragItem.cs プロジェクト: warlocksuper/trendcity
    public void OnDrag(PointerEventData data)
    {
        playerIO = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerIO>();
        if (rectTransform == null)
        {
            return;
        }

        if (data.button == PointerEventData.InputButton.Left && transform.parent.GetComponent <CraftResultSlot>() == null)
        {
            rectTransform.SetAsLastSibling();

            transform.SetParent(draggedItemBox);
            Vector2 localPointerPosition;
            canvasGroup.blocksRaycasts = false;
            if (RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransformSlot, Input.mousePosition, data.pressEventCamera, out localPointerPosition))
            {
                rectTransform.localPosition = localPointerPosition - pointerOffset;
                if (transform.GetComponent <ConsumeItem>().duplication != null)
                {
                    Destroy(transform.GetComponent <ConsumeItem>().duplication);
                }
            }
        }

        inventory.OnUpdateItemList();
    }
コード例 #16
0
        public JoinClusterModule()
        {
            this.Post("/api/504", ctx =>
            {
                var args = Serializer.Deserialize <JoinClusterArgs>(this.Request.Body);

                return(PlayerIO.CreateResponse("token", true, new JoinClusterOutput()
                {
                    ActivityLog = "",
                    APIEndpoints = new List <string>()
                    {
                        "http://*****:*****@1234",
                    JoinedClusterName = "Main Cluster",
                    MaxCPUWatchTime = 1000,
                    MaxPlayersPerRoom = 45,
                    MaxRoomCloseAPIRequests = 100000,
                    MaxRoomMB = 10000,
                    ValidEndpoints = null
                }));
            });
        }
コード例 #17
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;
コード例 #18
0
ファイル: World.cs プロジェクト: atillabyte/World
    public World(InputType type, object input, Client client = null)
    {
        if (client == null)
        {
            client = PlayerIO.Connect("everybody-edits-su9rn58o40itdbnw69plyw", "public", "user", "", "");
        }

        switch (type)
        {
        case InputType.DatabaseObject:
            if (!(input is DatabaseObject))
            {
                throw new ArgumentException("input needs to be a DatabaseObject!");
            }

            this._world = (DatabaseObject)input;

            foreach (var property in (DatabaseObject)_world)
            {
                _properties.Add(property.Key, property.Value);
            }

            this.Blocks = Helpers.FromWorldData(_world.GetArray("worlddata"));
            break;

        case InputType.BigDB:
            if (!(input is string))
            {
                throw new ArgumentException("input needs to be a string!");
            }

            this._world = client.BigDB.Load("worlds", (string)input);

            foreach (var property in (DatabaseObject)_world)
            {
                _properties.Add(property.Key, property.Value);
            }

            this.Blocks = Helpers.FromWorldData(_world.GetArray("worlddata"));
            break;

        case InputType.JSON:
            if (!(input is string))
            {
                throw new ArgumentException("input needs to be a string!");
            }

            this._world = JObject.Parse((string)input);

            foreach (var property in _world)
            {
                _properties.Add(property.Name, property.Value);
            }

            this.Blocks = Helpers.FromJsonArray(_world);
            break;
        }
    }
コード例 #19
0
ファイル: Block.cs プロジェクト: warlocksuper/trendcity
 void Start()
 {
     playerIO = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerIO>();
     if (playerIO.isNetwork)
     {
         networkLayer = GameObject.Find("NetworkManager").GetComponent <NetworkLayerClient>();
     }
     hotbar = playerIO.Prefhotbar;//GameObject.Find("PlayerGui").transform.GetChild(2).gameObject;
 }
コード例 #20
0
ファイル: Block.cs プロジェクト: warlocksuper/trendcity
 // Use this for initialization
 private void Awake()
 {
     playerIO = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerIO>();
     if (playerIO.isNetwork)
     {
         networkLayer = GameObject.Find("NetworkManager").GetComponent <NetworkLayerClient>();
     }
     hotbar = playerIO.Prefhotbar;
 }
コード例 #21
0
ファイル: MainForm.cs プロジェクト: Neonixxx/SomeName
        private void Save_Button_Click(object sender, EventArgs e)
        {
            var isSaved = PlayerIO.TrySave(Player);

            if (isSaved)
            {
                MessageBox.Show("Saved succesful.");
            }
        }
コード例 #22
0
    // Use this for initialization
    void Start()
    {
        currentPlayerIO = this;

        /*
         * QualitySettings.vSyncCount = 0;
         * Application.targetFrameRate = 144;
         */
    }
コード例 #23
0
    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();
        }
            );
    }
コード例 #24
0
    // Use this for initialization

    void Start()
    {
        _player     = GameObject.FindGameObjectWithTag("Player");
        menuManager = GameObject.Find("MenuManager").GetComponent <MenuManager>();
        playerIO    = _player.GetComponent <PlayerIO>();
        if (_player != null)
        {
            _inventory = _player.GetComponent <PlayerInventory>().inventory.GetComponent <Inventory>();
        }
    }
コード例 #25
0
 // Use this for initialization
 void Start()
 {
     io         = gameObject.GetComponent <PlayerIO>();
     QiPool     = new Pool(4);
     taoManager = new TaoManager();
     taoManager.addTao(color, 1);
     taoManager.addTao(GS.Color.BLACK, 1);
     hasYinYang    = true;
     gameBoard     = GameObject.FindGameObjectWithTag("_GameBoard").GetComponent <GameBoard>();
     playerManager = GameObject.FindGameObjectWithTag("_PlayerManager").GetComponent <PlayerManager>();
 }
コード例 #26
0
ファイル: PlayerIO.cs プロジェクト: skru/Biome-Game
 // Use this for initialization
 void Start()
 {
     currentPlayerIO = this;
     objectPool      = new Queue <GameObject>();
     for (int i = 0; i < poolSize; i++)
     {
         GameObject obj = Instantiate(cube);
         obj.SetActive(false);
         objectPool.Enqueue(obj);
     }
 }
コード例 #27
0
 public WebserviceOnlineTestModule()
 {
     this.Post("/api/533", ctx =>
     {
         var args = Serializer.Deserialize <WebserviceOnlineTestArgs>(this.Request.Body);
         return(PlayerIO.CreateResponse("token", true, new WebserviceOnlineTestOutput()
         {
             Message = "success"
         }));
     });
 }
コード例 #28
0
ファイル: PlayerIO.cs プロジェクト: takaaptech/Minecraft-3
    // Use this for initialization
    void Start()
    {
        currentPlayerIO = this;
        fpsController   = GameObject.FindWithTag("FPSController");
        inputController = GetComponentInParent <FPSInputControllerC>();

        /*
         * QualitySettings.vSyncCount = 0;
         * Application.targetFrameRate = 144;
         */
    }
コード例 #29
0
        public UserLeftRoomModule()
        {
            this.Post("/api/40", ctx =>
            {
                var args  = Serializer.Deserialize <UserLeftRoomArgs>(this.Request.Body);
                var token = this.Request.Headers["playertoken"].FirstOrDefault();
                var game  = GameManager.GetGameFromToken(token);

                return(PlayerIO.CreateResponse(token, true, new UserLeftRoomOutput()));
            });
        }
コード例 #30
0
ファイル: ArmorGames.cs プロジェクト: capasha/Rabbit
 /// <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
                ));
 }
コード例 #31
0
	// Use this for initialization
	void Start () {
		currentPlayerIO = this;
	}