public void shouldBeValley_trough8()
        {
            var    landscapeType = new LandscapeType("[9, 8, 9]");
            String result        = landscapeType.Type();

            Assert.Equal(VALLEY, result);
        }
        public void shouldBeNeither()
        {
            var    landscapeType = new LandscapeType("[9, 8, 9, 8]");
            String result        = landscapeType.Type();

            Assert.Equal(NEITHER, result);
        }
示例#3
0
 /// <summary>
 /// The constructor for a Landscape tile is just a plain old C# object constructor.
 /// </summary>
 /// <param name="inType">The type of tile, using enum LandscapeType</param>
 /// <param name="inBrightnessOffset">a random int to brighten or darken the color of the tile. Stored to make it consistent</param>
 /// <param name="inRandomShape">The random shape of this tile. Only used for rocks</param>
 public LandscapeTile(LandscapeType inType, int inBrightnessOffset, List <PointF> inRandomShape)
 {
     tileType         = inType;
     randomShape      = inRandomShape;
     tileChanged      = false;
     brightnessOffset = inBrightnessOffset;
 }
        public void shouldBeMountain_peak5()
        {
            var    landscapeType = new LandscapeType("[3, 4, 5, 4, 3]");
            String result        = landscapeType.Type();

            Assert.Equal(MOUNTAIN, result);
        }
示例#5
0
 public LandscapeTypeConfObject(LandscapeType type, float rarityFrom, float blendDistance, float heightMultiplier)
 {
     this.type             = type;
     this.rarityFrom       = rarityFrom;
     this.blendDistance    = blendDistance;
     this.blendTo          = rarityFrom + blendDistance;
     this.heightMultiplier = heightMultiplier;
 }
示例#6
0
        public void GridIsPassableMethodWorksCorrectly(int x, int y, LandscapeType cellType, int cellClearance,
                                                       LandscapeType unitType, int unitySize, bool result)
        {
            var grid = new PathfindingGrid(20, 20, Allocator.Persistent);

            grid.SetFlag(x, y, (long)cellType);
            grid.SetClearance(x, y, cellClearance);
            Assert.AreEqual(result, grid.IsPassable(x, y, (long)unitType, unitySize));
            grid.Dispose();
        }
示例#7
0
 protected void GenerateRandomLandscapes(int num)
 {
     for (int i = 0; i < num; i++)
     {
         int           r  = rand.Next(0, 2);
         LandscapeType lt = (LandscapeType)r;
         Landscape     ls = new Landscape(lt, new Vector(rand.Next(0, 1366), rand.Next(0, 768)));
         overallMap.Add(ls);
     }
 }
示例#8
0
 public void AddTypeConf(LandscapeType type, float rarityFrom, float blendDistance, float heightMultiplier)
 {
     if (this.landscapeTypeGradient.Count > 0)
     {
         this.landscapeTypeGradient.Add(new LandscapeTypeConfObject(type, rarityFrom, blendDistance, heightMultiplier, this.landscapeTypeGradient[this.landscapeTypeGradient.Count - 1]));
     }
     else
     {
         this.landscapeTypeGradient.Add(new LandscapeTypeConfObject(type, rarityFrom, blendDistance, heightMultiplier));
     }
 }
示例#9
0
        public Landscape(LandscapeType type, Vector pos)
        {
            Type     = type;
            Position = pos;
            if (type == LandscapeType.House || type == LandscapeType.Rock ||
                type == LandscapeType.Wall)
            {
                Passable = false;
            }
            else
            {
                Passable = true;
            }

            SetImage(type);
        }
示例#10
0
 public LandscapeTypeConfObject(LandscapeType type, float rarityFrom, float blendDistance, float heightMultiplier, LandscapeTypeConfObject prev) : this(type, rarityFrom, blendDistance, heightMultiplier)
 {
     this.prev = prev;
 }
示例#11
0
 public Landscape(string name, Vector pos, Animation ani,
                  bool pass, LandscapeType type) : base(name, pos, ani)
 {
     Type     = type;
     Passable = pass;
 }
示例#12
0
 public void SetLandscape(LandscapeType landscape)
 {
     this.landscape = landscape;
 }
示例#13
0
 public Node(LandscapeType type)
 {
     landscape = type;
     entity    = null;
 }
示例#14
0
        private void SetImage(LandscapeType type)
        {
/*            if (type == LandscapeType.House)
 *          {
 *              Img = Properties.Resources.House;
 *          }
 *          else if (type == LandscapeType.Rock)
 *          {
 *              Img = Properties.Resources.rock;
 *          }
 *          else if (type == LandscapeType.Stairs)
 *          {
 *              Img = Properties.Resources.stairs;
 *          }
 *          else if (type == LandscapeType.TreasureChest)
 *          {
 *              Img = Properties.Resources.chest;
 *          }
 *          else*/
            if (type == LandscapeType.Tree)
            {
                int r = Form1.rand.Next(0, 20);
                if (r == 0)
                {
                    Img = Res.foliage1;
                }
                else if (r == 1)
                {
                    Img = Res.foliage2;
                }
                else if (r == 2)
                {
                    Img = Res.foliage3;
                }
                else if (r == 3)
                {
                    Img = Res.foliage4;
                }
                else if (r == 4)
                {
                    Img = Res.palmtree1;
                }
                else if (r == 5)
                {
                    Img = Res.palmtree2;
                }
                else if (r == 6)
                {
                    Img = Res.palmtree3;
                }
                else if (r == 7)
                {
                    Img = Res.palmtree4;
                }
                else if (r == 8)
                {
                    Img = Res.palmtree5;
                }
                else if (r == 9)
                {
                    Img = Res.palmtree6;
                }
                else if (r == 10)
                {
                    Img = Res.tree1;
                }
                else if (r == 11)
                {
                    Img = Res.tree2;
                }
                else if (r == 12)
                {
                    Img = Res.tree3;
                }
                else if (r == 13)
                {
                    Img = Res.tree4;
                }
                else if (r == 14)
                {
                    Img = Res.tree5;
                }
                else if (r == 15)
                {
                    Img = Res.tree6;
                }
                else if (r == 16)
                {
                    Img = Res.tree7;
                }
                else if (r == 17)
                {
                    Img = Res.tree8;
                }
                else if (r == 18)
                {
                    Img = Res.tree9;
                }
                else if (r == 19)
                {
                    Img = Res.treeDead;
                }
                //                Img = Properties.Resources.Tree;
            }
            else
            {
                Img = Properties.Resources.block;
            }
        }
示例#15
0
        }//E N D  C O N S T R U C T O R

        /// <summary>
        /// The start method generates a random landscape to fit the parameters.
        /// </summary>
        public void Start()
        {
            Array landscapeTypes = Enum.GetValues(typeof(LandscapeType));

            tilesMap = new List <List <LandscapeTile> >();
            int goalRow = rand.Next(3, landscapeHeight - 3);

            //seed initial map
            for (int row = 0; row < landscapeHeight; row++)
            {
                List <LandscapeTile> currentRow = new List <LandscapeTile>();
                for (int col = 0; col < landscapeWidth; col++)
                {
                    if (row >= goalRow - 1 && row <= goalRow + 1 && col == 0)
                    {
                        currentRow.Add(new LandscapeTile(LandscapeType.goal, rand.Next(-30, 30), generateRandomShape()));
                    }
                    else if (row == 0 || col == 0 || col == landscapeWidth - 1 || row == landscapeHeight - 1)
                    {
                        currentRow.Add(new LandscapeTile(LandscapeType.bedrock, rand.Next(-30, 30), generateRandomShape()));
                    }
                    else
                    {
                        if (col < edgeBuffer || col > landscapeWidth - edgeBuffer - 1 || row < edgeBuffer || row > landscapeHeight - edgeBuffer - 1)
                        {
                            currentRow.Add(new LandscapeTile(LandscapeType.rock, rand.Next(-30, 30), generateRandomShape()));
                        }
                        else
                        {
                            LandscapeType randomLandscapeType = (LandscapeType)landscapeTypes.GetValue(rand.Next(landscapeTypes.Length - 2));
                            currentRow.Add(new LandscapeTile(randomLandscapeType, rand.Next(-30, 30), generateRandomShape()));
                        }
                    }
                }
                tilesMap.Add(currentRow);
            }//end seed

            //iterate on generation (cell generation)
            for (int iteration = 0; iteration < generationIterations; iteration++)
            {
                for (int row = edgeBuffer; row < landscapeHeight - edgeBuffer; row++)
                {
                    for (int col = edgeBuffer; col < landscapeWidth - edgeBuffer; col++)
                    {
                        int rocksCount = 0; int grassCount = 0;
                        //proximity search of all neighbors.
                        for (int searchRow = row - 1; searchRow < row + 2; searchRow++)
                        {
                            for (int searchCol = col - 1; searchCol < col + 2; searchCol++)
                            {
                                if (searchRow != row || searchCol != col)
                                {
                                    if (tilesMap[searchRow][searchCol].tileType == LandscapeType.rock)
                                    {
                                        rocksCount++;
                                    }
                                    if (tilesMap[searchRow][searchCol].tileType == LandscapeType.grass)
                                    {
                                        grassCount++;
                                    }
                                }
                            }
                        }//end proximity search
                        if (rocksCount > rockSpawnThreshold)
                        {
                            tilesMap[row][col].tileType = LandscapeType.rock;
                        }
                    }
                }
            }
            //clean up excess rocks
            for (int row = edgeBuffer; row < landscapeHeight - edgeBuffer; row++)
            {
                for (int col = edgeBuffer; col < landscapeWidth - edgeBuffer; col++)
                {
                    if (tilesMap[row][col].tileType == LandscapeType.rock)
                    {
                        int rocksCount = 0; int grassCount = 0;
                        //proximity search of all neighbors.
                        for (int searchRow = row - 1; searchRow < row + 2; searchRow++)
                        {
                            for (int searchCol = col - 1; searchCol < col + 2; searchCol++)
                            {
                                if (searchRow != row || searchCol != col)
                                {
                                    if (tilesMap[searchRow][searchCol].tileType == LandscapeType.rock)
                                    {
                                        rocksCount++;
                                    }
                                    if (tilesMap[searchRow][searchCol].tileType == LandscapeType.grass)
                                    {
                                        grassCount++;
                                    }
                                }
                            }
                        }//end proximity search
                        if (rocksCount < rockSpawnThreshold)
                        {
                            if (grassCount > grassSpawnThreshold)
                            {
                                tilesMap[row][col].tileType = LandscapeType.grass;
                            }
                            else
                            {
                                tilesMap[row][col].tileType = LandscapeType.dirt;
                            }
                        }
                    }
                    else if (tilesMap[row][col].tileType == LandscapeType.dirt)
                    {
                        tilesMap[row][col].tileType = LandscapeType.grass;
                    }
                }
            }//end clean up
        }
示例#16
0
 public CellLandscapeType(LandscapeType type, float score)
 {
     this.type  = type;
     this.score = score;
 }
示例#17
0
        /// <summary>
        /// The KeyPlayer's Tick method controls invincibility, collision with landscape, movement and digging.
        /// </summary>
        public void Tick()
        {
            //i n v i n c i b i l i t y  handling
            if (invincible && timeInvincible < invincibilityTime)
            {
                timeInvincible++;
            }
            else
            {
                invincible     = false;
                timeInvincible = 0;
            }

            /*s i z i n g,  originally  l o c a t i n g,  and determining
             * the  s p e e d  of the character based on the size of the landscape */
            int pixelSpeed = 0;

            if (landscape.pixelHeightPerTile != 0)
            {
                bounds.Width       = landscape.pixelWidthPerTile / 2;
                bounds.Height      = landscape.pixelHeightPerTile * 3;
                imageBounds.X      = bounds.X - bounds.Width / 2;
                imageBounds.Y      = bounds.Y - bounds.Height / 2;
                imageBounds.Width  = landscape.pixelWidthPerTile;
                imageBounds.Height = landscape.pixelHeightPerTile * 5;
                pixelSpeed         = landscape.pixelWidthPerTile / 4;

                if (bounds.X == 0 && bounds.Y == 0)
                {
                    bounds.X = (landscapeCol * landscape.pixelWidthPerTile);
                    bounds.Y = (landscapeRow * landscape.pixelHeightPerTile);
                }
                else
                {
                    landscapeCol = (int)((bounds.X + (bounds.Width / 2)) / landscape.pixelWidthPerTile);
                    landscapeRow = (int)((bounds.Y + (bounds.Height)) / landscape.pixelHeightPerTile);

                    landscape.tilesMap[landscapeRow][landscapeCol].tileType = LandscapeType.dirt;
                }
            }

            //M o v e m e n t code
            digHeld = false;
            if (landscape.tilesMap[landscapeRow][landscapeCol - 1].tileType == LandscapeType.goal)  //Victory condition
            {
                stateManager.keyboardVictory();
            }
            else    //loop through all the keys currently held to determine what actions to take.
            {
                foreach (KeyEventArgs key in inputManager.keysHeld)
                {
                    if (key.KeyCode == Keys.W)
                    {
                        lastFacingDirection[0] = -1; lastFacingDirection[1] = 0;
                        LandscapeType forwardTile = landscape.tilesMap[landscapeRow - 1][landscapeCol].tileType;
                        if (forwardTile == LandscapeType.grass || forwardTile == LandscapeType.dirt ||
                            bounds.Y + bounds.Height > (landscapeRow * landscape.pixelHeightPerTile) + pixelSpeed)
                        {
                            bounds.Y -= pixelSpeed;
                        }
                    }
                    if (key.KeyCode == Keys.A)
                    {
                        lastFacingDirection[0] = 0; lastFacingDirection[1] = -1;
                        LandscapeType forwardTile = landscape.tilesMap[landscapeRow][landscapeCol - 1].tileType;
                        if (forwardTile == LandscapeType.grass || forwardTile == LandscapeType.dirt ||
                            bounds.X > (landscapeCol * landscape.pixelWidthPerTile) + pixelSpeed)
                        {
                            bounds.X -= pixelSpeed;
                        }
                    }
                    if (key.KeyCode == Keys.S)
                    {
                        lastFacingDirection[0] = 1; lastFacingDirection[1] = 0;
                        LandscapeType forwardTile = landscape.tilesMap[landscapeRow + 1][landscapeCol].tileType;
                        if (forwardTile == LandscapeType.grass || forwardTile == LandscapeType.dirt || bounds.Y + bounds.Height <
                            (landscapeRow * landscape.pixelHeightPerTile) - landscape.pixelHeightPerTile - pixelSpeed)
                        {
                            bounds.Y += pixelSpeed;
                        }
                    }
                    if (key.KeyCode == Keys.D)
                    {
                        lastFacingDirection[0] = 0; lastFacingDirection[1] = 1;
                        LandscapeType forwardTile = landscape.tilesMap[landscapeRow][landscapeCol + 1].tileType;
                        if (forwardTile == LandscapeType.grass || forwardTile == LandscapeType.dirt || bounds.X + bounds.Width <
                            (landscapeCol * landscape.pixelWidthPerTile) - landscape.pixelWidthPerTile - pixelSpeed)
                        {
                            bounds.X += pixelSpeed;
                        }
                    }
                    if (key.KeyCode == Keys.Space)
                    {
                        digHeld             = true;
                        attackBounds.Width  = landscape.pixelWidthPerTile;
                        attackBounds.Height = landscape.pixelHeightPerTile * 2;
                        attackBounds.Y      = bounds.Y;
                        attackBounds.X      = bounds.X + (bounds.Width / 2 - attackBounds.Width / 2);
                        if (lastFacingDirection[1] > 0)
                        {
                            attackBounds.X = bounds.X + bounds.Width;
                        }
                        else if (lastFacingDirection[1] < 0)
                        {
                            attackBounds.X = bounds.X - attackBounds.Width;
                        }
                        if (timeDigging >= digCooldown)
                        {
                            if (landscape.tilesMap[landscapeRow + lastFacingDirection[0]]
                                [landscapeCol + lastFacingDirection[1]].tileType != LandscapeType.bedrock)
                            {
                                landscape.tilesMap[landscapeRow + lastFacingDirection[0]]
                                [landscapeCol + lastFacingDirection[1]].tileType = LandscapeType.dirt;
                                timeDigging = 0;
                            }
                        }
                        else
                        {
                            digHeld      = true;
                            timeDigging += 0.1f;
                        }
                    }
                }//end inputs
                if (!digHeld)
                {
                    timeDigging         = 0;
                    attackBounds.Width  = 0;
                    attackBounds.Height = 0;
                }
            }
        }