public void LoadButtons(GraphicsDevice graphicsDevice_, GameContent content_) { Buttons[0] = new Button(content_.GetUiTexture(7), content_.GetFont(1)) { Position = new Vector2(Rectangle.X + 8, Rectangle.Y + 8) }; Buttons[0].Click += delegate { if (SelectionIndex.X > 0) { SelectionIndex -= new Vector2(1, 1); } }; Buttons[1] = new Button(content_.GetUiTexture(7), content_.GetFont(1)) { Position = new Vector2((Rectangle.X + 40) + (32 * 7) + (8 * 8), Rectangle.Y + 8), IsFlipped = true }; Buttons[1].Click += delegate { if (SelectionIndex.Y < Items.Count) { SelectionIndex += new Vector2(1, 1); } }; }
public DebugMenu(GraphicsDevice graphicsDevice_, GameContent content_) { int height_ = 48; int width_ = 780; Position = new Vector2(10, 10); _displaySize = new Vector2(width_, height_); Console.WriteLine($"Debug Menu Created:>"); Console.WriteLine($"Size: {_displaySize}"); Console.WriteLine($"Position: {Position}"); SetColorData(graphicsDevice_); _content = content_; _font = _content.GetFont(1); LoadItemsMenu(graphicsDevice_); Button btn = new Button(_content.GetUiTexture(1), _content.GetFont(1)) { Position = new Vector2(SelectMenu.Position.X + SelectMenu.Rectangle.Width + 56, Position.Y + 8), Text = "SAVE MAP" }; btn.Click += delegate { Console.WriteLine("Saving Map..."); GameState.SaveMap(); }; Components.Add(btn); }
public EditMapsListState(GameInstance game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content) { _gameContent = new GameContent(content); // load maps LoadMaps(); int x = 50; int y = 50; int i = 0; // loop through each loaded map foreach (List <TileData> map in _maps) { var button = new Button(_gameContent.GetUiTexture(1), _gameContent.GetFont(1)) { Position = new Vector2(x, y + (100 * i)), Text = "Map " + (i + 1).ToString(), HoverColor = Color.Red }; button.Click += delegate { Console.WriteLine($"Map {i + 1} clicked"); Map_Click(map); }; _components.Add(button); i++; } }
public Map(Tile[,] tiles_, int width_, int height_, int tx_, int ty_, GameContent content_) { Tiles = tiles_; width = width_; height = height_; tw = tx_; th = ty_; Content = content_; font = Content.GetFont(1); }
public HorizontalScrollMenu(GraphicsDevice graphicsDevice_, GameContent content_, Vector2 size_, Vector2 position_, List <ContentData <Texture2D> > items_) { Position = position_; _displaySize = size_; Items = items_; _content = content_; _font = _content.GetFont(1); SetColorData(graphicsDevice_); LoadSelections(graphicsDevice_, _content); LoadButtons(graphicsDevice_, _content); }
public TextDisplay(string Text, Vector2 Position, int FontSize) { this.Text = Text; this.Position = Position; Font = GameContent.GetFont(DEF_FONT); TextColor = Color.Black; this.FontSize = FontSize; AlignmentX = TextAlignment.Left; AlignmentY = TextAlignment.Top; }
public TextDisplay(string Text) { this.Text = Text; Position = Vector2.Zero; Font = GameContent.GetFont(DEF_FONT); TextColor = Color.Black; FontSize = 1; AlignmentX = TextAlignment.Left; AlignmentY = TextAlignment.Top; }
public Player(GameContent content, Vector2 _position, Vector2 tileIndex, Tile[,] tiles) { font = content.GetFont(1); gameTiles = tiles; currentTile = gameTiles[(int)tileIndex.X, (int)tileIndex.Y]; LoadContent(content); Reset(currentTile.CenterPoint); // load inventory playerInventory = new PlayerInventory(50, 1000); }
// construct map public Map(Tile[,] tiles_, int width_, int height_, int tx_, int ty_, GameContent content_) { // set tiles Tiles = tiles_; // set map width and height width = width_; height = height_; // set tile width and height tw = tx_; th = ty_; // set gamecontent manager Content = content_; // set font font = Content.GetFont(1); }
public CellDataDisplay(GraphicsDevice graphicsDevice_, GameContent content) { SetColorData(graphicsDevice_); _content = content; _font = _content.GetFont(1); }
public HUD(GraphicsDevice graphicsDevice_, GameContent content_) { _graphicsDevice = graphicsDevice_; int height = (int)(graphicsDevice_.Viewport.Height * 0.25f); int width = (int)(graphicsDevice_.Viewport.Width); _position = new Vector2(0, graphicsDevice_.Viewport.Height - height); _displaySize = new Vector2(width, height); _buttonSize = new Vector2(30, height * 0.8f); Console.WriteLine("HUD created."); Console.WriteLine($"HUD Size: {_displaySize}"); Console.WriteLine($"HUD Pos: {_position}"); _content = content_; _font = _content.GetFont(1); HUDIconIDs = new int[] { 5, 6, 7, 8, 12, 9, 10, 11 }; SetColorData(graphicsDevice_); DisplayInfo_Texture = content_.GetUiTexture(37); for (int i = (int)SelectionCells_BuildingIndexes.X; i < SelectionCells_BuildingIndexes.Y; i++) { SelectionCells_BuildingTextures.Add(content_.GetUiTexture(i)); } SelectionCells_BuildingTextures.Add(content_.GetUiTexture(24)); SelectionCells_BuildingTextures.Add(content_.GetUiTexture(25)); if (SelectionCells_BuildingTextures.Count < (SelectionCell_GridDimensions.X * SelectionCell_GridDimensions.Y)) { var dif = (SelectionCell_GridDimensions.X * SelectionCell_GridDimensions.Y) - SelectionCells_BuildingTextures.Count; for (int i = 0; i < dif + 1; i++) { SelectionCells_BuildingTextures.Add(SelectionCells_BuildingTextures[0]); } } SelectionCell_BlankTexture = content_.GetUiTexture(13); foreach (var e in SelectionCells_BldgHouses_Indexes) { SelectionCells_BldgHouses_Textures.Add(content_.GetUiTexture(e)); } foreach (var e in SelectionCells_BldgReso_Indexes) { SelectionCells_BldgReso_Textures.Add(content_.GetUiTexture(e)); } foreach (var e in SelectionCells_BldgDeco_Indexes) { SelectionCells_BldgDeco_Textures.Add(content_.GetUiTexture(e)); } foreach (var e in SelectionCells_AllBldgs_Textures) { if (e.Count < (SelectionCell_GridDimensions.X * SelectionCell_GridDimensions.Y)) { var dif = (SelectionCell_GridDimensions.X * SelectionCell_GridDimensions.Y) - e.Count; for (int i = 0; i < dif + 1; i++) { e.Add(SelectionCell_BlankTexture); } } } SetSelectionCellButtons(); // get textures for buttons that swap between building selections Btn_SelectHouses_Texture = content_.GetUiTexture(26); Btn_SelectReso_Texture = content_.GetUiTexture(27); Btn_SelectDeco_Texture = content_.GetUiTexture(28); var init_btn_bldg_pos = new Vector2(); init_btn_bldg_pos.X = (ResourceBar_Rectangle.X + ResourceBar_Rectangle.Width) - (Btn_SelectHouses_Texture.Width); init_btn_bldg_pos.Y = (ResourceBar_Rectangle.Y - (Btn_SelectHouses_Texture.Height * 3.5f)); var btn_bldgs_house = new Button(Btn_SelectHouses_Texture, _font) { Position = init_btn_bldg_pos, ID = 800 }; btn_bldgs_house.Click += ViewBldgsBtn_OnClick; var btn_bldgs_reso = new Button(Btn_SelectReso_Texture, _font) { Position = init_btn_bldg_pos + new Vector2(0, Btn_SelectHouses_Texture.Height * 1.18f), ID = 801 }; btn_bldgs_reso.Click += ViewBldgsBtn_OnClick; var btn_bldgs_deco = new Button(Btn_SelectDeco_Texture, _font) { Position = init_btn_bldg_pos + new Vector2(0, ((Btn_SelectHouses_Texture.Height * 1.18f) * 2f)), ID = 802 }; btn_bldgs_deco.Click += ViewBldgsBtn_OnClick; _components.Add(btn_bldgs_house); _components.Add(btn_bldgs_reso); _components.Add(btn_bldgs_deco); BtnList_SelectBldgsView.Add(btn_bldgs_house); BtnList_SelectBldgsView.Add(btn_bldgs_reso); BtnList_SelectBldgsView.Add(btn_bldgs_deco); DeleteBuildingBtn_Texture = content_.GetUiTexture(23); DeleteBuildingBtn_Pos = new Vector2( (int)(DisplayInfo_Rectangle.X + DisplayInfo_Rectangle.Width - DeleteBuildingBtn_Texture.Width - ((DisplayInfo_Rectangle.Width * 0.05f) / 2)), (int)(DisplayInfo_Rectangle.Y + (DisplayInfo_Rectangle.Height * 0.05f))); DeleteBuildingBtn = new Button(content_.GetUiTexture(23), _font) { Position = DeleteBuildingBtn_Pos, HoverColor = Color.Red }; DeleteBuildingBtn.Click += DeleteBuildingBtnOnClick; }
public TopBar(GraphicsDevice graphicsDevice_, GameContent content_) { // get required arguments _gameContent = content_; _graphicsDevice = graphicsDevice_; // set display dimensions _displayDimensions = new Vector2(_graphicsDevice.Viewport.Width, _graphicsDevice.Viewport.Height * 0.09f); // calculate texture data(s) _displayTexture = new Texture2D(_graphicsDevice, (int)_displayDimensions.X, (int)_displayDimensions.Y); var o = new Color[(int)_displayDimensions.X * (int)_displayDimensions.Y]; for (var i = 0; i < o.Length; i++) { o[i] = _displayColor; } _displayTexture.SetData(o); _borderTexture = new Texture2D(_graphicsDevice, (int)_borderDimensions.X, (int)_borderDimensions.Y); var e = new Color[(int)_borderDimensions.X * (int)_borderDimensions.Y]; for (var i = 0; i < e.Length; i++) { e[i] = _borderColor; } _borderTexture.SetData(e); _resourceAreaTexture = _gameContent.GetUiTexture(29); _font = _gameContent.GetFont(1); // calculate icon rects var icon_start = new Vector2(_resourceIconsAreaRectangle.X, 0); for (var i = 0; i < _resourceIconIDs.Length; i++) { var icon_id = _resourceIconIDs[i]; var icon_txt = _gameContent.GetUiTexture(icon_id); var icon_pos = icon_start + new Vector2(_resourceIconDisplayDimension.X * i, 0); var icon_rect = new Rectangle((int)icon_pos.X, (int)icon_pos.Y, (int)_resourceIconDisplayDimension.X, (int)_resourceIconDisplayDimension.Y); var icon_print_rect = new Rectangle( (int)(icon_rect.X + ((icon_rect.Width / 2) - (icon_rect.Width / 8))), (int)(icon_rect.Y + (icon_rect.Height / 7)), (int)(icon_rect.Width / 4), (int)((icon_rect.Width / 4) * icon_txt.Height / icon_txt.Width) ); var text_origin = new Vector2( icon_rect.X + (icon_rect.Width / 2), icon_rect.Y + (icon_rect.Height)); _resourceTopBarIcons.Add(new TopBarIcon() { Texture = icon_txt, Rect = icon_print_rect, Index = i, TextOrigin = text_origin }); } }
public HUD(GraphicsDevice graphicsDevice_, GameContent content_) { _graphicsDevice = graphicsDevice_; int height = (int)(graphicsDevice_.Viewport.Height * 0.25f); int width = (int)(graphicsDevice_.Viewport.Width); _position = new Vector2(0, graphicsDevice_.Viewport.Height - height); _startPosition = new Vector2(0, graphicsDevice_.Viewport.Height - height); _displaySize = new Vector2(width, height); _buttonSize = new Vector2(30, height * 0.8f); Log.Info("CitySim", "HUD created."); Log.Info("CitySim", $"HUD Size: {_displaySize}"); Log.Info("CitySim", $"HUD Pos: {_position}"); _content = content_; _font = _content.GetFont(1); HUDIconIDs = new int[] { 5, 6, 7, 8, 12, 9, 10, 11 }; SetColorData(graphicsDevice_); DisplayInfo_Texture = content_.GetUiTexture(37); for (int i = (int)SelectionCells_BuildingIndexes.X; i < SelectionCells_BuildingIndexes.Y; i++) { SelectionCells_BuildingTextures.Add(content_.GetUiTexture(i)); } SelectionCells_BuildingTextures.Add(content_.GetUiTexture(24)); SelectionCells_BuildingTextures.Add(content_.GetUiTexture(25)); if (SelectionCells_BuildingTextures.Count < (SelectionCell_GridDimensions.X * SelectionCell_GridDimensions.Y)) { var dif = (SelectionCell_GridDimensions.X * SelectionCell_GridDimensions.Y) - SelectionCells_BuildingTextures.Count; for (int i = 0; i < dif + 1; i++) { SelectionCells_BuildingTextures.Add(SelectionCells_BuildingTextures[0]); } } SelectionCell_BlankTexture = content_.GetUiTexture(13); foreach (var e in SelectionCells_BldgHouses_Indexes) { SelectionCells_BldgHouses_Textures.Add(content_.GetUiTexture(e)); } foreach (var e in SelectionCells_BldgReso_Indexes) { SelectionCells_BldgReso_Textures.Add(content_.GetUiTexture(e)); } foreach (var e in SelectionCells_BldgDeco_Indexes) { SelectionCells_BldgDeco_Textures.Add(content_.GetUiTexture(e)); } foreach (var e in SelectionCells_AllBldgs_Textures) { if (e.Count < (SelectionCell_GridDimensions.X * SelectionCell_GridDimensions.Y)) { var dif = (SelectionCell_GridDimensions.X * SelectionCell_GridDimensions.Y) - e.Count; for (int i = 0; i < dif + 1; i++) { e.Add(SelectionCell_BlankTexture); } } } SetSelectionCellButtons(); // get textures for buttons that swap between building selections Btn_SelectHouses_Texture = content_.GetUiTexture(26); Btn_SelectReso_Texture = content_.GetUiTexture(27); Btn_SelectDeco_Texture = content_.GetUiTexture(28); Btn_HideHUD_Texture = content_.GetUiTexture(40); var init_btn_bldg_pos = new Vector2(); init_btn_bldg_pos.X = _displaySize.X - ((Btn_SelectHouses_Texture.Width * 5) * 4) - 10; init_btn_bldg_pos.Y = DisplayRect.Y - (Btn_SelectHouses_Texture.Height * 5) - 10; Btn_SelectHouses = new Button(Btn_SelectHouses_Texture, _font) { Position = init_btn_bldg_pos, ID = 800, }; Btn_SelectHouses.CustomRect = new Rectangle( (int)Btn_SelectHouses.Position.X, (int)Btn_SelectHouses.Position.Y, Btn_SelectHouses_Texture.Width * 5, Btn_SelectHouses_Texture.Height * 5 ); Btn_SelectHouses.Click += ViewBldgsBtn_OnClick; Btn_SelectReso = new Button(Btn_SelectReso_Texture, _font) { Position = init_btn_bldg_pos + new Vector2(Btn_SelectHouses_Texture.Width * 5f, 0), ID = 801, }; Btn_SelectReso.CustomRect = new Rectangle( (int)Btn_SelectReso.Position.X, (int)Btn_SelectReso.Position.Y, Btn_SelectHouses_Texture.Width * 5, Btn_SelectHouses_Texture.Height * 5 ); Btn_SelectReso.Click += ViewBldgsBtn_OnClick; Btn_SelectDeco = new Button(Btn_SelectDeco_Texture, _font) { Position = init_btn_bldg_pos + new Vector2(((Btn_SelectHouses_Texture.Width * 5f) * 2f), 0), ID = 802, }; Btn_SelectDeco.CustomRect = new Rectangle( (int)Btn_SelectDeco.Position.X, (int)Btn_SelectDeco.Position.Y, Btn_SelectHouses_Texture.Width * 5, Btn_SelectHouses_Texture.Height * 5 ); Btn_SelectDeco.Click += ViewBldgsBtn_OnClick; _closeMenuButton = new Button(Btn_HideHUD_Texture, _font) { Position = init_btn_bldg_pos + new Vector2(((Btn_SelectHouses_Texture.Width * 5f) * 3f), 0), ID = 803, IsFlippedVert = true }; _closeMenuButton.CustomRect = new Rectangle( (int)_closeMenuButton.Position.X, (int)_closeMenuButton.Position.Y, Btn_SelectHouses_Texture.Width * 5, Btn_SelectHouses_Texture.Height * 5 ); _closeMenuButton.Click += Btn_hide_hud_Click; BtnList_SelectBldgsView.Add(Btn_SelectHouses); BtnList_SelectBldgsView.Add(Btn_SelectReso); BtnList_SelectBldgsView.Add(Btn_SelectDeco); DeleteBuildingBtn_Texture = content_.GetUiTexture(23); DeleteBuildingBtn_Pos = new Vector2( (int)(DisplayInfo_Rectangle.X + DisplayInfo_Rectangle.Width - DeleteBuildingBtn_Texture.Width - ((DisplayInfo_Rectangle.Width * 0.05f) / 2)), (int)(DisplayInfo_Rectangle.Y + (DisplayInfo_Rectangle.Height * 0.05f))); DeleteBuildingBtn = new Button(content_.GetUiTexture(23), _font) { Position = DeleteBuildingBtn_Pos, HoverColor = Color.Red }; DeleteBuildingBtn.Click += DeleteBuildingBtnOnClick; }