Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        public override void Activate(bool instancePreserved)
        {
            base.Activate(instancePreserved);

            myData = Storage.Get<PlayerData>("myPlayerData");
            TransitionAnimations = new List<UIElement>();

            categorySelected = false;
            gameSelected = false;
            itemSelected = false;

            BorderedView storeCategories = new BorderedView(new Vector2(672, 450), new Vector2(1536, 258));
            storeCategories.BorderWidth = 0;
            Label categories = new Label("Categories", new Vector2(rightXMiddle, 125));
            categories.Font = "gillsans";
            categories.Scale = 1.2f;
            Button skins = new SmallButton("Skins");
            skins.Position = new Vector2(rightXMiddle, 250);
            skins.TappedArgs.Arg = "skins";
            skins.Tapped += CategoryButton_Tapped;
            Button upgrades = new SmallButton("Upgrades");
            upgrades.Position = new Vector2(rightXMiddle, 370);
            upgrades.TappedArgs.Arg = "upgrades";
            upgrades.Tapped += CategoryButton_Tapped;
            storeCategories.Disabled = false;
            storeCategories.AddElement(categories, skins, upgrades);
            storeCategories.SetAnimationOffset(new Vector2(1000, 0), Helpers.EaseOutBounceAnimation, false); // set the animation to start 1000 pixels to the right
            storeCategories.UpdateAnimationPosition(0); // start the animation to move the elements out of screen
            TransitionAnimations.Add(storeCategories); // add it to the list of animated objects
            mainView.AddElement(storeCategories);

            BorderedView itemDetails = new BorderedView(new Vector2(672, 552), new Vector2(rightXMiddle, 780));
            itemDetails.BorderWidth = 0;

            itemName = new Label("", new Vector2(rightXMiddle, 580));
            itemName.Font = "gillsans";
            itemName.MaxSize(760);
            itemDescription = new Label("", new Vector2(rightXMiddle, 650));
            itemDescription.MaxSize(760);
            buyItem = new SmallButton("");
            buyItem.Position = new Vector2(1536, 745);
            buyItem.ButtonImage = "buyButton";
            buyItem.Tapped += BuyItem_Tapped;
            ClearItem();

            currentMoney = new Label("$" + myData.money, new Vector2(rightXMiddle, 870));
            currentMoney.Font = "gillsans";
            currentMoney.TextColor = Color.Yellow;
            Button back = new SmallButton("Back");
            back.Position = new Vector2(1536, 978);
            back.Tapped += backButton_Tapped;
            itemDetails.Disabled = false;
            itemDetails.AddElement(itemName, itemDescription, buyItem, currentMoney, back);
            itemDetails.SetAnimationOffset(new Vector2(1000, 0), Helpers.EaseOutBounceAnimation, false); // set the animation to start 1000 pixels to the right
            itemDetails.UpdateAnimationPosition(0); // start the animation to move the elements out of screen
            TransitionAnimations.Add(itemDetails); // add it to the list of animated objects
            mainView.AddElement(itemDetails);

            BorderedView storeLeft = new BorderedView(new Vector2(1152, 1300), new Vector2(leftXMiddle, 540));
            storeLeft.Disabled = false;
            itemView = new View(new Vector2(1152, 1300), new Vector2(leftXMiddle, 540));
            itemView.Disabled = false;
            itemViewLabel = new Label("Select a category at the right", new Vector2(leftXMiddle, leftYTop));
            itemViewLabel.Font = "gillsans";
            storeLeft.AddElement(itemViewLabel, itemView);
            storeLeft.SetAnimationOffset(new Vector2(-1500, 0), Helpers.EaseOutBounceAnimation, false); // set the animation to start 1500 pixels to the left
            storeLeft.UpdateAnimationPosition(0); // start the animation to move the elements out of screen
            TransitionAnimations.Add(storeLeft); // add it to the list of animated objects
            mainView.AddElement(storeLeft);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        protected void handleLeaders(string message, bool error, ITCPConnection connection)
        {
            JObject o = JObject.Parse(message);
            if((string)o["action"] == "rank" && (string)o["type"] == "leader") {
                doneRetrieving = true;
                connection.pMessageReceivedEvent -= handleLeaders;
                JArray leaderArr = (JArray)o["leaders"];

                PlayerData myData = Storage.Get<PlayerData>("myPlayerData");
                if(retrieving != null)
                    retrieving.Visible = false;
                int index = 1;
                int rank = 0;
                int prevLvl = -1;

                foreach(JObject name in leaderArr) {
                    BorderedView row = playerRows.ElementAt(index - 1);
                    string username = (string)name["username"];
                    int level = (int)name["level"];

                    if(prevLvl != level) {
                        // the levels are different. this player is not a tie. set the rank equal to the current index
                        rank = index;
                        prevLvl = level;
                    } // otherwise display the same rank as before

                    Label rankLabel = new Label(rank.ToString(), new Vector2(startX, startY + index * 70 + 5));
                    Label player = new Label(username, new Vector2(startX + 125, startY + index * 70 + 5));
                    player.CenterX = false;
                    player.Font = "gillsans";
                    player.Scale = 0.85f;
                    player.MaxSize(700);

                    Label levelLabel = new Label(level.ToString(), new Vector2(startX + 850, startY + index * 70 + 5));

                    row.AddElement(rankLabel);
                    row.AddElement(player);
                    row.AddElement(levelLabel);

                    if(myData.username == username) {
                        row.BorderColor = Constants.YellowHighlight;
                    }

                    index++;

                    if(index > 10) {
                        break;
                    }
                }

                int myRank = (int)((JObject)o["rank"])["rank"];

                BorderedView myRow = playerRows.ElementAt(10);

                Label myRankLabel = new Label(myRank.ToString(), new Vector2(startX, startY + 11 * 70 + 5));
                Label myPlayer = new Label(myData.username, new Vector2(startX + 125, startY + 11 * 70 + 5));
                myPlayer.CenterX = false;
                myPlayer.Font = "gillsans";
                myPlayer.Scale = 0.85f;
                myPlayer.MaxSize(700);
                Label myLevel = new Label(myData.level.ToString(), new Vector2(startX + 850, startY + 11 * 70 + 5));

                myRow.AddElement(myRankLabel);
                myRow.AddElement(myPlayer);
                myRow.AddElement(myLevel);
                myRow.BorderColor = Constants.YellowHighlight;
            }
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }