示例#1
0
    private GameObject boardHolder;                               // GameObject that acts as a container for all other tiles.

    // Commence stewmaking
    void Start()
    {
        float startUp = Time.realtimeSinceStartup;

        boardHolder = new GameObject("BoardHolder");

        SetUpBoard(ROWS, ROW_LENGTH);

        Tunneler tunnelLad = new Tunneler(100, 25);

        tunnelLad.Dig(ref tiles);

        for (int i = 0; i < RoomDiggers.Count; i++)
        {
            //Debug.Log (RoomDiggers [i] [0] + " " + RoomDiggers [i] [1]);
            RoomTunneler roomTunnel = new RoomTunneler(RoomDiggers [i] [0], RoomDiggers [i] [1]);
            roomTunnel.Activate(ref tiles);
        }


        print("Execution time of all board-gen scripts took " + (Time.realtimeSinceStartup - startUp) + " seconds.");
    }
示例#2
0
 // Dig out a (dimension * 2 + 1) x (dimension * 2 + 1) area from current position.
 // dimensions: 0 = 1x1 area
 // dimensions: 1 = 3x3 area
 // dimensions: 2 = 5x5 area
 // dimensions: 3 = 7x7 area
 public void DigArea(ref Tile[][] board, int curY, int curX, int dimensions)
 {
     for (int i = -dimensions; i < dimensions + 1; i++)
     {
         for (int j = -dimensions; j < dimensions + 1; j++)
         {
             if (board [curY + j] [curX + i].property == Tile.TileState.IS_WALL)
             {
                 board [curY + j] [curX + i].property = Tile.TileState.IS_FLOOR;
                 if (rng.Next(0, 100) < CHANCE_SPAWN_ROOM_TUNNELER)
                 {
                     BoardGenerator.RoomDiggers.Add(new int[] { this.x, this.y });
                 }
             }
         }
     }
     if (dimensions >= 2)
     {
         // Newly spawned tunnelers have 0.5x lifespan compared to their parent's lifespan.
         Tunneler babyTunneler = new Tunneler(this.x, this.y, (int)Math.Round(this.lifespan * NEW_TUNNELER_LIFESPAN));
         babyTunneler.Dig(ref board);
         BoardGenerator.RoomDiggers.Add(new int[] { this.x, this.y });
     }
 }