public override void Activate(bool instancePreserved)
        {
            base.Activate(instancePreserved);
            myData = Storage.Get<PlayerData>("myPlayerData");

            // Draw logo
            // TODO: do it

            // Draw profile information
            BorderedView profileContainer = new BorderedView(new Vector2(1140, 600), new Vector2(630, 540));
            profileElements.Add(profileContainer);

            Image profileBackground = new Image("profileBg", 0, new Vector2(448, 312), new Vector2(420, 498));
            PlayerAvatar avatar = new PlayerAvatar(myData, new Vector2(420, 533));
            profileElements.Add(profileBackground);
            profileElements.Add(avatar);

            Label name = new Label(myData.username, new Vector2(420, 790));
            name.Font = "gillsans";
            name.MaxSize(700);
            Label levelTitle = new Label("Level", new Vector2(978, 300));
            Label level = new Label(myData.level.ToString(), new Vector2(978, 375));
            level.Font = "tahomaLarge";
            level.Scale = 0.8f;
            Label rankTitle = new Label("Rank", new Vector2(978, 460));
            Label rank = new Label("#" + myData.rank, new Vector2(978, 535));
            rank.Font = "tahomaLarge";
            rank.Scale = 0.8f;
            profileElements.Add(name);
            profileElements.Add(rankTitle);
            profileElements.Add(rank);
            profileElements.Add(levelTitle);
            profileElements.Add(level);

            SquareButton profileButton = new SquareButton();
            profileButton.Icon = new Image("buttonSquare", (int)TextureData.ButtonSquare.profile);
            profileButton.Position = new Vector2(876, 720);
            profileButton.Tapped += profileButton_Tapped;
            profileElements.Add(profileButton);

            SquareButton storeButton = new SquareButton();
            storeButton.Icon = new Image("buttonSquare", (int)TextureData.ButtonSquare.store);
            storeButton.Position = new Vector2(1080, 720);
            storeButton.Tapped += storeButton_Tapped;
            profileElements.Add(storeButton);

            foreach(UIElement element in profileElements) {
                mainView.AddElement(element);
                profileDestinations[element] = element.Position;
                if(profileBounce) {
                    // immediately hide profile from view
                    element.Position = new Vector2(3000, 2000);
                }
            }
        }
        public override void Activate(bool instancePreserved)
        {
            base.Activate(instancePreserved);

            myData = Storage.Get<PlayerData>("myPlayerData");
            username = myData.username;

            // Request the profile data
            JObject packet = new JObject(
                new JProperty("action", "profile"),
                new JProperty("type", "get"),
                new JProperty("username", username)
            );
            conn.pMessageReceivedEvent += handleProfile;
            conn.SendMessage(packet.ToString());

            Image profileBackground = new Image("profileBg", 0, new Vector2(448, 312), new Vector2(1536, 258));
            avatar = new PlayerAvatar(myData, new Vector2(1536, 293));
            profileElements.Add(profileBackground);
            profileElements.Add(avatar);

            playerInfo = new BorderedView(new Vector2(672, 552), new Vector2(1536, 780));
            playerInfo.BorderWidth = 0;

            name = new Label(myData.username, new Vector2(1536, 580));
            name.Font = "gillsans";
            name.Scale = 1.2f;
            name.MaxSize(760);
            level = new Label("Level: " + myData.level, new Vector2(1536, 660));
            rank = new Label("Rank #" + myData.rank, new Vector2(1536, 730));
            profileElements.Add(name);
            profileElements.Add(level);
            profileElements.Add(rank);

            Button store = new SmallButton("Store");
            store.Position = new Vector2(1536, 858);
            profileElements.Add(store);

            Button back = new SmallButton("Back");
            back.Position = new Vector2(1536, 978);
            back.Tapped += backButton_Tapped;
            profileElements.Add(back);

            playerInfo.AddElement(name, level, rank, store, back);
            profileElements.Add(playerInfo);

            avatars = new BorderedView(new Vector2(1152, 1300), new Vector2(576, 540));
            Label avatarsLabel = new Label("Unlocked Critters", new Vector2(576, 50));
            avatarsLabel.Font = "gillsans";
            mainView.AddElement(avatars, avatarsLabel);

            foreach(UIElement element in profileElements) {
                mainView.AddElement(element);
                profileDestinations[element] = element.Position;
                // immediately hide profile from view
                element.Position = new Vector2(3000, 2000);
            }
            avatarDestinations[avatars] = avatars.Position;
            avatarDestinations[avatarsLabel] = avatarsLabel.Position;
            avatars.Position = new Vector2(-2000, 2000);
            avatarsLabel.Position = new Vector2(-500, -500);
        }
        public override void Activate(bool instancePreserved)
        {
            base.Activate(instancePreserved);
            OfflineScreenCore osc = Storage.Get<OfflineScreenCore>("OfflineScreenCore");
            osc.ShowAdDuplex(false);

            if (!ScreenManager.Textures.ContainsKey("gameIcons")) {
                ContentManager cm = ScreenManager.Game.Content;
                ScreenManager.Textures.Add("gameIcons", cm.Load<Texture2D>("gameIcons"));
            }

            timeLeft = 10;
            timeLeftTimer = new Timer(timeLeftTimerCallback, null, 1000, 1000);
            gamesToVote = new GameData[3];

            // Load relevant information
            JArray playerInfo = Storage.Get<JArray>("group_info");
            JArray gameChoices = Storage.Get<JArray>("game_choices");

            players = new Dictionary<string, PlayerData>();

            // Parse color for duplicate skins
            // If not default, no two players should have the same color
            Dictionary<string, int> colorMap = new Dictionary<string, int>();
            int colorCount = 1;
            foreach (JObject playerData in playerInfo) {
                string profile = (string)playerData["profile"];
                int color = 0;
                if (colorMap.ContainsKey(profile)) {
                    color = colorCount++;
                } else {
                    colorMap[profile] = 1;
                }
                players[(string)playerData["username"]] = new PlayerData((string)playerData["username"], profile, (int)playerData["level"], color);
            }
            Storage.Set("player_data", players);

            int iconX = middleIconX - iconSpace - iconSize;
            BorderedView voteMenu = new BorderedView(new Vector2(912, 960), new Vector2(middleIconX, 1080 / 2));
            voteMenu.Disabled = false;

            Label ChooseGame = new Label("Choose Game", new Vector2(middleIconX, 200));
            ChooseGame.Font = "museoslab";
            voteMenu.AddElement(ChooseGame);

            // add the buttons for the games
            buttons = new List<Button>();
            iconSizeVector = new Vector2(iconSize, iconSize);
            int index = 0;
            foreach (string game in gameChoices) {
                GameData gd = GameConstants.GetGameData(game);
                gamesToVote[index] = gd;
                index++;
                Button gameChoice = new Button(gd.GameIconTexture, gd.GameIconIndex);
                gameChoice.Size = iconSizeVector;
                gameChoice.Position = new Vector2(iconX, iconStartY);
                gameChoice.TappedArgs.ObjectArg = gd;
                gameChoice.Tapped += selectGame;
                Label line1 = new Label(gd.NameLine1, new Vector2(iconX, iconStartY + 140));
                line1.Font = "gillsans";
                line1.Scale = 0.8f;
                Label line2 = new Label(gd.NameLine2, new Vector2(iconX, iconStartY + 200));
                line2.Font = "gillsans";
                line2.Scale = 0.8f;

                buttons.Add(gameChoice);
                voteMenu.AddElement(gameChoice, line1, line2);

                iconX += iconSpace + iconSize;
            }

            // add the vote button
            voteButton = new SmallButton("Vote");
            voteButton.Position = new Vector2(middleIconX, iconStartY + iconSpace + 200);
            voteButton.Tapped += vote;
            voteButton.Disabled = true;
            voteMenu.AddElement(voteButton);

            Label timeLeftLabel = new Label("Time Left: ", new Vector2(middleIconX - 15, iconStartY + iconSpace + 330));
            timeLeftLabel.Font = "gillsans";
            timeLeftLabel.Scale = 0.8f;
            timeLeftNumber = new Label(timeLeft.ToString(), new Vector2(middleIconX + 115, iconStartY + iconSpace + 330));
            timeLeftNumber.CenterX = false;
            timeLeftNumber.Scale = 1.2f;
            voteMenu.AddElement(timeLeftLabel);
            voteMenu.AddElement(timeLeftNumber);

            mainView.AddElement(voteMenu);

            BorderedView playersView = new BorderedView(new Vector2(840, 960), new Vector2(middlePlayers, 1080 / 2));
            float playersX = 175;
            float playersY = 180;
            float spacing = 240;
            PlayerData myData = Storage.Get<PlayerData>("myPlayerData");
            foreach (PlayerData p in players.Values) {
                PlayerAvatar playerAvatar = new PlayerAvatar(p, new Vector2(playersX, playersY));
                Label playerName = new Label(p.username, new Vector2(playersX + 110, playersY - 30));
                Label level = new Label("Level " + p.level, new Vector2(playersX + 110, playersY + 30));
                level.CenterX = false;
                level.Scale = 0.8f;
                playerName.CenterX = false;
                playerName.Scale = 1.2f;
                playerName.Font = "gillsans";
                playerName.MaxSize(700);
                if (myData.username == p.username) {
                    // drawing our own avatar. put it in a view so we can highlight it yellow
                    BorderedView yellowHighlight = new BorderedView(new Vector2(840, spacing), new Vector2(middlePlayers, playersY));
                    yellowHighlight.BorderColor = new Color(132, 201, 73); // set the border color to yellow
                    yellowHighlight.DrawFill = false; // don't draw the fill color
                    yellowHighlight.AddElement(playerAvatar, playerName, level);
                    playersView.AddElement(yellowHighlight);
                } else {
                    playersView.AddElement(playerAvatar, playerName);
                }
                playersY += spacing;
            }

            mainView.AddElement(playersView);
        }
        public override void Activate(bool instancePreserved)
        {
            base.Activate(instancePreserved);

            Dictionary<string, PlayerData> playerData = Storage.Get<Dictionary<string, PlayerData>>("player_data");
            PlayerData myData = Storage.Get<PlayerData>("myPlayerData");

            // level calculations
            int myLevel = Storage.Get<int>("myLevel");
            int currLvlExp = Storage.Get<int>("curr_lvl_exp"); // experience to get to our current level
            int nextLvlExp = Storage.Get<int>("next_lvl_exp"); // experience to get the the next level
            int currExp = Storage.Get<int>("exp"); // our current experience
            int expGained = Storage.Get<int>("exp_gained"); // how much experience we gained
            int isolatedLvlExp = currExp - currLvlExp;
            int prevExp = (isolatedLvlExp < expGained) ? 0 : currExp - expGained - currLvlExp;
            int currExpToShow = currExp - currLvlExp;
            int expToNext = nextLvlExp - currLvlExp;
            int gainedExpToShow = currExpToShow - prevExp;
            bool levelGained = false;
            if (myData.level != myLevel) { // our new level doesnt match. we gained a level
                myData.level = myLevel;
                Storage.Set("myPlayerData", myData); // resave the player data
                levelGained = true;
            }

            List<PlayerData> sortedScoreData = Storage.Get<List<PlayerData>>("scores");
            for (int i = 0; i < sortedScoreData.Count; i++) {
                PlayerData player = sortedScoreData[i];
                BorderedView playerView = new BorderedView(new Vector2(432, 525), new Vector2(276 + 456 * i, 425));
                if (player.username == myData.username) {
                    // displaying ourself. draw a yellow background instead of the default light brown
                    playerView.FillColor = Constants.YellowHighlight;
                    player.level = myLevel; // update the level info
                }

                PlayerAvatar playerAvatar = new PlayerAvatar(player, new Vector2(276 + 456 * i, 400));
                Label playerName = new Label(player.username, new Vector2(276 + 456 * i, 575));
                playerName.Font = "gillsans";
                playerName.MaxSize(500);
                Label playerLevel = new Label("Level " + player.level.ToString(), new Vector2(276 + 456 * i, 625));
                playerLevel.Scale = 0.8f;

                Image badge = new Image("scoreScreenIcons", player.score - 1, new Vector2(192, 192), new Vector2(276 + 456 * i, 150 + 20 * (player.score - 1)));

                playerView.AddElement(playerAvatar);
                playerView.AddElement(playerName);
                playerView.AddElement(playerLevel);

                mainView.AddElement(playerView);
                mainView.AddElement(badge);
            }

            const int levelViewHeight = 125;
            const int levelViewWidth = 1800;
            const int levelViewX = 960;
            const int levelViewY = 825;
            const int rectX = levelViewX - levelViewWidth / 2 + 20; // top left corner of the level rectangle;
            const int rectY = levelViewY - levelViewHeight / 2 + 20; // top right corner of the level rectangle;
            const int rectSizeX = levelViewWidth - 40;
            const int rectSizeY = levelViewHeight - 40;

            int currExpToShowSize = rectSizeX * prevExp / expToNext;
            gainedExpToShowSize = rectSizeX * gainedExpToShow / expToNext;
            BorderedView levelView = new BorderedView(new Vector2(levelViewWidth, levelViewHeight), new Vector2(levelViewX, levelViewY));
            FilledRectangle levelBack = new FilledRectangle(new Rectangle(rectX, rectY, rectSizeX, rectSizeY));
            levelBack.RectangleColor = new Color(102, 102, 102);
            levelView.AddElement(levelBack);
            FilledRectangle levelCurrExp = new FilledRectangle(new Rectangle(rectX, rectY, currExpToShowSize, rectSizeY));
            levelCurrExp.RectangleColor = new Color(48, 198, 48);
            levelView.AddElement(levelCurrExp);
            levelExpGain = new FilledRectangle(new Rectangle(rectX + currExpToShowSize-1, rectY, 0, rectSizeY));
            levelExpGain.RectangleColor = new Color(154, 231, 154);
            levelView.AddElement(levelExpGain);

            Label levelLabel = new Label("Level " + myLevel, new Vector2(rectX+50, levelViewY));
            levelLabel.TextColor = Color.White;
            levelLabel.CenterX = false;
            levelView.AddElement(levelLabel);

            Label expLabel = new Label(currExpToShow + " / " + expToNext, new Vector2(levelViewX, levelViewY));
            expLabel.TextColor = Color.White;
            levelView.AddElement(expLabel);

            Label expGainedLabel = new Label("+" + expGained + "XP", new Vector2(levelViewX + 325, levelViewY));
            expGainedLabel.TextColor = Color.Yellow;
            levelView.AddElement(expGainedLabel);

            if (levelGained) { // display a level gained message
                Label levelGainedLabel = new Label("+level", new Vector2(levelViewX + 525, levelViewY));
                levelGainedLabel.TextColor = Color.Yellow;
                levelView.AddElement(levelGainedLabel);
            }

            mainView.AddElement(levelView);

            Label messageLabel = new Label("Tap to continue", new Vector2(levelViewX, levelViewY + 150));
            mainView.AddElement(messageLabel);
        }