protected void Initialize(Vector2 Size, Vector2 Position) { this.Size = Size; this.Position = Position; Visible = true; CenterX = true; CenterY = true; Disabled = true; // default to not tappable Selected = false; Scale = 1f; TappedArgs = new UIElementTappedArgs(this); }
private void Game_Tapped(object sender, UIElementTappedArgs e) { GameData gd = (GameData)e.ObjectArg; GenerateUpgradeStore(gd); }
private void StoreItem_Tapped(object sender, UIElementTappedArgs e) { itemSelected = true; StoreItem si = (StoreItem)e.ObjectArg; if (si.GetType().IsAssignableFrom(typeof(GameUpgradeStoreItem))) { // this is a game upgrade item GameUpgradeStoreItem gusi = (GameUpgradeStoreItem)si; itemDescription.Text = si.Name; itemName.Visible = true; itemDescription.Visible = true; if (gusi.Level < 5) { // upgrade is not maxed out yet // allow the user to buy the upgrade itemName.Text = "Level " + (gusi.Level + 1) + " Upgrade"; buyItem.TappedArgs.ObjectArg = si; buyItem.Text = si.Price.ToString(); buyItem.Visible = true; } else { itemName.Text = "Already at max level"; buyItem.Visible = false; } } else { // this is a regular upgrade item itemName.Text = si.Name; itemName.Visible = true; itemDescription.Visible = false; buyItem.TappedArgs.ObjectArg = si; buyItem.Text = si.Price.ToString(); buyItem.Visible = true; } }
private void BuyItem_Tapped(object sender, UIElementTappedArgs e) { StoreItem si = (StoreItem)e.ObjectArg; if (myData.money < si.Price) { // not enough money to buy it string line1 = "Not enough money to buy " + si.Name; string line2 = "You have $" + myData.money + " and you need $" + si.Price; ScreenManager.AddScreen(new MessagePopup(line1, line2), null); return; } // otherwise user has enough money, purchase the item if (si.GetType().IsAssignableFrom(typeof(GameUpgradeStoreItem))) { // this is a game upgrade item GameUpgradeStoreItem gusi = (GameUpgradeStoreItem)si; GameUpgrade gu = gusi.MyGameUpgrade; gu.Level++; // increase the level by 1 GenerateUpgradeStore(gu.MyGame); // send the information to the server JObject packet = new JObject( new JProperty("action", "store"), new JProperty("type", "game"), new JProperty("game", gu.MyGame.ServerName), new JProperty("upgrade_index", gu.Index) ); conn.SendMessage(packet.ToString()); } myData.money -= si.Price; Storage.Set("myPlayerData", myData); currentMoney.Text = "$" + myData.money; // show a confirmation to the user string line = "Sucessfully bought " + si.Name; ScreenManager.AddScreen(new MessagePopup(line, ""), null); }
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; } }
// Method callback when we press on a game icon button to vote for void selectGame(object sender, UIElementTappedArgs e) { if (voted) { // already pressed the vote button. dont do anything return; } // go through the list and unhighlight any previous selected buttons foreach (Button b in buttons) { b.Highlight = false; } ((Button)e.Element).Highlight = true; // highlight the button we pressed selectedGame = (GameData)e.ObjectArg; // our selected game is the button we pressed voteButton.Disabled = false; // enable the vote button for people to vote }
private void backButton_Tapped(object sender, UIElementTappedArgs e) { OnBackPressed(); }
private void OnTap(object sender, UIElementTappedArgs e) { MyScreenManager.Sounds[buttonSound].Play(); }
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; }
private void rateButton_Tapped(object sender, UIElementTappedArgs e) { #if WINDOWS_PHONE MarketplaceDetailTask marketplaceDetailTask = new MarketplaceDetailTask(); marketplaceDetailTask.ContentType = MarketplaceContentType.Applications; marketplaceDetailTask.Show(); #endif }
void close_Tapped(object sender, UIElementTappedArgs e) { OnBackPressed(); }
// Method callback when we press on a game icon button to vote for void SelectGame(object sender, UIElementTappedArgs e) { if (selectedButton != null) { selectedButton.Highlight = false; } selectedButton = (Button)e.Element; selectedButton.Highlight = true; // highlight the button we pressed selectedGame = (GameData)e.ObjectArg; // our selected game is the button we pressed gameName.Text = selectedGame.Name; // Get high score data if(!PermanentStorage.Get(selectedGame.ServerName + "_score", out highScore.Text)) { highScore.Text = "0"; } // Show proper star rating for(int i = 0; i < 5; i++) { if(selectedGame.StarMap[i] < int.Parse(highScore.Text)) { stars[i].TextureIndex = 1; } else { stars[i].TextureIndex = 0; } } }