public override void OnDrop(Block block, Vector3 position) { base.OnDrop(block, position); if(IsEmpty) { base.OnDrop(block, position); IsEmpty = false; } else { block.ReturnToOldPosition(); } }
public override void OnDrop(Block block, Vector3 position) { int x = Mathf.FloorToInt((position.x + (-leftUpCellX) + cellWidth / 2) / cellWidth); int y = -Mathf.FloorToInt((position.y + (-leftUpCellY) + cellHeight / 2) / cellHeight); if(!this.gridSorter.TrySetBlock(x, y, block.Type)) { block.ReturnToOldPosition(); return; } block.X = x; block.Y = y; this.gridBlocks.Add(block); base.OnDrop(block, new Vector3(x * cellWidth + leftUpCellX, -y * cellHeight + leftUpCellY, -1)); }