protected override void LoadContent() { GameRef.IsMouseVisible = true; base.LoadContent(); var _backgroundImage = GameGraphics.GetTexture("title_screen_bg").SourceTexture; _background = new PictureBox(_backgroundImage, GameRef.ScreenRectangle); var _seperatorImage = GameGraphics.GetTexture("seperator").SourceTexture; _seperator = new PictureBox(_seperatorImage, new Rectangle(0, 0, _seperatorImage.Width, _seperatorImage.Height)); _startLabel = new LinkLabel(); _startLabel.Text = "Start Menu"; _startLabel.TabStop = true; _startLabel.HasFocus = true; _startLabel.LeftIndexer = true; _startLabel.Hover += new EventHandler(_startLabel_Hover); _startLabel.Click += new EventHandler(startLabel_Selected); UpdateLayout(); _startLabel.Selected += new EventHandler(startLabel_Selected); ControlManager.Add(_startLabel); }
public GameWorld(ControlManager controlManagerRef) { ControlManagerRef = controlManagerRef; Map = new TileMap(200, 400); MainPlayer = new GamePlayer(this); MainPlayer.Name = "Osama Abulail"; int cloudsCount = (Map.MapWidth*Map.MapHeight)/(20*20); CloudManager = new CloudManager(Map, cloudsCount, CloudDirection.West, 0.5f); MovementManager = new UnitMovementManager(this); SelectionManager = new UnitSelectionManager(this); DockManager = new DockManager(ControlManagerRef); UpperStatusBar = new UpperStatusBar(new Vector2(10, 0), MainPlayer, ControlManagerRef); _trees = new List<Tree>(); // generate random trees. Random r = new Random(); for (int i = 0; i < 4000; i++) { Point treeLoc = new Point(r.Next(0,Map.MapWidth), r.Next(0,Map.MapHeight)); if (Map.MapCellAt(treeLoc).Walkable) { Tree t = new Tree("tree" + r.Next(1, 26), this, treeLoc); _trees.Add(t); } } // border _border = new PictureBox(GameGraphics.GetTexture("gameplay_border").SourceTexture, new Rectangle(0, 0, 1366, 768)); ControlManagerRef.Add(_border); }
protected override void LoadContent() { GameRef.IsMouseVisible = true; base.LoadContent(); var backgroundImage = GameRef.Content.Load<Texture2D>(@"Backgrounds\dialog"); _background = new PictureBox(backgroundImage, GameRef.ScreenRectangle); ControlManager.Add(_background); Label pause = new Label(); pause.Text = "Game Paused"; pause.SetPosition ( new Vector2( (GameRef.ScreenWidth-ControlManager.SpriteFont.MeasureString(pause.Text).X)/2f+16, 350) ); ControlManager.Add(pause); }
public SwitchBox(string caption, List<string> menuItems ) { // set position initially to zero. var la = GameGraphics.GetTexture("left_arrow").SourceTexture; _leftArrow = new PictureBox(la, new Rectangle(0, 0, la.Width, la.Height)); var ra = GameGraphics.GetTexture("right_arrow").SourceTexture; _rightArrow = new PictureBox(ra, new Rectangle(0, 0, ra.Width, ra.Height)); _arrowWidth = ra.Width; // or la _arrowHeight = ra.Height; SetMenuItems(menuItems); _currentItem = 0; Caption = caption; HasFocus = false; TabStop = true; Indexer = true; SetPosition(Vector2.Zero); }
/// <summary> /// Automatically sets the positions of the SwitchBox visual components /// </summary> /// <param name="position"></param> public override void SetPosition(Vector2 position) { Position = position; _leftArrow.SetPosition(new Vector2(position.X + CaptionMaxWidth, position.Y+5)); _rightArrow.SetPosition(new Vector2(position.X + CaptionMaxWidth + _arrowWidth + MenuMaxWidth, position.Y+5)); var indexerTexture = GameGraphics.GetTexture("left_indexer").SourceTexture; var indexerXPosition = Position.X - indexerTexture.Width - 18; // some offset var indexerYPosition = Position.Y + 3; var indexerPosition = new Vector2(indexerXPosition, indexerYPosition); _indexer = new PictureBox(indexerTexture, new Rectangle(0, 0, indexerTexture.Width, indexerTexture.Height)); _indexer.SetPosition(indexerPosition); _leftArrowButtonArea = _leftArrow.DestinationRectangle; _rightArrowButtonArea = _rightArrow.DestinationRectangle; }
protected override void LoadContent() { base.LoadContent(); _backgroundImage = new PictureBox(GameGraphics.GetTexture("bg").SourceTexture, GameRef.ScreenRectangle); ControlManager.Add(_backgroundImage); _pageTitle = new Label(); _pageTitle.Text = "General Game Options.."; ControlManager.Add(_pageTitle); _resolution = new SwitchBox("Resolution", new List<string> { "720p", "1080p" }); _resolution.ItemChanged += new EventHandler(_resolution_ItemChanged); _resolution.Hover += new EventHandler(Hover); ControlManager.Add(_resolution); _viewMode = new SwitchBox("View Mode", new List<string> { "Window", "Full Screen" }); _viewMode.ItemChanged += new EventHandler(_viewMode_ItemChanged); _viewMode.Hover +=new EventHandler(Hover); ControlManager.Add(_viewMode); var volumes = new List<string>(); for (int i = 0; i < 105; i += 5) volumes.Add(i.ToString()); volumes.Reverse(); _volume = new SwitchBox("Audio Volume", volumes); _volume.ItemChanged += new EventHandler(_volume_ItemChanged); _volume.Hover += new EventHandler(Hover); ControlManager.Add(_volume); _music = new SwitchBox("Gameplay Music", new List<string> { "On", "Off" }); _music.ItemChanged += new EventHandler(_music_ItemChanged); _music.Hover += new EventHandler(Hover); ControlManager.Add(_music); _soundEffects = new SwitchBox("Sound Effects", new List<string> { "On", "Off" }); _soundEffects.ItemChanged += new EventHandler(_soundEffects_ItemChanged); _soundEffects.Hover += new EventHandler(Hover); ControlManager.Add(_soundEffects); _back = new LinkLabel(); _back.Text = "Back to Main Menu"; _back.Size = _back.SpriteFont.MeasureString(_back.Text); _back.Selected += new EventHandler(_back_Selected); _back.Click += new EventHandler(_back_Selected); _back.Hover += new EventHandler(Hover); ControlManager.Add(_back); UpdateLayout(); ControlManager.NextControl(); ControlManager.FocusChanged += new EventHandler(ControlManager_FocusChanged); }
public override void SetPosition(Vector2 position) { Position = position; var LIndexerTexture = GameGraphics.GetTexture("left_indexer").SourceTexture; var RIndexerTexture = GameGraphics.GetTexture("right_indexer").SourceTexture; // setting left indexer var indexerXPosition = Position.X - LIndexerTexture.Width - 18; // some offset var indexerYPosition = Position.Y -3; var indexerPosition = new Vector2(indexerXPosition, indexerYPosition); _leftIndexerPic = new PictureBox(LIndexerTexture, new Rectangle(0, 0, LIndexerTexture.Width, LIndexerTexture.Height)); _leftIndexerPic.SetPosition(indexerPosition); // setting right indexer indexerXPosition = Position.X + SpriteFont.MeasureString(Text).X + 18; indexerPosition = new Vector2(indexerXPosition, indexerYPosition); _rightIndexerPic = new PictureBox(RIndexerTexture, new Rectangle(0, 0, RIndexerTexture.Width, RIndexerTexture.Height)); _rightIndexerPic.SetPosition(indexerPosition); _leftIndexerPic.Fading = true; _rightIndexerPic.Fading = true; }
protected override void LoadContent() { base.LoadContent(); _backgroundImage = new PictureBox(GameGraphics.GetTexture("bg").SourceTexture, GameRef.ScreenRectangle); ControlManager.Add(_backgroundImage); _newGame = new LinkLabel(); _newGame.Text = "Start a New Game"; _newGame.Size = _newGame.SpriteFont.MeasureString(_newGame.Text); _newGame.Selected += new EventHandler(menuItem_Selected); _newGame.Click += new EventHandler(menuItem_Selected); _newGame.Hover += new EventHandler(LinkLabel_Hover); ControlManager.Add(_newGame); _loadGame = new LinkLabel(); _loadGame.Text = "Load Saved Games.."; _loadGame.Size = _loadGame.SpriteFont.MeasureString(_loadGame.Text); _loadGame.Selected += new EventHandler(menuItem_Selected); _loadGame.Hover += new EventHandler(LinkLabel_Hover); _loadGame.Click += new EventHandler(menuItem_Selected); ControlManager.Add(_loadGame); _options = new LinkLabel(); _options.Text = "General Options"; _options.Size = _options.SpriteFont.MeasureString(_options.Text); _options.Selected += menuItem_Selected; _options.Hover += new EventHandler(LinkLabel_Hover); _options.Click += new EventHandler(menuItem_Selected); ControlManager.Add(_options); _editMap = new LinkLabel(); _editMap.Text = "Edit Custom Senario.."; _editMap.Size = _editMap.SpriteFont.MeasureString(_editMap.Text); _editMap.Selected += menuItem_Selected; _editMap.Hover += new EventHandler(LinkLabel_Hover); _editMap.Click += new EventHandler(menuItem_Selected); ControlManager.Add(_editMap); _multiplayer = new LinkLabel(); _multiplayer.Text = "Multiplayer Game"; _multiplayer.Size = _multiplayer.SpriteFont.MeasureString(_multiplayer.Text); _multiplayer.Selected += menuItem_Selected; _multiplayer.Hover += new EventHandler(LinkLabel_Hover); _multiplayer.Click += new EventHandler(menuItem_Selected); ControlManager.Add(_multiplayer); _back = new LinkLabel(); _back.Text = "To Title Screen"; _back.Size = _back.SpriteFont.MeasureString(_back.Text); _back.Selected += menuItem_Selected; _back.Hover += new EventHandler(LinkLabel_Hover); _back.Click += new EventHandler(menuItem_Selected); ControlManager.Add(_back); _exit = new LinkLabel(); _exit.Text = "Exit to Windows"; _exit.Size = _exit.SpriteFont.MeasureString(_exit.Text); _exit.Selected += menuItem_Selected; _exit.Hover += new EventHandler(LinkLabel_Hover); _exit.Click += new EventHandler(menuItem_Selected); ControlManager.Add(_exit); ControlManager.NextControl(); ControlManager.FocusChanged += new EventHandler(ControlManager_FocusChanged); UpdateLayout(); ControlManager_FocusChanged(_newGame, null); }
protected override void LoadContent() { base.LoadContent(); _backgroundImage = new PictureBox(GameGraphics.GetTexture("bg").SourceTexture, GameRef.ScreenRectangle); ControlManager.Add(_backgroundImage); _pageTitle = new Label(); _pageTitle.Text = "New Game Settings.."; ControlManager.Add(_pageTitle); _resources = new SwitchBox("Player Resources", new List<string>() { "High", "Normal", "Low" }); _resources.ItemChanged +=new EventHandler(_resources_ItemChanged); _resources.Hover+=new EventHandler(Hover); ControlManager.Add(_resources); _population = new SwitchBox("Max Population", new List<string>() { "50", "100", "150", "200", "500" }); _population.ItemChanged +=new EventHandler(_population_ItemChanged); _population.Hover += new EventHandler(Hover); ControlManager.Add(_population); _mapSize = new SwitchBox("Map Size", new List<string>() { "Small", "Normal" ,"Large" }); _mapSize.ItemChanged +=new EventHandler(_mapSize_ItemChanged); _mapSize.Hover += new EventHandler(Hover); ControlManager.Add(_mapSize); _mapStyle = new SwitchBox("Map Terrain Style", new List<string>() { "Spring", "Desert" ,"Forest" }); _mapStyle.ItemChanged +=new EventHandler(_mapStyle_ItemChanged); _mapStyle.Hover += new EventHandler(Hover); ControlManager.Add(_mapStyle); _allowCheats = new SwitchBox("Allow Cheats", new List<string>() { "Yes", "No" }); _allowCheats.ItemChanged +=new EventHandler(_allowCheats_ItemChanged); _allowCheats.Hover += new EventHandler(Hover); ControlManager.Add(_allowCheats); _startGame = new LinkLabel(); _startGame.Text = "Start Game"; _startGame.Size = _startGame.SpriteFont.MeasureString(_startGame.Text); _startGame.Selected += new EventHandler(_startGame_Selected); _startGame.Click += new EventHandler(_startGame_Selected); _startGame.Hover += new EventHandler(Hover); ControlManager.Add(_startGame); _back = new LinkLabel(); _back.Text = "Back to Main Menu"; _back.Size = _back.SpriteFont.MeasureString(_back.Text); _back.Selected += new EventHandler(_back_Selected); _back.Click += new EventHandler(_back_Selected); _back.Hover += new EventHandler(Hover); ControlManager.Add(_back); ControlManager.NextControl(); ControlManager.FocusChanged += new EventHandler(ControlManager_FocusChanged); UpdateLayout(); ControlManager_FocusChanged(_resources, null); }