コード例 #1
0
 public Dungeon(Vector3IntMinMax roomSize, int features, Tilemap t)
 {
     FeatureCount = features;
     RoomSize     = roomSize;
     Tilemap      = t;
 }
コード例 #2
0
        public FeaturePosition GetNewFeaturePosition()
        {
            /*  # = possible position to return
             *  F = actual room floor
             *             FFFFFF
             *            F000000F
             *            F000000F
             *            F000000F
             *            F000000F
             *             FFFFFF                 */

            Vector3IntMinMax rand = new Vector3IntMinMax();
            Vector3Int       pos  = Vector3Int.zero;
            Direction        d    = _directions[Random.Range(0, _directions.Count)];

            switch (d)
            {
            case Direction.Top:
                rand.Min    = Bounds.TopLeft();
                rand.Min.y += 1;

                rand.Max    = Bounds.TopRight();
                rand.Max.y += 1;

                pos = rand.GetRandomValue();
                break;

            case Direction.Left:
                rand.Min    = Bounds.BottomLeft();
                rand.Min.x -= 1;

                rand.Max    = Bounds.TopLeft();
                rand.Max.x -= 1;

                pos = rand.GetRandomValue();
                break;

            case Direction.Right:
                rand.Min    = Bounds.BottomRight();
                rand.Min.x += 1;

                rand.Max    = Bounds.TopRight();
                rand.Max.x += 1;

                pos = rand.GetRandomValue();
                break;

            case Direction.Bottom:
                rand.Min    = Bounds.BottomLeft();
                rand.Min.y -= 1;

                rand.Max    = Bounds.BottomRight();
                rand.Max.y -= 1;

                pos = rand.GetRandomValue();
                break;
            }

            _directions.Remove(d);
            return(new FeaturePosition(pos.x, pos.y, d));
        }