示例#1
0
        private void ProcessResponse(RdlTagCollection tags)
        {
            bool       validLogin = false;
            RdlAuthKey key        = tags.Where(t => t.TagName == "AUTH").FirstOrDefault() as RdlAuthKey;

            if (key != null)
            {
                if (!String.IsNullOrEmpty(key.Key))
                {
                    validLogin = true;
                }

                // Check for persist login token.
                if (!String.IsNullOrEmpty(key.PersistLoginToken))
                {
                    StorageManager.SetPersistLoginToken(key.PersistLoginToken);
                }
            }

            this.Dispatcher.BeginInvoke(() =>
            {
                _waitDialog.Close();
            });

            if (validLogin)
            {
                Settings.UserAuthKey = key.Key;
                ScreenManager.SetScreen(new HomeScreen());
            }
            else
            {
                valMain.Errors.Add(new ValidationSummaryItem("The username/password combination you supplied is invalid. Please ensure caps lock is not on and try again."));
            }
        }
示例#2
0
        private void ProcessCharacters(RdlTagCollection tags)
        {
            List <RdlPlayer> players = tags.GetObjects <RdlPlayer>();

            if (players.Count > 0)
            {
                // Load the player's character avatar panels.
                var avatars = new List <Avatar>();
                for (int i = 0; i < players.Count; i++)
                {
                    avatars.Add(new Avatar(players[i]));
                }
                lstAvatars.ItemsSource = avatars;
            }
            else
            {
                // Display the new player dialog.
                var win = new NewPlayerIntroWindow();
                win.Closed += (o, args) =>
                {
                    if (win.DialogResult == true)
                    {
                        ScreenManager.SetScreen(new CreateCharacterWizardScreen());
                    }
                };
                win.Show();
            }

            // Get a USER tag that contains the max number of characters available to this user.
            RdlUser user = tags.Where(t => t.TagName == "USER").FirstOrDefault() as RdlUser;

            if (user != null)
            {
                if (players.Count >= user.MaxCharacters)
                {
                    btnCreateCharacter.IsEnabled = false;
                }
                // TODO: Purchase Button
            }
        }
示例#3
0
        private void ProcessTags(RdlTagCollection tags)
        {
            // AuthKey tags
            this.UpdateAuthKeys(tags.Where(t => t.TagName == "AUTH").Select(t => t as RdlAuthKey));

            // Place Types
            var placeTypes = tags.Where(t => t.TagName == "PLACETYPE" && t.TypeName == "PLACETYPE");

            if (placeTypes.Count() > 0)
            {
                List <string> types = new List <string>();
                foreach (var pt in placeTypes)
                {
                    types.Add(pt.GetArg <string>(0));
                }
                ddlPlaceTypes.ItemsSource = types;
            }

            // Properties
            if (this.Player != null)
            {
                var properties = tags.GetProperties(_playerId);
                if (properties != null && properties.Count > 0)
                {
                    // Location
                    Point3 location = new Point3(this.Player.X, this.Player.Y, this.Player.Z);

                    // Loop through all of the properties.
                    foreach (var item in properties)
                    {
                        // All other properties.
                        this.Player.Properties.SetValue(item.Name, item.Value);
                    }

                    Point3 playerLoc = new Point3(this.Player.X, this.Player.Y, this.Player.Z);
                    if (location != playerLoc)
                    {
                        ctlMap.SetView(playerLoc);
                    }
                }
            }

            int count = tags.GetObjects <RdlPlace>().Count;

            if (count == 1)
            {
                // Place
                RdlPlace place = tags.GetObjects <RdlPlace>().FirstOrDefault();
                if (place != null)
                {
                    _placeId                   = place.ID;
                    _currentLocation           = new Point3(place.X, place.Y, place.Z);
                    txtPlaceName.Text          = place.Name;
                    txtPlaceDesc.Text          = place.Properties.GetValue <string>("Description") ?? String.Empty;
                    ddlPlaceTypes.SelectedItem = place.Properties.GetValue <string>("RuntimeType");
                    ddlTerrain.SelectedItem    = Game.Terrain.Where(t => t.ID == place.Properties.GetValue <int>("Terrain")).FirstOrDefault();
                    ctlMap.Tiles.Add(new Tile(place));
                    ctlMap.SetView(new Point3(this.Player.X, this.Player.Y, this.Player.Z));
                    ctlMap.HideLoading();
                }
                List <RdlActor> actors = tags.GetActors();
                if (actors.Count > 0)
                {
                    lstActors.ItemsSource = actors;
                }
            }
            else if (count > 1)
            {
                // Map
                ctlMap.LoadMap(tags);
                ctlMap.SetView(new Point3(this.Player.X, this.Player.Y, this.Player.Z));
                ctlMap.HideLoading();
            }

            // Chat Messages
            ctlChat.WriteMessages(tags);
        }