コード例 #1
0
		public static void CreateAsset()
		{
			string path = UnityEditor.AssetDatabase.GetAssetPath(UnityEditor.Selection.activeObject);
			string assetPath = path + "/BlankDungeonBoardSettings.asset";
			DungeonBoardSettings item = ScriptableObject.CreateInstance<DungeonBoardSettings> ();
			UnityEditor.ProjectWindowUtil.CreateAsset(item, assetPath);
		}
コード例 #2
0
ファイル: DungeonBoard.cs プロジェクト: Snepsts/Project1
    //public
    public void init(DungeonBoardSettings Settings)
    {
        //if the settings call for rows or cols under the minimum amount then scale the value up to the minimum
        Settings.rows = (Settings.rows < minNumberOfRows) ? minNumberOfRows : Settings.rows;
        Settings.cols = (Settings.cols < minNumberOfCols) ? minNumberOfCols : Settings.cols;
        Settings.minimumPercentageOfOpenTiles = (Settings.rows == minNumberOfRows && Settings.cols == minNumberOfCols) ? 0.25f : Settings.minimumPercentageOfOpenTiles;

        //TODO:Just make Settings a part of the DungeonBoard and then hand off what is needed from the settings object instead of doing all this setup
        //Configure based off of setting values
        base.init(Settings.rows, Settings.cols, Settings.tileObject);
        chanceToStartAlive           = Settings.chanceToStartAlive;
        minimumPercentageOfOpenTiles = Settings.minimumPercentageOfOpenTiles;
        deathLimit             = Settings.deathLimit;
        birthLimit             = Settings.birthLimit;
        numberOfSimulations    = Settings.numberOfSimulations;
        innerWallSprite        = Settings.innerWallSprite;
        wallSprite             = Settings.wallSprite;
        floorSprite            = Settings.floorSprite;
        waterSprite            = Settings.waterSprite;
        teleporterSprite       = Settings.teleporterSprite;
        runEdgeSmoothing       = Settings.runEdgeSmoothing;
        allowDisconnectedCaves = Settings.allowDisconnectedCaves;
        xPadding = Settings.xPadding;
        yPadding = Settings.yPadding;
        //
        gridContainerName = "DungeonGrid";
        initMap();
        if (!EnsureSpawnPointAndExitCanExist())
        {
            RespawnMap();
        }
        MapCleanUp();
        SetAllOriginalSpritesAndColors();
        SpawnPlayerAndExitPoint();
        SetUpEdges();              //setup all tiles with edge information
        CalculateTileNeighbours(); //setup all tiles with neighbour information
    }
コード例 #3
0
 public DungeonBoard(DungeonBoardSettings Settings)
 {
     Grid          = new List <List <ITile> >();
     this.Settings = Settings;
 }
コード例 #4
0
    //public
    public void init(DungeonBoardSettings Settings)
    {
        //if the settings call for rows or cols under the minimum amount then scale the value up to the minimum
        Settings.rows = (Settings.rows < minNumberOfRows) ? minNumberOfRows : Settings.rows;
        Settings.cols = (Settings.cols < minNumberOfCols) ? minNumberOfCols : Settings.cols;
        Settings.minimumPercentageOfOpenTiles = (Settings.rows == minNumberOfRows && Settings.cols == minNumberOfCols) ? 0.25f : Settings.minimumPercentageOfOpenTiles;
        //

        //basic board info setup
        base.init(Settings.rows, Settings.cols, Settings.tileObject, "DungeonGrid");
        mapSettings = Settings;
        //

        //map generation
        initMap();         //create the static grid that we use to play the game of life on
        MapSimulation();   //play the game of life on the grid a number of times equal to mapSettings.numberOfSimulations
        //

        //map cleanup
        if (!EnsureSpawnPointAndExitCanExist())           //ensure that we can create a spawn and exit, if not restart map generation
        {
            RespawnMap();
        }
        RemoveBlockedOpenTiles();         // if any floor tiles are completely blocked in, remove them from the game
        FixEdges(mapSettings.wallSprite); //if any floor tiles are touching the edge of the gird change them to walls
        RemoveFloatingWalls();            //remove any walls that are just freefloating next to destoryed tiles
        //

        //water generation
        DungeonBoardWaterGeneration waterGeneration = ScriptableObject.CreateInstance <DungeonBoardWaterGeneration>();

        waterGeneration.GenerateLiquid(this, ref container, mapSettings.waterSprite);         //generate water in natural holes in the map
        //

        //grass generation
        DungeonBoardGrassGeneration grassGeneration = ScriptableObject.CreateInstance <DungeonBoardGrassGeneration>();

        grassGeneration.GenerateGrass(this, ref container, mapSettings.grassSprites);
        //

        //fix caves
        if (mapSettings.allowDisconnectedCaves)           //if we allow caves to spawn disconnected then place teleporters to connect them
        {
            ConnectDisconnectedCaves();
        }
        else             //otherwise remove the disconnected caves and make sure we retain a certain percentage of play space
        {
            RemoveDisconnectedCaves();
            CheckForMinimumMapSize();
        }
        if (mapSettings.runEdgeSmoothing)           //if we enable smoothing out map edges
        {
            SmoothMapEdges();
        }
        SetDestroyed();           //Set the destroyed status for all tiles
        ChangeInnerWallSprites(); //set walls that the player cannot see the "bottom" side of to a different sprite
        //

        //Final data setup
        SetAllOriginalSpritesAndColors(); //set the sprite and color values for each tile for use in later logic
        SpawnPlayerAndExitPoint();        //spawn the player and the exit point for the map
        SetUpEdges();                     //setup all tiles with edge information
        CalculateTileNeighbours();        //setup all tiles with neighbour information
        //
    }