public SpaceStationComponent(Game game) : base(game) { Menu = new SpaceStationMenu(game); TradeOptions = new TradeOptions(); //TEMPORARY Menu.SellMaterials.Add(new Plutonium(32)); Menu.SellMaterials.Add(new Tungsten(32)); Menu.SellMaterials.Add(new Hydrogen(32)); Menu.BuyMaterials.Add(new Plutonium(32)); Menu.BuyMaterials.Add(new Tungsten(32)); Menu.BuyMaterials.Add(new Hydrogen(32)); //========= }
public void DrawComponentsTrade(TradeOptions Options) { int i = 0; foreach (BuyOption B in Options.Buy) { i++; Rectangle Slot = new Rectangle((int)(Renderer.Width * 1.5 / 10), (int)(10 + Renderer.Height * i / 10), (int)(Renderer.Width/ 10), (int)(Renderer.Height /10)); Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, Slot, Color.White); Renderer.Singleton.batch.Draw(B.Item.Tex, Slot, Color.White); Rectangle PriceRect = new Rectangle(Slot.X + Slot.Width * 3 / 4, Slot.Y + Slot.Height * 3 / 4, Slot.Width * 1 / 4, Slot.Height * 1 / 4); Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, PriceRect, Color.White); Text PriceText = new Text(Game); PriceText.Name = B.Price.ToString(); PriceText.Rect = PriceRect; PriceText.Font = Font; PriceText.Draw(null); //Renderer.Singleton.batch.DrawString(Font, B.Price.ToString(), new Vector2(Slot.X + Slot.Width * 3 / 4, Slot.Y + Slot.Height * 3 / 4), Color.White, 0.0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0.0f); } i = 0; foreach (SellOption B in Options.Sell) { i++; Rectangle Slot = new Rectangle((int)(Renderer.Width * 2.5 / 10), (int)(10 + Renderer.Height * i / 10), (int)(Renderer.Width / 10), (int)(Renderer.Height / 10)); Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, Slot, Color.White); Renderer.Singleton.batch.Draw(B.Item.Tex, Slot, Color.White); Rectangle PriceRect = new Rectangle(Slot.X + Slot.Width * 3 / 4, Slot.Y + Slot.Height * 3 / 4, Slot.Width * 1 / 4, Slot.Height * 1 / 4); Renderer.Singleton.batch.Draw(Renderer.Singleton.SlotBackground, PriceRect, Color.White); Text PriceText = new Text(Game); PriceText.Name = B.Price.ToString(); PriceText.Rect = PriceRect; PriceText.Font = Font; PriceText.Draw(null); // Renderer.Singleton.batch.DrawString(Font, B.Price.ToString(), new Vector2(Slot.X + Slot.Width * 3 / 4, Slot.Y + Slot.Height * 3 / 4), Color.White, 0.0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0.0f); } }
public void Update(GameTime gameTime, TradeOptions Options) { if (MenuMode == Mode.TradeComponents) { int i = 0; foreach (BuyOption B in Options.Buy) { i++; Rectangle Slot = new Rectangle((int)(Renderer.Width * 1.5 / 10), (int)(10 + Renderer.Height * i / 10), (int)(Renderer.Width / 10), (int)(Renderer.Height / 10)); if (GeneralManager.Singleton.CheckLMB() && GeneralManager.Singleton.CheckCollision(GeneralManager.Singleton.MousePos, Slot)) { B.OnClick(); Options.Buy.Remove(B); break; } } i = 0; foreach (SellOption B in Options.Sell) { i++; Rectangle Slot = new Rectangle((int)(Renderer.Width * 2.5 / 10), (int)(10 + Renderer.Height * i / 10), (int)(Renderer.Width / 10), (int)(Renderer.Height / 10)); if (GeneralManager.Singleton.CheckLMB() && GeneralManager.Singleton.CheckCollision(GeneralManager.Singleton.MousePos, Slot)) { B.OnClick(); Options.Sell.Remove(B); break; } } } if (MenuMode == Mode.TradeMaterials) { for (int i = 0; i < SellMaterials.Count; i++) { Rectangle Slot = Renderer.GetPartialRect(0.2f, 0.2f + 0.05f * i, 0.05f, 0.05f); if (GeneralManager.Singleton.CheckLMB()) { if (Slot.Contains((int)GeneralManager.Singleton.MousePos.X, (int)GeneralManager.Singleton.MousePos.Y)) { SellMaterials[i].Count -= 1; GeneralManager.Singleton.CurrentPlayer.Money += SellMaterials[i].AvgPrice; if (SellMaterials[i].Count <= 0) { SellMaterials.Remove(SellMaterials[i]); } } } } for (int i = 0; i < BuyMaterials.Count; i++) { Rectangle Slot = Renderer.GetPartialRect(0.3f, 0.2f + 0.05f * i, 0.05f, 0.05f); if (GeneralManager.Singleton.CheckLMB()) { if (Slot.Contains((int)GeneralManager.Singleton.MousePos.X, (int)GeneralManager.Singleton.MousePos.Y)) { BuyMaterials[i].Count -= 1; GeneralManager.Singleton.CurrentPlayer.Money -= SellMaterials[i].AvgPrice; if (BuyMaterials[i].Count <= 0) { BuyMaterials.Remove(BuyMaterials[i]); } } } } } base.Update(gameTime); }