public SkinInterface(Skin skin, SkinAction whenSelectClicked, ContentManager content, string bgAsset, SpriteFont font, string tongueAsset, int x, int y) { this.Skin = skin; this.font = font; this.skinSelected = whenSelectClicked; color = Color.White; color.R = 124; color.G = 216; color.B = 247; bgRect = new Rectangle(x, y, WIDTH, HEIGHT); skinName = skin.Name; skinNamePos = new Vector2(bgRect.X + (bgRect.Width / 2 - ((int)font.MeasureString(skinName).X / 2)), bgRect.Y + SPACING); selectButton = new MenuButton(new OnButtonClick(SelectClicked), LanguageTranslator.Translate("Select"), content, 0, 0, true, font); selectButton.X = bgRect.X + (bgRect.Width / 2 - (selectButton.Width / 2)); selectButton.Y = bgRect.Bottom - selectButton.Height - SPACING; snake = new Snake(skin, 0, 0, content, tongueAsset); snake.X = bgRect.X + (bgRect.Width / 2 - (snake.Width / 2)); snake.Y = selectButton.Y - snake.Rectangle.Height - SPACING; bgImg = content.Load <Texture2D>(bgAsset); }
public ShopItemInterface(ContentManager content, string whiteRectAsset, Skin itemSkin, SpriteFont smallFont, SkinAction buyClicked, int cost, int x, int y, int itemWidth, int itemHeight, string tongueAsset) { // Initialize image objects bgImg = content.Load <Texture2D>(whiteRectAsset); costString = cost.ToString() + "c"; name = itemSkin.Name; this.skinBought = buyClicked; this.ItemSkin = itemSkin; this.Cost = cost; this.font = smallFont; bgColor.R = 124; bgColor.G = 216; bgColor.B = 247; // Initialize positioning objects bgRect = new Rectangle(x, y, BG_WIDTH, BG_HEIGHT); namePos = new Vector2(bgRect.X + (bgRect.Width / 2 - (int)(font.MeasureString(name).X / 2)), bgRect.Y + SPACING); buyButton = new MenuButton(new OnButtonClick(SkinClicked), LanguageTranslator.Translate("Buy") + " (" + cost + "c)", content, 0, 0, true, font); buyButton.X = bgRect.X + (bgRect.Width / 2 - (buyButton.Width / 2)); buyButton.Y = bgRect.Bottom - buyButton.Height - SPACING; costPos = new Vector2(bgRect.X + (bgRect.Width / 2 - (int)(font.MeasureString(costString).X / 2)), buyButton.Y - SPACING - (int)(font.MeasureString(costString).Y)); snake = new Snake(itemSkin, 0, 0, content, tongueAsset); snake.X = bgRect.X + (bgRect.Width / 2 - (snake.Width / 2)); snake.Y = (int)costPos.Y - snake.Height - SPACING; itemType = ShopItemType.Skin; }
public GiftGiver(List <Skin> skins, List <InventoryItem> items, ContentManager content, string bgAsset, string interiorAsset, int x, int y, Random rand, Action onReward, string tongueAsset, string coinAsset, Dictionary <ItemType, string> itemAssets, string xpAsset, SpriteFont smallFont, SpriteFont bigFont, int windowWidth, int windowHeight, SkinAction skinAdded) { this.content = content; this.tongueAsset = tongueAsset; this.coinAsset = coinAsset; this.itemAssets = itemAssets; this.xpAsset = xpAsset; this.skinAdded = skinAdded; this.skins = skins; this.items = items; this.rand = rand; this.onReward = onReward; this.windowWidth = windowWidth; this.windowHeight = windowHeight; button = new MenuButton(interiorAsset, new OnButtonClick(RewardGift), content, x, y, true); button.ImgWidth = WIDTH - (SPACING * 2); button.ImgHeight = HEIGHT - (SPACING * 2); button.Width = WIDTH; button.Height = HEIGHT; rewardPopup = new Popup(content, smallFont, bgAsset, windowWidth, windowHeight, false, bigFont); }
public Shop(ContentManager content, string speedAsset, string teleportAsset, string wallBreakAsset, string whiteRectSprite, SpriteFont smallFont, string mazeAsset, Dictionary <ItemType, InventoryAction> itemActions, List <Skin> skins, string tongueAsset, SkinAction skinBought, string leftArrowAsset, string rightArrowAsset, int windowWidth, int windowHeight, Action onItemPurchase, SpriteFont bigFont, string textboxAsset, SpriteFont mediumFont, string forcefieldAsset, string frozenAsset) { this.onItemPurchase = onItemPurchase; this.bigFont = bigFont; this.content = content; this.speedAsset = speedAsset; this.teleportAsset = teleportAsset; this.wallBreakAsset = wallBreakAsset; this.instaFinAsset = mazeAsset; this.windowWidth = windowWidth; this.windowHeight = windowHeight; this.skinBought = skinBought; this.itemActions = itemActions; skinButton = new MenuButton(new OnButtonClick(MakeStateSkins), LanguageTranslator.Translate("Snakes"), content, 0, 0, true, bigFont); skinButton.Y = windowHeight - (skinButton.Height * 2) - SPACING; pwButton = new MenuButton(new OnButtonClick(MakeStatePowerups), LanguageTranslator.Translate("Powerups"), content, 0, 0, true, bigFont); pwButton.Y = skinButton.Y; skinButton.Width = pwButton.Width; pwButton.X = windowWidth / 2 - (SPACING / 2 + pwButton.Width); skinButton.X = windowWidth / 2 + SPACING / 2; nextPageButton = new MenuButton(rightArrowAsset, new OnButtonClick(NextPage), content, 0, 0, true); prevPageButton = new MenuButton(leftArrowAsset, new OnButtonClick(PrevPage), content, 0, 0, true); prevPageButton.Y = windowHeight - (prevPageButton.Height + SPACING); prevPageButton.X = SPACING * 2; nextPageButton.ImgWidth = prevPageButton.ImgWidth; nextPageButton.ImgHeight = prevPageButton.ImgHeight; nextPageButton.Width = prevPageButton.Width; nextPageButton.Height = prevPageButton.Height; nextPageButton.Y = windowHeight - (nextPageButton.Height + SPACING); nextPageButton.X = windowWidth - (SPACING + nextPageButton.Width); pwInterfaces = new List <ShopItemInterface>() { new ShopItemInterface(content, whiteRectSprite, speedAsset, smallFont, new OnButtonClick(SpeedBought), LanguageTranslator.Translate("Speed Powerup"), speedCost, 0, 0, powerupWidth, powerupHeight, ItemType.SpeedPowerup), new ShopItemInterface(content, whiteRectSprite, teleportAsset, smallFont, new OnButtonClick(TeleportBought), LanguageTranslator.Translate("Teleport Powerup"), teleportCost, 0, 0, powerupWidth, powerupHeight, ItemType.TeleportPowerup), new ShopItemInterface(content, whiteRectSprite, wallBreakAsset, smallFont, new OnButtonClick(WallBreakerBought), LanguageTranslator.Translate("Electric Powerup"), wallBreakCost, 0, 0, powerupWidth, powerupHeight, ItemType.WallBreakPowerup), new ShopItemInterface(content, whiteRectSprite, forcefieldAsset, smallFont, new OnButtonClick(ForcefieldBought), LanguageTranslator.Translate("Forcefield Powerup"), forcefieldCost, 0, 0, powerupWidth, powerupHeight, ItemType.ForcefieldPowerup), new ShopItemInterface(content, whiteRectSprite, frozenAsset, smallFont, new OnButtonClick(FrozenBought), LanguageTranslator.Translate("Frozen Powerup"), frozenCost, 0, 0, powerupWidth, powerupHeight, ItemType.FrozenPowerup), //new ShopItemInterface(content, whiteRectSprite, mazeAsset, smallFont, new OnButtonClick(FinishBought), // LanguageTranslator.Translate("Finish"), 50, 0, 0, powerupWidth, powerupHeight, ItemType.Finish), }; for (int i = 0; i <= skins.Count - 1; i++) { // Iterates through the skins collection, making sure that all skins make it into the game // The old code was inefficient and filled with bugs skinInterfaces.Add(new ShopItemInterface(content, whiteRectSprite, skins[i], smallFont, new SkinAction(SkinBought), Costs.SkinCosts[skins[i].Type], 0, 0, Snake.REG_WIDTH, Snake.REG_HEIGHT, tongueAsset)); } UpdateSkinPagesToInterfaces(); }