Example #1
0
 public ScreenItem(Game game, ApplicationSkin applicationSkin, float x, float y, float width, float height)
     : base(game)
 {
     _position = new Vector2(x, y);
     _size = new Vector2(width, height);
     skin = applicationSkin;
 }
 public ScreenItemNewNotice(Game game, ApplicationSkin skin, int x, int y, Vector2 travelDirection,
     Vector2 travelBounds)
     : base(game, skin, x, y, "New")
 {
     this.travelBounds = travelBounds;
     this.travelDirection = travelDirection;
     this.initialLocation = new Vector2(x, y);
     moving = true;
 }
Example #3
0
 public MessageWindow(ApplicationSkin applicationSkin, string dialogCaption, string title)
 {
     Title = title;
     graphics = new GraphicsDeviceManager(this);
     skin = applicationSkin;
     usingSkin = (skin != null);
     caption = dialogCaption;
     Content.RootDirectory = "Content";
 }
 public static void DrawTileShadow(this SpriteBatch spriteBatch, Vector2 screenPosition, ApplicationSkin skin)
 {
     Vector2[] vertice = new Vector2[4];
     vertice[0] = screenPosition;
     vertice[1] = screenPosition + new Vector2(-GlobalSettings.TileWidth / 2, GlobalSettings.TileHeight / 2);
     vertice[2] = screenPosition + new Vector2(0, GlobalSettings.TileHeight);
     vertice[3] = screenPosition + new Vector2(GlobalSettings.TileWidth / 2, GlobalSettings.TileHeight / 2);
     Rectangle tileRectangle = new Rectangle((int)vertice[1].X,
         (int)vertice[0].Y, GlobalSettings.TileWidth, GlobalSettings.TileHeight);
     spriteBatch.Draw(skin.Graphics["BlankTile"], tileRectangle, new Color(70, 70, 70));
 }
        public static void DrawTile(this SpriteBatch spriteBatch, Tile tile, Map map, 
            Vector2 screenPosition, ApplicationSkin skin, Color tinting)
        {
            Vector2[] vertice = new Vector2[4];
            vertice[0] = screenPosition;
            vertice[1] = screenPosition + new Vector2(-GlobalSettings.TileWidth / 2, GlobalSettings.TileHeight / 2);
            vertice[2] = screenPosition + new Vector2(0, GlobalSettings.TileHeight);
            vertice[3] = screenPosition + new Vector2(GlobalSettings.TileWidth / 2, GlobalSettings.TileHeight / 2);

            Color overlayColor = tinting;
            if (map.PlacingBuilding)
            {
                if (map.BuildingPlacementInfo.TopTilePlacementLocation.X <= tile.X &&
                    map.BuildingPlacementInfo.TopTilePlacementLocation.X + map.BuildingPlacementInfo.Height > tile.X &&
                    map.BuildingPlacementInfo.TopTilePlacementLocation.Y <= tile.Y &&
                    map.BuildingPlacementInfo.TopTilePlacementLocation.Y + map.BuildingPlacementInfo.Width > tile.Y)
                    overlayColor = (map.BuildingPlacementInfo.CanPlace ? Color.Green : Color.Red);
                else
                    overlayColor = ((map.BuildingPlacementInfo.Building.ValidTerrainTypes & tile.TerrainType) ==
                        tile.TerrainType && tile.IsBuildable ? Color.PaleGreen : new Color(255, 200, 200));
            }
            else if (tile.HasHover)
                    overlayColor = Color.Yellow;

            Rectangle tileRectangle = new Rectangle((int)vertice[1].X,
                (int)vertice[0].Y, GlobalSettings.TileWidth, GlobalSettings.TileHeight);
            spriteBatch.Draw(skin.Graphics[tile.TerrainType.ToString()], tileRectangle, tinting);

            spriteBatch.DrawLine(vertice[0], vertice[3], Color.LightGray);
            spriteBatch.DrawLine(vertice[3], vertice[2], Color.LightGray);
            if (tile.X == map.Height - 1)
                spriteBatch.DrawLine(vertice[2], vertice[1], Color.LightGray);
            if (tile.Y == 0)
                spriteBatch.DrawLine(vertice[1], vertice[0], Color.LightGray);

            if (tile.Building != null)
                spriteBatch.Draw(tile.Building.Textures[tile.BuildingPieceHere],
                    new Vector2(vertice[1].X, (int)vertice[0].Y -
                    (tile.Building.Textures[tile.BuildingPieceHere].Texture.Height - GlobalSettings.TileHeight)),
                    tinting);
            if (!overlayColor.Equals(tinting))
                spriteBatch.Draw(skin.Graphics["BlankTile"], tileRectangle, new Color(overlayColor, 150));

            if (tile.HasHover)//centerTile == tile.Location || tile.HasHover)
                spriteBatch.DrawString(tile.X.ToString() + ", " + tile.Y.ToString(),
                    screenPosition, Color.Black);
        }
Example #6
0
 public ScreenItem(Game game, ApplicationSkin applicationSkin, int x, int y, int width, int height)
     : this(game, applicationSkin, (float)x, (float)y, (float)width, (float)height)
 {
 }
Example #7
0
        public void Initialize(Game game, ApplicationSkin applicationSkin, PlayerGame playerGame)
        {
            interfaceBlocks = new Rectangle[3];
            interfaceBlocks[0] = new Rectangle(0, 0, 144, 568);
            interfaceBlocks[1] = new Rectangle(0, 568, 1050, 133);
            interfaceBlocks[2] = new Rectangle(877, 376, 173, 192);

            _playerGame = playerGame;
            _playerGame.UrbanMap.TileClicked += new Map.TileClickedHandler(TileClicked);
            _playerGame.UrbanMap.BuildingPlacementBegan += new BuildingPlacementBeganHandler(BuildingPlacementBegins);
            _playerGame.UrbanMap.BuildingPlacementFinished += new BuildingPlacementFinishedHandler(BuildingPlacementEnds);
            _playerGame.UrbanMap.BuildingSelected += new BuildingSelectedHandler(BuildingSelected);
            _playerGame.CountryMap.TileClicked += new Map.TileClickedHandler(TileClicked);
            _playerGame.CountryMap.BuildingPlacementBegan += new BuildingPlacementBeganHandler(BuildingPlacementBegins);
            _playerGame.CountryMap.BuildingPlacementFinished += new BuildingPlacementFinishedHandler(BuildingPlacementEnds);
            _playerGame.CountryMap.BuildingSelected += new BuildingSelectedHandler(BuildingSelected);
            _playerGame.OceanMap.TileClicked += new Map.TileClickedHandler(TileClicked);
            _playerGame.OceanMap.BuildingPlacementBegan += new BuildingPlacementBeganHandler(BuildingPlacementBegins);
            _playerGame.OceanMap.BuildingPlacementFinished += new BuildingPlacementFinishedHandler(BuildingPlacementEnds);
            _playerGame.OceanMap.BuildingSelected += new BuildingSelectedHandler(BuildingSelected);

            _playerGame.ResearchCompleted += delegate(Research research) { _playerGame.ApplyBenefits(research.Benefits); };
            _playerGame.BuildingsMadeAvailable += delegate() { RefreshBuildingOpportunities(); };
            _playerGame.ResearchMadeAvailable += delegate() { RefreshResearchOpportunities(); };

            skin = applicationSkin;
            controls = new SimulationScreenControls(game, applicationSkin);
            controls.UrbanAreaSelection.Toggled += new EventHandler(areaSelectionToggled);
            controls.CountryAreaSelection.Toggled += new EventHandler(areaSelectionToggled);
            controls.OceanAreaSelection.Toggled += new EventHandler(areaSelectionToggled);

            controls.NewTechnologyNotice.MovingFinished += delegate() { controls.NewTechnologyNotice.Visible = false; };

            controls.BuildingListLeft.OnClick += delegate(ScreenItem item, MouseEventArgs args) { ShiftBuildingList(-1); };
            controls.BuildingListRight.OnClick += delegate(ScreenItem item, MouseEventArgs args) { ShiftBuildingList(1); };

            controls.BuildingListLeft.Enabled = false;
            controls.MoneyLabel.Text = playerGame.Money.ToString();
            controls.FoodLabel.Text = playerGame.Food.ToString();
            controls.OilLabel.Text = playerGame.Oil.ToString();

            controls.MinimapEast.OnClick += delegate(ScreenItem item, MouseEventArgs args) { ShiftViewport(new Vector2(0, 1)); };
            controls.MinimapNorth.OnClick += delegate(ScreenItem item, MouseEventArgs args) { ShiftViewport(new Vector2(-1, 0)); };
            controls.MinimapSouth.OnClick += delegate(ScreenItem item, MouseEventArgs args) { ShiftViewport(new Vector2(1, 0)); };
            controls.MinimapWest.OnClick += delegate(ScreenItem item, MouseEventArgs args) { ShiftViewport(new Vector2(0, -1)); };

            foreach (Research research in playerGame.AvailableResearches)
                controls.TechnologyList.Items.Add(new ScreenItemListItem(research.Name, research));
            controls.TechnologyList.ListItemSelected += new ScreenItemList.ListItemSelectedHandler(TechnologyListItemSelected);
            foreach (Building building in playerGame.AvailableBuildings)
                controls.BuildingDropdown.Items.Add(new ScreenItemListItem(building.Name, building));
            controls.BuildingDropdown.ListItemSelected += delegate(ScreenItemList list, ScreenItemListItem item)
            {
                OpenBuildingDialog((Building)item.AttachedInformation);
            };
            int buttonIdentity = 0;
            foreach (ScreenItemButton button in controls.BuildingListButtons)
            {
                button.AttachedInformation = buttonIdentity;
                buttonIdentity++;
                button.OnClick += delegate(ScreenItem item, MouseEventArgs args)
                {
                    OpenBuildingDialog(_playerGame.AvailableBuildings[availableBuildingListOffset +
                           (int)item.AttachedInformation]);
                };
            }

            int upperBounds = (playerGame.AvailableBuildings.Count > 6 ? 6 : playerGame.AvailableBuildings.Count);
            for (int index = 0; index < upperBounds; index++)
                controls.BuildingListButtons[index].Image = playerGame.AvailableBuildings[index].BuildingIcon;

            if (playerGame.AvailableBuildings.Count <= 6)
            {
                for (int index = playerGame.AvailableBuildings.Count; index < controls.BuildingListButtons.Count; index++)
                    controls.BuildingListButtons[index].Enabled = false;
                controls.BuildingListRight.Enabled = false;
            }

            mapWindow = new Rectangle(151, 0, game.GraphicsDevice.Viewport.Width - 151,
                game.GraphicsDevice.Viewport.Height - 133);
            minimapWindow = new Rectangle(955, 405, GlobalSettings.MinimapWidth, GlobalSettings.MinimapHeight);
            minimapVertices = new Vector2[4];
            minimapVertices[0] = Vector2.Zero;
            minimapVertices[1] = new Vector2(GlobalSettings.MinimapWidth, 0);
            minimapVertices[2] = new Vector2(GlobalSettings.MinimapWidth, GlobalSettings.MinimapHeight);
            minimapVertices[3] = new Vector2(0, GlobalSettings.MinimapHeight);
            for (int vertex = 0; vertex < 4; vertex++)
            {
                Vector2 originalVertice = minimapVertices[vertex];
                minimapVertices[vertex].X = (int)(originalVertice.X * Math.Cos(MathHelper.PiOver4) -
                    originalVertice.Y * Math.Sin(MathHelper.PiOver4)) + minimapWindow.X;
                minimapVertices[vertex].Y = (int)(originalVertice.X * Math.Sin(MathHelper.PiOver4) +
                    originalVertice.Y * Math.Cos(MathHelper.PiOver4)) + minimapWindow.Y;
            }

            controls.SelectedBuilding.OnClick += delegate(ScreenItem item, MouseEventArgs args)
            {
                if (((ScreenItemBuildingInformation)item).Building == null)
                    return;
                switch (_currentMap)
                {
                    case SimulationScreenMap.Urban: _playerGame.UrbanMap.CenterTile = ((ScreenItemBuildingInformation)item).Building.MapLocation; break;
                    case SimulationScreenMap.Country: _playerGame.CountryMap.CenterTile = ((ScreenItemBuildingInformation)item).Building.MapLocation; break;
                    case SimulationScreenMap.Ocean: _playerGame.OceanMap.CenterTile = ((ScreenItemBuildingInformation)item).Building.MapLocation; break;
                }
            };
        }
 public static void DrawTile(this SpriteBatch spriteBatch, Tile tile, Map map,
     Vector2 screenPosition, ApplicationSkin skin)
 {
     spriteBatch.DrawTile(tile, map, screenPosition, skin, Color.White);
 }
Example #9
0
 public UrbanMap(Game game, ApplicationSkin skin, int width, int height)
     : base(game, skin, width, height, Terrain.Grass)
 {
 }
 public ScreenItemResearchProgress(Game game, ApplicationSkin skin, int x, int y,
     int width, ResearchProgress researchProgress)
     : base(game, skin, x, y, width)
 {
     this.ResearchProgress = researchProgress;
 }
 public ScreenItemWindowButtons(Game game, ApplicationSkin skin, int x, int y)
     : base(game, skin, x, y, 20, 20)
 {
 }
Example #12
0
 public ScreenItemImage(Game game, ApplicationSkin skin, int x, int y, int width, int height, string graphicHandle)
     : base(game, skin, x, y, width, height)
 {
     image = skin.Graphics[graphicHandle];
 }
Example #13
0
 public ScreenItemImage(Game game, ApplicationSkin skin, int x, int y, string graphicHandle)
     : base(game, skin, x, y, skin.Graphics[graphicHandle].Texture.Width,
     skin.Graphics[graphicHandle].Texture.Height)
 {
     image = skin.Graphics[graphicHandle];
 }
Example #14
0
 public ScreenItemImage(Game game, ApplicationSkin skin, int x, int y, Texture2D image)
     : base(game, skin, x, y, image.Width, image.Height)
 {
     this.image = image;
 }