예제 #1
0
 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);
 }
예제 #2
0
 private void Game_Tapped(object sender, UIElementTappedArgs e)
 {
     GameData gd = (GameData)e.ObjectArg;
     GenerateUpgradeStore(gd);
 }
예제 #3
0
        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;
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
        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;
            }
        }
예제 #6
0
        // 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
        }
예제 #7
0
 private void backButton_Tapped(object sender, UIElementTappedArgs e)
 {
     OnBackPressed();
 }
예제 #8
0
 private void OnTap(object sender, UIElementTappedArgs e)
 {
     MyScreenManager.Sounds[buttonSound].Play();
 }
예제 #9
0
        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;
        }
예제 #10
0
 private void rateButton_Tapped(object sender, UIElementTappedArgs e)
 {
     #if WINDOWS_PHONE
     MarketplaceDetailTask marketplaceDetailTask = new MarketplaceDetailTask();
     marketplaceDetailTask.ContentType = MarketplaceContentType.Applications;
     marketplaceDetailTask.Show();
     #endif
 }
예제 #11
0
 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;
                }
            }
        }