Exemplo n.º 1
0
        private void ModifyPlayerLevel(Guid playerId, int levelOffset)
        {
            relay.GetFile(playerId, (s, file) =>
            {
                int level = Convert.ToInt32(file.Entries["Level"]);

                if (level + levelOffset > 0)
                {
                    level += levelOffset;
                }
                else
                {
                    level = 1;
                }

                var newEntries = file.Entries.SetItem("Level", level.ToString());
                relay.UpdateFile(playerId, newEntries);

                relay.GetFile(leaderboardsFileId, (s1, file1) =>
                {
                    newEntries = file1.Entries.SetItem(playerId.ToString(), level.ToString());
                    relay.UpdateFile(leaderboardsFileId, newEntries);
                });
            });
        }
Exemplo n.º 2
0
        private void OnInviteDirectMessage(object sender, byte[] bytes)
        {
            if (bytes[0] == MessageConnect)
            {
                relay.OnDirectMessage -= OnInviteDirectMessage;
                relay.SendDirectMessage((Guid)sender, new[] { MessageConnect });

                StartGame((Guid)sender);

                relay.GetFile(matchmakingFileId, (s, file) =>
                {
                    var newEntries = file.Entries.SetItem(relay.OwnId.ToString(), "");
                    relay.UpdateFile(matchmakingFileId, newEntries);

                    OnFileRecieved(sender, file);
                });
            }
        }
Exemplo n.º 3
0
        public FormMatchmaking(INetworkRelay <TNetworkAddress> relay, Guid matchmakingFileId, Guid leaderboardsFileId)
        {
            this.relay              = relay;
            this.matchmakingFileId  = matchmakingFileId;
            this.leaderboardsFileId = leaderboardsFileId;

            relay.OnDirectMessage += OnInviteDirectMessage;

            InitializeComponent();

            textBoxYourId.Text = relay.OwnId.ToString();

            relay.GetFile(relay.OwnId, (s, file) =>
            {
                var newEntries = file.Entries.Add("Level", "1");
                relay.UpdateFile(relay.OwnId, newEntries);
            });
        }
Exemplo n.º 4
0
 private void FormLeaderboards_Load(object sender, EventArgs e)
 {
     relay.GetFile(leaderboardsFileId, FileLoaded);
 }