Beispiel #1
0
        private void DrawMap(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            base.Draw(gameTime);

            //How many Tiles are possible to render ?
            decimal showxTiles = Convert.ToDecimal(GraphicsDevice.Viewport.Width) / _status.ZoomFactor;
            decimal showyTiles = Convert.ToDecimal(GraphicsDevice.Viewport.Height) / _status.ZoomFactor;

            for (decimal y = 0; y < showyTiles; y++)
            {
                for (decimal x = 0; x < showxTiles; x++)
                {
                    int xpos = Convert.ToInt32(x * _status.ZoomFactor);
                    int ypos = Convert.ToInt32(y * _status.ZoomFactor);

                    //what is the current Map Position ?
                    MapPosition pos = _status.Map.MapPositions.Find(o => o.XPos == x + _status.MapPosition.X && o.YPos == y + _status.MapPosition.Y);

                    try
                    {
                        if (pos != null)
                        {
                            //draw corresponding textures
                            _spriteBatch.Draw(_textures[pos.TID], new Vector2(xpos + CONSTANTS.XSPACE, ypos + CONSTANTS.YSPACE), Color.White);

                            //is an Object on The Map
                            City cit = _cities.Find(o => o.MapPosition.XPos == pos.XPos && o.MapPosition.YPos == pos.YPos);
                            if (cit != null)
                            {
                                _spriteBatch.Draw(_textures[CONSTANTS.TXT_CITY], new Vector2(xpos + CONSTANTS.XSPACE, ypos + CONSTANTS.YSPACE), Color.White);
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin();

            if (_intro.Showintro)
            {
                _intro.DrawIntro(_spriteBatch);
            }
            else
            {
                _spriteBatch.Draw(_textures[CONSTANTS.TXT_YEAR_MENU], new Vector2(0, 0), Color.White);
                _spriteBatch.DrawString(_status.Font, "Year:" + _round.ToString(), new Vector2(10, 15), Color.Red);

                DrawMap(gameTime);


                if (_showcityMenu && _activeCity != null)
                {
                    _cityMenu.DrawCityMenu(_spriteBatch, _activeCity);
                    _showcityMenu = _cityMenu.ShowCityMenu();
                }



                Microsoft.Xna.Framework.Input.ButtonState state = Mouse.GetState().RightButton;
                if (state == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
                {
                    MapPosition pos = _mouse.GetMouseMapPosition(_status);
                    if (pos != null)
                    {
                        this.Window.Title = "Pressed" + pos.TID + "POS X" + pos.XPos + ".POS Y" + pos.YPos;

                        City cit = _cities.Find(o => o.MapPosition.XPos == pos.XPos && o.MapPosition.YPos == pos.YPos);
                        if (cit != null)
                        {
                            this.Window.Title = cit.Name;
                            _activeCity       = cit;
                            _showcityMenu     = true;
                        }
                    }
                }

                state = Mouse.GetState().LeftButton;

                if (state == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
                {
                    if (Menu.MenuIspressed() == true && !_counterprotect)
                    {
                        //todo Protect Counting up with - mouse State Year Combination
                        _round++;
                        _counterprotect = true;
                    }
                }


                //prevent Years from Counting UP
                if (state == Microsoft.Xna.Framework.Input.ButtonState.Released)
                {
                    _counterprotect = false;
                }


                _mouse.DrawTheMouse(_spriteBatch, GraphicsDevice, _status);
            }

            _spriteBatch.End();
        }