Esempio n. 1
0
 public Decoration(GameObject prefab, GridDecorationModel decoration, int i, int j, Transform parent = null)
 {
     gameObject            = GameObject.Instantiate(prefab, GridAsst.GridToWorldPosition(i, j), Quaternion.identity, parent);
     gameObject.name       = $"X {i} Y {j}";
     renderer              = gameObject.GetComponent <SpriteRenderer>();
     renderer.sprite       = decoration.sprite;
     renderer.sortingOrder = 1;
     isCreated             = true;
 }
Esempio n. 2
0
 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();
         }
     }
 }
Esempio n. 3
0
    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();
            }
        }
    }