Example #1
0
 // This copy constructor creates a board that is a copy of the original board w.r.t.
 // a new origin and scale.
 // The following are not copied:
 //      - Inhabitants of tiles.
 //      - Custom colorings of the tiles (all tiles will reset their coloring).
 public Board(Board original, World world, Vector3 origin, float scale)
 {
     this.world = world;
     this.size  = original.size;
     this.scale = scale;
     this.tiles = new GameObject[original.size, original.size];
     for (int i = 0; i < this.size; i++)
     {
         for (int j = 0; j < this.size; j++)
         {
             this.tiles[i, j] = (GameObject)GridTile.Instantiate(Resources.Load("tile_pf"));
             this.tiles[i, j].GetComponent <Transform>().position    = new Vector3(i * this.scale, j * this.scale, 0) + origin;
             this.tiles[i, j].GetComponent <Transform>().localScale *= this.scale;
             this.tiles[i, j].GetComponent <GridTile>().Setup(original.tiles[i, j].GetComponent <GridTile>(), world);
         }
     }
 }
Example #2
0
    public Board(World world, int size, Vector3 origin, float scale)
    {
        this.world = world;
        this.size  = size;
        this.scale = scale;
        tiles      = new GameObject[this.size, this.size];

        for (int i = 0; i < this.size; i++)
        {
            for (int j = 0; j < this.size; j++)
            {
                tiles[i, j] = (GameObject)GridTile.Instantiate(Resources.Load("tile_pf"));
                tiles[i, j].GetComponent <Transform>().position    = new Vector3(i * this.scale, j * this.scale, 0) + origin;
                tiles[i, j].GetComponent <Transform>().localScale *= this.scale;
                Color color = world.worldColor.passableTile;;
                tiles[i, j].GetComponent <GridTile>().Setup(this, new Vector2Int(i, j), color, world.worldColor.unpassableTile);
            }
        }
    }