#pragma warning restore 0649 #endregion public override Queue <Vector3Int> Modify(Grid3D grid, Vector3Int index) { Core.Cell root; if ((root = grid.TryGetCellByIndex(ref index)) == null) { return(null); } Queue <Vector3Int> newIndexes = new Queue <Vector3Int>(); List <Core.Cell> neighb = grid.GetNeighboursCell(ref index); foreach (Core.Cell cell in neighb) { newIndexes.Enqueue(cell.GetIndex()); } //Modif Vector3Int upIndex = root.GetIndex() + grid.GetConnexAxes()[1]; if (!grid.HaveCell(ref upIndex)) { int height = Random.Range(Min_Random, Max_Random); GameObject prefab = FuncEditor.GetPrefabFromInstance(root.gameObject); for (int i = 0; i < height; i++) { if (!grid.HaveCell(ref upIndex)) { FuncEditor.InstantiateCell(prefab, grid, upIndex); } upIndex += grid.GetConnexAxes()[1]; } } return(newIndexes); }
/// <summary> /// Check if it's a authorized move : /// -Destination is not a cell existing (occupied). /// -Destination above an existing cell that have a layer in ground's layermask /// </summary> /// <param name="futureIndex"> The index to test.</param> /// <returns>True if it's ok, false otherwise.</returns> private bool CheckIndexMovable(Vector3Int futureIndex) { Vector3Int groundInd = futureIndex; groundInd.y--; MapTileGridCreator.Core.Cell ground = _grid.TryGetCellByIndex(ref groundInd); return(_grid.HaveCell(ref groundInd) && !_grid.HaveCell(ref futureIndex) && _ground_layermask.HaveLayer(ground.gameObject.layer)); }