internal void LoadGame(SaveGame save)
 {
     MenuState             = 1;
     GameTime              = save.GameTime;
     _map                  = save.Map;
     _resourcesManager     = save.ResourcesManager;
     _resourcesManager.Map = _map;
     _experienceManager    = save.ExperienceManager;
     _name                 = save.Name;
     _drawUI               = new DrawUI(this, _map, 100, 100, _resolution, GameTime, _resourcesManager, _experienceManager);
 }
 internal void StartNewGame()
 {
     if (_newGame.Name != "" && _newGame.Name != null)
     {
         _name              = _newGame.Name;
         _newGame.Name      = "";
         MenuState          = 1;
         _map               = new Map(100, 100);
         _resourcesManager  = new ResourcesManager(_map);
         _experienceManager = new ExperienceManager(_resourcesManager);
         _drawUI            = new DrawUI(this, _map, 100, 100, _resolution, GameTime, _resourcesManager, _experienceManager);
     }
 }
        //Building _building;

        public MapUI(Game context, Map ctx, uint width, uint height, DrawUI drawUI, UI ui, Resolution resolution, ResourcesManager resourcesManager)
        {
            _gameCtx = context;
            _ctx = ctx;
            _drawUIctx = drawUI;
            _width = width;
            _height = height;
            _drawBuildings = new DrawBuildings(_gameCtx,ui, ctx);
            _ui = ui;
            _resolution = resolution;
            _x2y2 = new Vector2f((width + 1) * 32, (height + 1) * 32);
            _resourcesManager = resourcesManager;
            _cases = new Case[Width * Height];
        }
Exemple #4
0
        public UI(Game ctx, Resolution resolution, Map context, DrawUI drawUI, uint width, uint height, GameTime gameTime, ResourcesManager resourcesManager, ExperienceManager experienceManager)
        {
            _sprites             = new Dictionary <Sprite, string>();
            _buildingTypeSprites = new Dictionary <Sprite, BuildingType>();
            _tab1Sprite          = new Dictionary <Sprite, BuildingType>();
            _tab2Sprite          = new Dictionary <Sprite, BuildingType>();
            _tab3Sprite          = new Dictionary <Sprite, BuildingType>();

            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("fr-FR");
            _ctx               = ctx;
            _drawUIctx         = drawUI;
            _mapCtx            = context;
            _height            = height;
            _width             = width;
            _resolution        = resolution;
            _drawUIctx         = drawUI;
            _buildSelected     = false;
            _gameTime          = gameTime;
            _buildingChoices   = new BuildingChoice[16];
            _resourcesManager  = resourcesManager;
            _tab1Selected      = true;
            _tab2Selected      = false;
            _tab3Selected      = false;
            _experienceManager = experienceManager;

            //TIME BAR
            _play = new Sprite(_ctx._uiTextures[18])
            {
                Position = new Vector2f(_resolution.X / 2, _resolution.Y - 30),
                Scale    = new Vector2f(0.8f, 0.8f)
            };

            _pause = new Sprite(_ctx._uiTextures[17])
            {
                Position = new Vector2f(_resolution.X / 2 - 34, _resolution.Y - 30),
                Scale    = new Vector2f(0.8f, 0.8f)
            };

            _fastForward = new Sprite(_ctx._uiTextures[16])
            {
                Position = new Vector2f(_resolution.X / 2 + 32, _resolution.Y - _boxSize + 3),
                Scale    = new Vector2f(0.8f, 0.8f)
            };

            _rectangleTimeBar = new RectangleShape()
            {
                FillColor = Color.Transparent,
                Size      = new Vector2f(_resolution.X - _boxSize * 4 + 10, _boxSize),
                Position  = new Vector2f(0, _resolution.Y - _boxSize)
            };

            //UI BUTTONS
            _buildButton = new Sprite(_ctx._uiTextures[3])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 3, _resolution.Y / 2 + _boxSize * 2)
            };

            _destroyButton = new Sprite(_ctx._uiTextures[20])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 3, _resolution.Y / 2 + _boxSize * 5),
                //Scale = new Vector2f(0.5f, 0.5f)
            };
            _settingsButton = new Sprite(_ctx._uiTextures[21])
            {
                Scale = new Vector2f(0.8f, 0.8f)
            };
            _exitButton = new Sprite(_ctx._uiTextures[22]);

            _saveButton = new Sprite(_ctx._menuTextures[2])
            {
                Position = new Vector2f(_resolution.X / 2 - _boxSize * 7, _boxSize * 2),
                Scale    = new Vector2f(0.5f, 0.5f)
            };
            _menu[0] = _saveButton;

            _saveButtonActive = new Sprite(_ctx._menuTextures[7])
            {
                Position = new Vector2f(_resolution.X / 2 - _boxSize * 7, _boxSize * 2),
                Scale    = new Vector2f(0.5f, 0.5f)
            };
            _menuActif[0] = _saveButtonActive;

            _returnButton = new Sprite(_ctx._menuTextures[4])
            {
                Position = new Vector2f(_resolution.X / 2 - _boxSize * 7, _boxSize * 8),
                Scale    = new Vector2f(0.5f, 0.5f)
            };
            _menu[1] = _returnButton;

            _returnButtonActive = new Sprite(_ctx._menuTextures[9])
            {
                Position = new Vector2f(_resolution.X / 2 - _boxSize * 7, _boxSize * 8),
                Scale    = new Vector2f(0.5f, 0.5f)
            };
            _menuActif[1] = _returnButtonActive;

            _quitButton = new Sprite(_ctx._menuTextures[3])
            {
                Position = new Vector2f(_resolution.X / 2 - _boxSize * 7, _boxSize * 14),
                Scale    = new Vector2f(0.5f, 0.5f)
            };
            _menu[2] = _quitButton;

            _quitButtonActive = new Sprite(_ctx._menuTextures[8])
            {
                Position = new Vector2f(_resolution.X / 2 - _boxSize * 7, _boxSize * 14),
                Scale    = new Vector2f(0.5f, 0.5f)
            };
            _menuActif[2] = _quitButtonActive;

            //XP BAR
            _expBar = new RectangleShape()
            {
                Size     = new Vector2f(200, 30),
                Position = new Vector2f(resolution.X - 204, resolution.Y - _boxSize)
            };

            _expBarFilled = new RectangleShape(_expBar)
            {
                FillColor = Color.Blue
            };

            //RESOURCES
            _coinSprite = new Sprite(_ctx._uiTextures[5])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 4 + 5, _boxSize * 3),
                Scale    = new Vector2f(0.8f, 0.8f)
            };

            _woodSprite = new Sprite(_ctx._uiTextures[7])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 4 + 5, _boxSize * 4),
                Scale    = new Vector2f(0.8f, 0.8f)
            };

            _rockSprite = new Sprite(_ctx._uiTextures[9])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 4 + 5, _boxSize * 5),
                Scale    = new Vector2f(0.8f, 0.8f)
            };

            _metalSprite = new Sprite(_ctx._uiTextures[8])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 4 + 5, _boxSize * 6),
                Scale    = new Vector2f(0.8f, 0.8f)
            };

            _electricitySprite = new Sprite(_ctx._uiTextures[11])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 4 + 5, _boxSize * 7),
                Scale    = new Vector2f(0.8f, 0.8f)
            };

            _waterSprite = new Sprite(_ctx._uiTextures[10])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 4 + 5, _boxSize * 8),
                Scale    = new Vector2f(0.8f, 0.8f)
            };

            _pollutionSprite = new Sprite(_ctx._uiTextures[6])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 4 + 5, _boxSize * 9),
                Scale    = new Vector2f(0.8f, 0.8f)
            };

            _people = new Sprite(_ctx._uiTextures[23])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 3, _boxSize * 10)
            };

            _angrySprite    = new Sprite(_ctx._uiTextures[12]);
            _smileSprite    = new Sprite(_ctx._uiTextures[14]);
            _confusedSprite = new Sprite(_ctx._uiTextures[13]);
            _navbarSprite   = new Sprite(_ctx._uiTextures[15]);

            //HABITATIONS
            _flatSprite = new Sprite(_ctx._buildingsTextures[2])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 6, _resolution.Y / 2),
                Scale    = new Vector2f(0.5f, 0.5f)
            };

            _hutSprite = new Sprite(_ctx._buildingsTextures[1])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 10, _resolution.Y / 2)
            };


            _houseSprite = new Sprite(_ctx._buildingsTextures[3])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 8, _resolution.Y / 2)
            };

            //PUBLIC BUILDINGS
            _cityHall = new Sprite(_ctx._buildingsTextures[6])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 2, _resolution.Y / 2)
            };

            _fireStation = new Sprite(_ctx._buildingsTextures[8])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 4, _resolution.Y / 2)
            };

            _hospital = new Sprite(_ctx._buildingsTextures[9])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 6, _resolution.Y / 2)
            };

            _police = new Sprite(_ctx._buildingsTextures[10])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 8, _resolution.Y / 2)
            };

            _warehouse = new Sprite(_ctx._buildingsTextures[15])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 12, _resolution.Y / 2)
            };

            _spaceStation = new Sprite(_ctx._buildingsTextures[11])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 10, _resolution.Y / 2)
            };

            //RESOURCES BUILDINGS
            _powerPlant = new Sprite(_ctx._buildingsTextures[4])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 10, _resolution.Y / 2)
            };

            _pumpingStation = new Sprite(_ctx._buildingsTextures[5])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 8, _resolution.Y / 2)
            };

            _sawMill = new Sprite(_ctx._buildingsTextures[12])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 6, _resolution.Y / 2)
            };

            _oreMine = new Sprite(_ctx._buildingsTextures[13])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 4, _resolution.Y / 2)
            };

            _metalMine = new Sprite(_ctx._buildingsTextures[14])
            {
                Position = new Vector2f(_resolution.X - _boxSize * 2, _resolution.Y / 2)
            };

            _tab1Sprite.Add(_hutSprite, _mapCtx.BuildingTypes[5]);
            _tab1Sprite.Add(_houseSprite, _mapCtx.BuildingTypes[4]);
            _tab1Sprite.Add(_flatSprite, _mapCtx.BuildingTypes[2]);

            _tab2Sprite.Add(_cityHall, _mapCtx.BuildingTypes[0]);
            _tab2Sprite.Add(_fireStation, _mapCtx.BuildingTypes[1]);
            _tab2Sprite.Add(_hospital, _mapCtx.BuildingTypes[3]);
            _tab2Sprite.Add(_police, _mapCtx.BuildingTypes[8]);
            _tab2Sprite.Add(_spaceStation, _mapCtx.BuildingTypes[12]);
            _tab2Sprite.Add(_warehouse, _mapCtx.BuildingTypes[13]);

            _tab3Sprite.Add(_sawMill, _mapCtx.BuildingTypes[11]);
            _tab3Sprite.Add(_oreMine, _mapCtx.BuildingTypes[7]);
            _tab3Sprite.Add(_powerPlant, _mapCtx.BuildingTypes[9]);
            _tab3Sprite.Add(_metalMine, _mapCtx.BuildingTypes[6]);
            _tab3Sprite.Add(_pumpingStation, _mapCtx.BuildingTypes[10]);

            _mouseSprite = new Sprite();
        }