public void UpdateGrid(GridModel gridModel, float fillRate) { this.gridModel = gridModel; renderer.sprite = gridModel.gridModelSprite[GridAsst.GetGridTiles(i, j)]; ClearDecoration(); if (!GridAsst.IsEdgeGrid(i, j)) { if (Random.Range(0f, 1.0f) < fillRate) { AddDecoration(); } } }
public Grid(GameObject prefab, GridModel gridModel, int i, int j, float fillRate) { this.i = i; this.j = j; gameObject = GameObject.Instantiate(prefab, GridAsst.GridToWorldPosition(i, j), Quaternion.identity); renderer = gameObject.GetComponent <SpriteRenderer>(); this.gridModel = gridModel; gameObject.name = $"i {i} j {j}"; renderer.sprite = gridModel.gridModelSprite[GridAsst.GetGridTiles(i, j)]; decoration = new Decoration(); this.prefab = prefab; this.fillRate = fillRate; if (!GridAsst.IsEdgeGrid(i, j)) { if (Random.Range(0f, 1.0f) < fillRate) { AddDecoration(); } } }