コード例 #1
0
 /// <summary>
 /// Gets a graphical block whch exists on a particular point, with a global overlay
 /// </summary>
 /// <param name="point"></param>
 /// <param name="globalOverlay"></param>
 /// <returns></returns>
 public static GraphicalBlock GetBlockAtPoint(MapCoordinate point, GlobalOverlay globalOverlay)
 {
     switch (point.MapType)
     {
         case (DRObjects.Enums.MapType.GLOBAL)
         :
             try
             {
                 return GameState.GlobalMap.GetBlockAtCoordinate(point).ConvertToGraphicalBlock(globalOverlay);
             }
             catch
             {//send an empty one
                 GraphicalBlock block = new GraphicalBlock();
                 block.MapCoordinate = point;
                 return block;
             }
         case (DRObjects.Enums.MapType.LOCAL)
         :
             return GameState.LocalMap.GetBlockAtCoordinate(point).ConvertToGraphicalBlock();
         default:
             throw new NotImplementedException("There is no map manager for that type");
     }
 }
コード例 #2
0
ファイル: MapBlock.cs プロジェクト: Haedrian/Divine-Right
        public GraphicalBlock ConvertToGraphicalBlock(GlobalOverlay overlay)
        {
            GraphicalBlock block = new GraphicalBlock();
            block.TileGraphics = this.Tile.Graphics.ToArray();
            List<SpriteData> itemGraphics = new List<SpriteData>();

            if (this.GetTopItem() != null)
            {
                //go through all the items and add them to the list in order
                foreach (MapItem item in this.mapItems)
                {
                    itemGraphics.Add(item.Graphic);
                }

            }

            block.ItemGraphics = itemGraphics.ToArray();
            block.MapCoordinate = this.Tile.Coordinate;
            block.WasVisited = this.WasVisited;

            //get the overlay images if its a global tile

            if (this.Tile is GlobalTile)
            {
                block.OverlayGraphic = (this.Tile as GlobalTile).GetGraphicsByOverlay(overlay);
            }

            return block;
        }
コード例 #3
0
        public override void Update(GameTime gameTime)
        {
            //This fixes an issue in monogame with resizing
            graphics.ApplyChanges();

            base.Update(gameTime);

            if (gameTime.TotalGameTime.TotalMilliseconds - previousGameTime < GAMEINPUTDELAY)
            {
                //do nothing
                return;
            }

            previousGameTime = (int)gameTime.TotalGameTime.TotalMilliseconds;

            //Lets see if there are any keyboard keys being pressed

            KeyboardState keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.Up))
            {
                locationY += 5;
            }
            else if (keyboardState.IsKeyDown(Keys.Down))
            {
                locationY -= 5;
            }
            else if (keyboardState.IsKeyDown(Keys.Left))
            {
                locationX -= 5;
            }
            else if (keyboardState.IsKeyDown(Keys.Right))
            {
                locationX += 5;
            }

            if (keyboardState.IsKeyDown(Keys.OemPlus))
            {
                TILEWIDTH++;
                TILEHEIGHT++;
            }
            else if (keyboardState.IsKeyDown(Keys.OemMinus))
            {
                if (TILEHEIGHT != 1) //this would cause a div by zero
                {
                    TILEHEIGHT--;
                    TILEWIDTH--;
                }
            }

            if (keyboardState.IsKeyDown(Keys.R))
            {
                OVERLAY = GlobalOverlay.REGION;
            }
            else if (keyboardState.IsKeyDown(Keys.T))
            {
                OVERLAY = GlobalOverlay.TEMPERATURE;
            }
            else if (keyboardState.IsKeyDown(Keys.N))
            {
                OVERLAY = GlobalOverlay.NONE;
            }
            else if (keyboardState.IsKeyDown(Keys.P))
            {
                OVERLAY = GlobalOverlay.RAINFALL;
            }
            else if (keyboardState.IsKeyDown(Keys.E))
            {
                OVERLAY = GlobalOverlay.ELEVATION;
            }
            else if (keyboardState.IsKeyDown(Keys.D))
            {
                OVERLAY = GlobalOverlay.DESIRABILITY;
            }
            else if (keyboardState.IsKeyDown(Keys.O))
            {
                OVERLAY = GlobalOverlay.OWNER;
            }

            if (keyboardState.IsKeyDown(Keys.Enter) && !WorldGenerationManager.IsGenerating)
            {
                //Put it on the local map
                var blocks = GameState.GlobalMap.globalGameMap;
                BaseGame.requestedInternalAction = InternalActionEnum.LOAD;
                BaseGame.requestedArgs = new Object[1]{ "WorldMap"};
            }
        }
コード例 #4
0
        /// <summary>
        /// Gets a number of graphical blocks around a particular point.
        /// The order will be as follows:
        /// first max z, then max x, then max y.
        /// </summary>
        /// <param name="centrePoint">The center point around which the tiles will be calculated</param>
        /// <param name="xRange">How many tiles away from the centre point on the x axis will be obtained</param>
        /// <param name="yCount">How many tiles away from the centre point on the y axis will be obtained</param>
        /// <param name="zCount">How many tiles away from the centre point on the y axis will be obtained</param>
        /// <param name="overlay">If its a global map, the overlay to apply on it</param>
        /// <returns></returns>
        public static GraphicalBlock[] GetBlocksAroundPoint(MapCoordinate centrePoint, int xRange, int yRange, int zRange,GlobalOverlay overlay = GlobalOverlay.NONE)
        {
            int minZ = centrePoint.Z - Math.Abs(zRange);
            int maxZ = centrePoint.Z + Math.Abs(zRange);

            int minY = centrePoint.Y - Math.Abs(yRange);
            int maxY = centrePoint.Y + Math.Abs(yRange);

            int minX = centrePoint.X - Math.Abs(xRange);
            int maxX = centrePoint.X + Math.Abs(xRange);

            List<GraphicalBlock> returnList = new List<GraphicalBlock>();

            //go through all of them

            for (int zLoop = maxZ; zLoop >= minZ; zLoop--)
            {
                for (int yLoop = maxY; yLoop >= minY; yLoop--)
                {
                    for (int xLoop = minX; xLoop <= maxX; xLoop++)
                    {
                        MapCoordinate coord = new MapCoordinate(xLoop, yLoop, zLoop, centrePoint.MapType);
                        if (overlay != GlobalOverlay.NONE)
                        {
                            returnList.Add(GetBlockAtPoint(coord, overlay));
                        }
                        else
                        {
                            returnList.Add(GetBlockAtPoint(coord));
                        }
                    }
                }

            }

            return returnList.ToArray();
        }
コード例 #5
0
ファイル: GlobalTile.cs プロジェクト: Haedrian/Divine-Right
        public SpriteData GetGraphicsByOverlay(GlobalOverlay overlay)
        {
            if (overlay.Equals(GlobalOverlay.NONE))
            {
                return null;
            }

            #region Region Overlay
            else if (overlay.Equals(GlobalOverlay.REGION))
            {
                //if the elevation is underwater, nothing
                if (this.Elevation < 0)
                {
                    return null;
                }

                //otherwise, depending on the region number, colour them
                switch (Region % 7)
                {
                    case 0: return BROWN;
                    case 1: return GREEN;
                    case 2: return ORANGE;
                    case 3: return PINK;
                    case 4: return PURPLE;
                    case 5: return RED;
                    case 6: return YELLOW;
                }

                return null;

            }
            #endregion
            #region Temperature Overlay
            else if (overlay.Equals(GlobalOverlay.TEMPERATURE))
            {

                //Don't overlay the sea
                if (this.Elevation < 0)
                {
                    return null;
                }

                if (this.ClimateTemperature > 30)
                {
                    return RED;
                }
                else if (this.ClimateTemperature > 20)
                {
                    return ORANGE;
                }
                else if (this.ClimateTemperature > 10)
                {
                    return YELLOW;
                }
                else if (this.ClimateTemperature > 0)
                {
                    return INDIGO;
                }
                else if (this.ClimateTemperature > -10)
                {
                    return MARBLEBLUE;
                }
                else if (this.ClimateTemperature < -10)
                {
                    return WHITE;
                }

                return null;
            }
            #endregion
            #region Rainfall Overlay
            else if (overlay.Equals(GlobalOverlay.RAINFALL))
            {

                if (Elevation < 0)
                {
                    return null;
                }

                if (Rainfall > 8)
                {
                    //really wet
                    return RED;

                }
                else if (Rainfall > 6)
                {
                    //wet
                    return ORANGE;
                }
                else if (Rainfall > 4)
                {
                    return YELLOW;
                }
                else if (Rainfall > 2)
                {
                    return INDIGO;
                }
                else if (Rainfall < 2)
                {
                    return null;
                }

            }
            #endregion
            #region Elevation Overlay
            else if (overlay == GlobalOverlay.ELEVATION)
            {
                if (Elevation > 250)
                {
                    //mountain
                    return RED;
                }
                else if (Elevation > 100)
                {
                    return ORANGE;
                }
                else if (Elevation > 50)
                {
                    return YELLOW;
                }
                else if (Elevation > 25)
                {
                    return INDIGO;
                }
                else if (Elevation > 0)
                {
                    return WHITE;
                }
                else
                {
                    return null;
                }
            }
            #endregion
            #region Desirability Overlay
            else if (overlay == GlobalOverlay.DESIRABILITY)
            {
                if (BaseDesirability > 10)
                {
                    return GREEN;
                }
                else if (BaseDesirability > 5)
                {
                    return YELLOW;
                }
                else if (BaseDesirability > 0)
                {
                    return ORANGE;
                }
                else if (BaseDesirability <= 0)
                {
                    return RED;
                }
            }
            #endregion
            #region Owner
            else if (overlay == GlobalOverlay.OWNER)
            {
                if (Owner == null)
                {
                    return null;
                }

                switch (Owner.Value)
                {
                    case 0: return BROWN;
                    case 1: return GREEN;
                    case 2: return ORANGE;
                    case 3: return PINK;
                    case 4: return PURPLE;
                    case 5: return RED;
                    case 6: return YELLOW;

                    case 100: return INDIGO; //orc
                    case 50: return WHITE; //banditS
                }
            }
            #endregion
            return null;
        }