public ShoppingItemUI(IItem item, int i, Action whenBought) { _playerAccount = CurrentGameState.State.PlayerAccount; Branch = new ClickUIBranch(item.Name, (int)ClickUIPriorities.Pad); var x = (i % 4) * (Sizes.Item.Width + Sizes.Margin); var y = (i / 4) * (Sizes.Item.Height + Sizes.Margin * 2 + Sizes.Button.Height); _transform = new Transform2(new Vector2((int)x, (int)y)); _productDetails = new ImageWithDescription("Images/Items/" + item.Name.ToLower().Replace(" ", "-").Replace(".", ""), item.Description, new Transform2(Sizes.Item)); _label = new Label { BackgroundColor = Color.Transparent, TextColor = Color.White, Font = "Fonts/14", Transform = new Transform2(new Vector2(0, Sizes.Item.Height + 5), new Size2(Sizes.Item.Width, 30)), RawText = item.Name + " - $" + item.Cost.Amount() }; _amount = item.Cost.Amount(); _button = ImageTextButtonFactory.Create("Buy", new Vector2(0, Sizes.Item.Height + Sizes.SmallMargin + 30), () => { if (_playerAccount.Amount() >= _amount) { whenBought(); } }); _disabledButton = new ImageLabel("Buy", "Images/UI/button-disable", new Transform2(new Vector2(0, Sizes.Item.Height + Sizes.SmallMargin + 30), Sizes.Button)); Branch.Add(_button); Branch.Add(_productDetails); }
public ShoppingCompanyOptionUI(IShoppingCompany company, int i, Action whenBought) { Branch = new ClickUIBranch(company.Name, (int)ClickUIPriorities.Pad); var x = (i % 4) * (Sizes.Item.Width + Sizes.Margin); var y = (i / 4) * (Sizes.Item.Height + Sizes.Margin * 2 + Sizes.Button.Height); _transform = new Transform2(new Vector2((int)x, (int)y)); _productDetails = new ImageWithDescription("Images/Companies/" + company.Name.ToLower().Replace(" ", "-").Replace(".", "").Replace("'", ""), company.Description, new Transform2(Sizes.Item)); _label = new Label { BackgroundColor = Color.Transparent, TextColor = Color.White, Font = "Fonts/14", Transform = new Transform2(new Vector2(0, Sizes.Item.Height + 5), new Size2(Sizes.Item.Width, 30)), RawText = company.Name }; _button = ImageTextButtonFactory.Create("Shop", new Vector2(0, Sizes.Item.Height + Sizes.SmallMargin + 30), whenBought); Branch.Add(_button); Branch.Add(_productDetails); }