public bool Switch() { CellObject firstCellObject = FirstCell.ContainedObject; CellObject secondCellObject = SecondCell.ContainedObject; if (firstCellObject == null || secondCellObject == null) { Debug.LogWarning("One of cells is empty. Abort"); return(false); } if (firstCellObject.InAction || secondCellObject.InAction) { Debug.LogWarning("One of objects in action now. Abort"); return(false); } firstCellObject.OnMoveEnd += OnMoveEnd; secondCellObject.OnMoveEnd += OnMoveEnd; _switchCounter = 2; firstCellObject.MoveTo(SecondCell); secondCellObject.MoveTo(FirstCell); secondCellObject.SetParentCell(FirstCell); firstCellObject.SetParentCell(SecondCell); return(true); }
public void PinCellObject(CellObject cellObject, bool changeObjectPosition = true) { if (cellObject == null) { return; } ContainedObject = cellObject; if (changeObjectPosition) { cellObject.transform.position = transform.position; } cellObject.SetParentCell(this); }