コード例 #1
0
ファイル: BoardGeneration.cs プロジェクト: Swynfel/heirloom
 public RoundCornerBoardGeneration(int chippedCornerMin, int chippedCornerMax, int width, int height, BoardGeneration innerGeneration)
 {
     this.width           = width - 1;
     this.height          = height - 1;
     this.innerGeneration = innerGeneration;
     topLeft     = Global.rng.Next(chippedCornerMin, chippedCornerMax + 1);
     topRight    = Global.rng.Next(chippedCornerMin, chippedCornerMax + 1);
     bottomLeft  = Global.rng.Next(chippedCornerMin, chippedCornerMax + 1);
     bottomRight = Global.rng.Next(chippedCornerMin, chippedCornerMax + 1);
 }
コード例 #2
0
ファイル: BoardGeneration.cs プロジェクト: Swynfel/heirloom
 public MixBoardGeneration(BoardGeneration main, BoardGeneration secondary, float bias, float period = 2f, float persistence = 0.5f, float lacunarity = 2f)
 {
     this.main      = main;
     this.secondary = secondary;
     this.bias      = bias;
     noise          = new OpenSimplexNoise {
         Period      = period,
         Persistence = persistence,
         Lacunarity  = lacunarity,
     };
     noise.Seed = Global.rng.Next();
 }
コード例 #3
0
ファイル: BoardGeneration.cs プロジェクト: Swynfel/heirloom
        public LakeBoardGeneration(int width, int height, BoardGeneration outside, BoardGeneration inside, float lakeMinRadius, float lakeMaxRadius)
        {
            this.outside       = outside;
            this.inside        = inside;
            this.lakeMinRadius = lakeMinRadius;
            this.lakeMaxRadius = lakeMaxRadius;
            center             = new Vector2(Global.rng.Next(width / 3, width * 2 / 3), Global.rng.Next(height / 3, height * 2 / 3));
            double angle = Global.rng.NextDouble();

            direction      = new Vector2((float)Math.Sin(angle), (float)Math.Cos(angle));
            lakeHalfHeight = (float)(Global.rng.NextDouble() % (lakeMaxRadius - lakeMinRadius)) + lakeMinRadius;
            lakeHalfWidth  = (float)(Global.rng.NextDouble() % (lakeMaxRadius - lakeMinRadius)) + lakeMinRadius;
        }
コード例 #4
0
ファイル: BoardGeneration.cs プロジェクト: Swynfel/heirloom
        public RoadBoardGeneration(int width, int height, BoardGeneration outside, BoardGeneration inside, float halfThickness, float sinusStretch, float sinusImpact)
        {
            this.outside       = outside;
            this.inside        = inside;
            this.halfThickness = halfThickness;
            this.sinusStretch  = sinusStretch;
            this.sinusImpact   = sinusImpact;
            center             = new Vector2(Global.rng.Next(width / 3, width * 2 / 3), Global.rng.Next(height / 3, height * 2 / 3));
            bent = (float)Global.rng.NextDouble();
            double angle = Global.rng.NextDouble();

            direction = new Vector2((float)Math.Sin(angle), (float)Math.Cos(angle));
        }
コード例 #5
0
        private bool GenerateInternal(Board board, List <CharacterEntity> friendly, int width, int height)
        {
            try {
                board.width  = width;
                board.height = height;
                board.CreateTerrain(
                    BoardGeneration.Build(map, width, height)
                    );

                List <Tile> tiles = new List <Tile>(board.Tiles);

                // Check it tiles are all connected
                int totalTiles     = tiles.Count;
                int totalConnected = BoardUtils.AllReachableTiles(tiles[0]).Count;
                if (totalTiles != totalConnected)
                {
                    return(false);
                }

                foreach (CharacterEntity friend in friendly)
                {
                    Tile tile = tiles.PopRandom();
                    foreach (Tile n in tile.GetNeighbors())
                    {
                        tiles.Remove(n);
                    }
                    Place(friend, tile);
                }

                foreach (CharacterEntity enemy in RandomEnemies(enemyCount))
                {
                    Tile tile = tiles.PopRandom();
                    foreach (Tile n in tile.GetNeighbors())
                    {
                        tiles.Remove(n);
                    }
                    Place(enemy, tile);
                }
                return(true);
            } catch {
                board.Clear();
                return(false);
            }
        }
コード例 #6
0
ファイル: Board.cs プロジェクト: Swynfel/heirloom
 public void CreateTerrain(Generate.BoardGeneration boardGen) {
     Clear();
     tiles = new Tile[width * height];
     for (int x = 0 ; x < width ; x++) {
         for (int y = 0 ; y < height ; y++) {
             Tile.GroundType groundType = boardGen.Pick(x, y);
             if (groundType == Tile.GroundType.NONE) {
                 continue;
             }
             Tile tile = Tile.Create(this, x, y, groundType);
             tile.GetNode("Control").Connect("mouse_entered", this, nameof(on_TileHovered), Global.ArrayFrom(tile));
             tile.GetNode("Control").Connect("mouse_exited", this, nameof(on_TileExited), Global.ArrayFrom(tile));
             tiles[y * width + x] = tile;
             Entity potentialEntity = boardGen.Obstacle(x, y);
             if (potentialEntity != null) {
                 AddChild(Piece.New(potentialEntity, tile));
             }
         }
     }
 }