public void BuildTile(int x, int y, Tiles.TileTemplate template) { int index = x + y * tile_width; // Make sure that the requirements are met and that there are no other tiles // that block this tile if (template.Requirements.ValidateTerrain(this, x, y).Valid) { for (int j = 0; j < template.Requirements.Height - 1; j++) { for (int i = 0; i < template.Requirements.Width - 1; i++) { if (Tiles[x + i + (y + j) * tile_width].tile != null) { return; } } } Assets.Scripts.Tiles.Tile t = template.CreateInstance( entity_parent, new Vector3(x, GetVertex(x, y).Height, y)); for (int j = 0; j < template.Requirements.Height; j++) { for (int i = 0; i < template.Requirements.Width; i++) { Tiles[x + i + (y + j) * tile_width].tile = t; } } } }
// Use this for initialization void Start() { cam = GetComponent <Camera>(); focus_point = transform.position; selection_renderer = selection_graphic.GetComponent <MeshRenderer>(); tile = new Assets.Scripts.Tiles.Castle(); reqRenderer = new RequirementRenderer(tile.Requirements); renderer = new TerrainRenderer(selection_graphic, reqRenderer, falseMaterial); default_layer = (LayerMask.NameToLayer("Default") + 1) << 8; }