public override void Activate(bool instancePreserved) { base.Activate(instancePreserved); // Add buttons music = new SmallButton("Leaderboard"); music.Text = "Music: On"; music.Position = new Vector2(1560, 294); music.Tapped += musicButton_Tapped; sound = new SmallButton("Leaderboard"); sound.Text = "Sound Effects: On"; sound.Position = new Vector2(1560, 426); sound.Tapped += soundButton_Tapped; back = new SmallButton("Back"); back.Position = new Vector2(1560, 894); back.Tapped += backButton_Tapped; AddButton(music, sound, back); mainView.AddElement(music, sound, back); string soundOn, musicOn; if(PermanentStorage.Get("music", out musicOn)) { if(!Boolean.Parse(musicOn)) { musicButton_Tapped(music, null); } } if(PermanentStorage.Get("sound", out soundOn)) { if(!Boolean.Parse(soundOn)) { soundButton_Tapped(sound, null); } } }
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); // 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); 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); }
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); // Add buttons play = new LargeButton("PLAY"); play.Position = new Vector2(1560, 360); play.TextFont = "tahomaLarge"; play.Tapped += playButton_Tapped; leaders = new SmallButton("Leaderboard"); leaders.Position = new Vector2(1560, 546); leaders.Tapped += leaderButton_Tapped; options = new SmallButton("Options"); options.Position = new Vector2(1560, 666); options.Tapped += optionsButton_Tapped; about = new SmallButton("About"); about.Position = new Vector2(1560, 786); about.Tapped += aboutButton_Tapped; news = new SmallButton("News"); news.Position = new Vector2(1560, 906); news.Tapped += newsButton_Tapped; AddButton(play, leaders, options, about, news); mainView.AddElement(play, leaders, options, about, news); }
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); 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); }