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); 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 ClearCategory() { itemViewLabel.Text = "Select a category at the right"; itemView.RemoveAllElements(); selectedCategory.DrawSelected = false; // unhighlight it selectedCategory.Disabled = false; // let it be pressed again selectedCategory = null; categorySelected = false; }
private void CategoryButton_Tapped(object sender, UIElementTappedArgs e) { categorySelected = true; if (selectedCategory != null) { // there was a previous selected category selectedCategory.DrawSelected = false; // unhighlight it selectedCategory.Disabled = false; // let it be pressed again } selectedCategory = (Button)e.Element; selectedCategory.Disabled = true; // don't let it be pressed again selectedCategory.DrawSelected = true; // highlight it to show the user what category were in itemDescription.Text = "selected " + e.Arg; switch (e.Arg) { case "skins": SwitchToSkinsCategory(); break; case "upgrades": SwitchToUpgradesCategory(); break; } }
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); }
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; } } } }
private void iconButton_Tapped(object sender, UIElementTappedArgs e) { // pressed on an icon. send the new profile icon data to the server ProfileData pd = (ProfileData)e.ObjectArg; if (pd.ServerName == myData.profile) { // selected the same profile return; } myData.profile = pd.ServerName; avatar.PlayerDataInfo = myData; selectedButton.ButtonTexture.Tint = normalTint; selectedButton = (Button)sender; selectedButton.ButtonTexture.Tint = selectedTint; }
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); }