public override void Activate(bool instancePreserved) { base.Activate(instancePreserved); IsPopup = true; RemoveConn(); // dont need our page to be handling any connections exitPage = new BorderedView(new Vector2(875, 400), new Vector2(1920 / 2, 1080 / 2 - 125)); exitPage.Disabled = false; int startX = 1920 / 2; int startY = 270; Label text = new Label("Are you sure you want to exit?", new Vector2(startX, startY)); Button keepPlaying = new SmallButton("Keep Playing"); keepPlaying.Position = new Vector2(startX, startY + 140); keepPlaying.Tapped += PopupExitTap; Button exitButton = new SmallButton("Exit"); exitButton.Position = new Vector2(startX, startY + 260); exitButton.Tapped += (s, e) => { if(exitGame) { SwitchScreen(typeof(OfflineScreen)); } else { SwitchScreen(typeof(HomeScreen)); } }; exitPage.AddElement(text); exitPage.AddElement(keepPlaying); exitPage.AddElement(exitButton); mainView.AddElement(exitPage); }
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); IsPopup = true; aboutPage = new BorderedView(new Vector2(1150, 902), new Vector2(1920 / 2, 1080 / 2 - 75)); aboutPage.Disabled = false; int startX = 445; int startY = 120; Label about = new Label("About", new Vector2(startX, startY)); about.CenterX = false; about.Font = "tahoma"; Label version = new Label("Version " + Configuration.VERSION, new Vector2(startX, startY + 70)); version.CenterX = false; version.Scale = 0.8f; Label email1 = new Label("Email any issues to: ", new Vector2(startX + 670, startY - 20)); email1.CenterX = false; email1.Scale = 0.8f; Label email2 = new Label("*****@*****.**", new Vector2(startX + 340, startY + 30)); email2.CenterX = false; Button rate = new Button("Rate Us"); rate.Position = new Vector2(startX + 200, startY + 177); rate.Tapped += rateButton_Tapped; Image fbIcon = new Image("fbIcon", 0, new Vector2(100, 100), new Vector2(startX + 75, startY + 350)); Label fb = new Label("fb.me/CritterCampGame", new Vector2(startX + 180, startY + 350)); fb.CenterX = false; Image twIcon = new Image("twitterIcon", 0, new Vector2(100, 100), new Vector2(startX + 75, startY + 515)); Label tw = new Label("@CritterCampGame", new Vector2(startX + 180, startY + 515)); tw.CenterX = false; Label music1 = new Label("Music", new Vector2(startX, startY + 655)); music1.CenterX = false; music1.Scale = 0.8f; Label music2 = new Label("Call to Adventure by Kevin Macleod", new Vector2(startX, startY + 715)); music2.CenterX = false; aboutPage.AddElement(about); aboutPage.AddElement(version); aboutPage.AddElement(email1); aboutPage.AddElement(email2); aboutPage.AddElement(rate); aboutPage.AddElement(fbIcon); aboutPage.AddElement(fb); aboutPage.AddElement(twIcon); aboutPage.AddElement(tw); aboutPage.AddElement(music1); aboutPage.AddElement(music2); mainView.AddElement(aboutPage); }
public override void Activate(bool instancePreserved) { base.Activate(instancePreserved); // Add buttons single = new LargeButton("Single Player"); single.Position = new Vector2(1560, 360); single.TextFont = "tahomaLarge"; single.TextScale = 0.8f; single.Tapped += singleButton_Tapped; multi = new LargeButton("Multiplayer"); multi.Position = new Vector2(1560, 612); multi.ButtonTexture.Tint = new Color(72, 182, 216); multi.TextFont = "tahomaLarge"; multi.TextScale = 0.8f; multi.Tapped += multiButton_Tapped; back = new SmallButton("Back"); back.Position = new Vector2(1560, 894); back.Tapped += backButton_Tapped; AddButton(single, multi, back); mainView.AddElement(single, multi, back); SearchingButtons = new View(); SearchingButtons.Disabled = false; SearchingButtons.Visible = false; playersInParty = new Label("Searching for players: 1/4", new Vector2(1560, 550)); playersInParty.Scale = 0.8f; playersInParty.TextColor = Color.White; AnimatedPigs = new List<Image>(); int size = Constants.BUFFER_SPRITE_DIM; Vector2 StartingPosition = new Vector2(1600 - size * 3f, 650); for(int i = 0; i < 6; i++) { Image PigImage = new Image("pig", i); PigImage.Position = StartingPosition + new Vector2(size * i, 0); SearchingButtons.AddElement(PigImage); AnimatedPigs.Add(PigImage); } SearchingButtons.AddElement(playersInParty); mainView.AddElement(SearchingButtons); }
public override void Activate(bool instancePreserved) { base.Activate(instancePreserved); IsPopup = true; // Request the leaderboards JObject packet = new JObject( new JProperty("action", "rank"), new JProperty("type", "leader") ); conn.pMessageReceivedEvent += handleLeaders; conn.SendMessage(packet.ToString()); leaderPage = new BorderedView(new Vector2(1100, 840), new Vector2(1920 / 2, 1080 / 2 - 75)); leaderPage.Disabled = false; Label rank = new Label("Rank", new Vector2(startX, startY)); rank.Scale = 1.1f; Label player = new Label("Player", new Vector2(startX + 125, startY)); player.CenterX = false; player.Scale = 1.1f; Label level = new Label("Level", new Vector2(startX + 850, startY)); level.Scale = 1.1f; playerRows = new List<BorderedView>(); for(int i = 0; i < 11; i++) { BorderedView row = new BorderedView(new Vector2(1100, 70), new Vector2(1920 / 2, startY + (i + 1) * 70)); if(i % 2 == 0) { row.BorderColor = new Color(239, 208, 175); } else { row.BorderColor = Constants.LightBrown; } row.DrawFill = false; leaderPage.AddElement(row); playerRows.Add(row); } retrieving = new Label("Retreiving the top players", new Vector2(startX, startY + 70)); retrieving.CenterX = false; leaderPage.AddElement(rank); leaderPage.AddElement(player); leaderPage.AddElement(level); leaderPage.AddElement(retrieving); mainView.AddElement(leaderPage); }
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); }
private void SwitchToUpgradesCategory() { ClearItem(); gameSelected = false; itemView.RemoveAllElements(); // remove any elements from the last category itemViewLabel.Text = "Single Player Game Upgrades"; int startX = 192; int startY = leftYTop + 150; int count = 0; // generate the store items and buttons for the game upgrades foreach (GameData gd in GameConstants.GAMES) { // draw the game icon and name Button gameChoice = new Button(gd.GameIconTexture, gd.GameIconIndex); gameChoice.Size = new Vector2(128, 128); gameChoice.Position = new Vector2(startX, startY); gameChoice.TappedArgs.ObjectArg = gd; gameChoice.Tapped += Game_Tapped; Label line1 = new Label(gd.NameLine1, new Vector2(startX, startY + 140)); line1.Font = "gillsans"; line1.Scale = 0.8f; Label line2 = new Label(gd.NameLine2, new Vector2(startX, startY + 200)); line2.Font = "gillsans"; line2.Scale = 0.8f; count++; if (count == 4) { count = 0; startX = 192; startY += 356; } else { startX += 256; } itemView.AddElement(gameChoice, line1, line2); } }
private void SwitchToSkinsCategory() { ClearItem(); itemView.RemoveAllElements(); // remove any elements from the last category itemViewLabel.Text = "Profile Skins"; Label comingSoon = new Label("New skins coming soon!", new Vector2(leftXMiddle, leftYTop + 75)); itemView.AddElement(comingSoon); }
private void GenerateUpgradeStore(GameData gd) { gameSelected = true; ClearItem(); itemView.RemoveAllElements(); // remove any elements from the last category itemViewLabel.Text = gd.Name + " Upgrades"; int startY = leftYTop + 150; // generate the store items and buttons for the game upgrades foreach (GameUpgrade gu in gd.GameUpgrades) { GameUpgradeStoreItem gusi = new GameUpgradeStoreItem(gu); Button upgrade = new LongButton(gu.Name); upgrade.Position = new Vector2(leftXMiddle, startY); upgrade.TappedArgs.ObjectArg = gusi; upgrade.Tapped += StoreItem_Tapped; Label level = new Label("Level: " + gu.Level + "/5", new Vector2(leftXMiddle, startY + 115)); startY += 275; itemView.AddElement(upgrade, level); } }
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); }
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; } }
public override void Activate(bool instancePreserved) { base.Activate(instancePreserved); IsPopup = true; RemoveConn(); // dont need our page to be handling any connections BorderedView messagePage = new BorderedView(new Vector2(1350, 400), new Vector2(1920 / 2, 1080 / 2 - 125)); messagePage.Disabled = false; int startX = 1920 / 2; int startY = 270; Label text1 = new Label(Line1, new Vector2(startX, startY)); Label text2 = new Label(Line2, new Vector2(startX, startY+80)); Button okButton = new SmallButton("Ok"); okButton.Position = new Vector2(startX, startY + 260); okButton.Tapped += PopupExitTap; messagePage.AddElement(text1); messagePage.AddElement(text2); messagePage.AddElement(okButton); mainView.AddElement(messagePage); }
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); IsPopup = true; BorderedView newsPage = new BorderedView(new Vector2(1100, 840), new Vector2(1920 / 2, 1080 / 2 - 75)); newsPage.Disabled = false; Label newsTitle = new Label("Latest News", new Vector2(1920/2, startY)); newsTitle.Font = "museoslab"; newsTitle.Scale = 0.8f; List<NewsPost> news = Storage.Get<List<NewsPost>>("news"); if (news.Count != 0) { NewsPost firstNews = news.ElementAt(0); Label newsDate = new Label(firstNews.TimeStamp.ToString("M", new CultureInfo("en-US")), new Vector2(startX, startY + 75)); newsDate.CenterX = false;; String lineBreaksPost = NewsPost.insertLineBreaks(firstNews.Post, 1050, ScreenManager); Label newsPostLabel = new Label(lineBreaksPost, new Vector2(startX, startY + 115)); newsPostLabel.CenterX = false; newsPostLabel.CenterY = false; Button close = new SmallButton("Close"); close.Position = new Vector2(1920 / 2, startY + 700); close.Tapped += close_Tapped; newsPage.AddElement(newsTitle, newsDate, newsPostLabel, close); } else { Label noNews = new Label("No new news posts to display", new Vector2(startX, startY + 100)); noNews.CenterX = false; newsPage.AddElement(newsTitle, noNews); } mainView.AddElement(newsPage); }
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); }
public override void Activate(bool instancePreserved) { base.Activate(instancePreserved); if(!ScreenManager.Textures.ContainsKey("gameIcons")) { ContentManager cm = ScreenManager.Game.Content; ScreenManager.Textures.Add("gameIcons", cm.Load<Texture2D>("gameIcons")); } PlayerData myData = Storage.Get<PlayerData>("myPlayerData"); Dictionary<string, PlayerData> players = new Dictionary<string, PlayerData>(); players[myData.username] = myData; Storage.Set("player_data", players); gameInfo = new BorderedView(new Vector2(672, 1032), new Vector2(1536, 540)); gameInfo.BorderWidth = 0; gameName = new Label(); gameName.Position = new Vector2(1536, 100); gameName.Font = "gillsans"; gameName.Scale = 1.2f; gameDataElements.Add(gameName); // star rating stars = new Image[5]; for(int i = 0; i < 5; i++) { stars[i] = new Image("star", 0); stars[i].TextureIndex = 0; stars[i].Size = new Vector2(64, 64); stars[i].Position = new Vector2(1536 + (i - 2) * 100, 250); gameDataElements.Add(stars[i]); gameInfo.AddElement(stars[i]); } Label highScoreText = new Label("High Score", new Vector2(1536, 425)); highScoreText.Font = "gillsans"; highScore = new Label(); highScore.Position = new Vector2(1536, 525); highScore.Font = "gillsans"; highScore.Scale = 1.2f; gameDataElements.Add(highScoreText); gameDataElements.Add(highScore); playButton = new LargeButton("Play"); playButton.Position = new Vector2(1536, 792); playButton.Tapped += Play; gameDataElements.Add(playButton); Button back = new SmallButton("Back"); back.Position = new Vector2(1536, 978); back.Tapped += backButton_Tapped; gameDataElements.Add(back); gameInfo.AddElement(gameName, highScoreText, highScore, playButton, back); gameDataElements.Add(gameInfo); gameIcon = new BorderedView(new Vector2(1152, 1300), new Vector2(576, 540)); Label gameTitle = new Label("Select Game", new Vector2(576, 50)); gameTitle.Font = "museoslab"; mainView.AddElement(gameIcon, gameTitle); // add the buttons for the games iconSizeVector = new Vector2(iconSize, iconSize); int iconX = 144, iconY = 250; foreach(GameData gd in GameConstants.GAMES) { Button gameChoice = new Button(gd.GameIconTexture, gd.GameIconIndex); gameChoice.Size = iconSizeVector; gameIconDestinations[gameChoice] = new Vector2(iconX, iconY); gameChoice.Position = new Vector2(-100, -100); gameChoice.TappedArgs.ObjectArg = gd; gameChoice.Tapped += SelectGame; if(selectedGame == null) { SelectGame(gameChoice, gameChoice.TappedArgs); } mainView.AddElement(gameChoice); iconX += 216; } foreach(UIElement element in gameDataElements) { mainView.AddElement(element); gameDataDestinations[element] = element.Position; // immediately hide profile from view element.Position = new Vector2(3000, 2000); } gameIconDestinations[gameIcon] = gameIcon.Position; gameIconDestinations[gameTitle] = gameTitle.Position; gameIcon.Position = new Vector2(-2000, 2000); gameTitle.Position = new Vector2(-500, -500); }