private TileActor createTileActor(TileModel tileModel) { Assert.IsTrue(tileModel != null && !tileModel.isOffBorad()); float halfRows = (currentData.numRows - 1) * currentData.tileSpacing / 2.0f; float halfCols = (currentData.numCols - 1) * currentData.tileSpacing / 2.0f; TileActor currentTile = Instantiate(currentData.tileInstance, Vector3.zero, Quaternion.identity, myTransform); //updating visual currentTile.tileModel = tileModel; currentTile.name = tileModel.row + "," + tileModel.col; currentTile.transform.localPosition = new Vector3(tileModel.col * currentData.tileSpacing - halfCols, tileModel.row * currentData.tileSpacing - halfRows); currentTile.setupFromConfig(currentData.tileConfigs[tileModel.type]); //linking visual and model Assert.IsNull(tileModel.AttachedTileActor); tileModel.AttachedTileActor = currentTile; return(currentTile); }
private void deleteTileActor(TileModel tileModel) { Assert.IsTrue(tileModel != null && !tileModel.isOffBorad() && tileModel.AttachedTileActor != null); Destroy(tileModel.AttachedTileActor.gameObject); tileModel.AttachedTileActor = null; }