Example #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);
                }
            }
        }
        private void updateProfileScreen()
        {
            lock(avatarDestinations) {
                avatar.PlayerDataInfo = dataToDisplay;

                name.Text = dataToDisplay.username;
                rank.Text = "Rank #" + dataToDisplay.rank;
                level.Text = "Level: " + dataToDisplay.level;

                if(dataToDisplay.username == myData.username) {
                    // displaying our own profile. display the critters we can use
                    int startX = 144;
                    int startY = 200;

                    List<string> unlockedProfiles = Storage.Get<List<string>>("unlocked");
                    foreach(string prof in unlockedProfiles) {
                        ProfileData pd = ProfileConstants.GetProfileData(prof);

                        SquareButton newIcon = new SquareButton();
                        newIcon.Icon = new Image("avatars", pd.ProfileIndex * Constants.AVATAR_COLORS);
                        newIcon.Icon.Size = new Vector2(128, 128);
                        newIcon.Icon.Scale = 0.7f;
                        newIcon.Position = new Vector2(startX, startY);

                        if(prof == myData.profile) {
                            newIcon.ButtonTexture.Tint = selectedTint;
                            selectedButton = newIcon;
                        } else {
                            newIcon.ButtonTexture.Tint = normalTint;
                        }

                        newIcon.TappedArgs.ObjectArg = pd;
                        newIcon.Tapped += iconButton_Tapped;

                        mainView.AddElement(newIcon);
                        avatarDestinations[newIcon] = newIcon.Position;
                        newIcon.Position = new Vector2(-500, -500);

                        startX += 216;
                    }
                }
            }
        }