public void Spawn(Vector3 position) { var currentInstance = _pool.GetObject(position + Vector3.up); currentInstance.transform.SetParent(_figureHandler.transform); if (_previousInstance != null) { if (DistanceBetweenFigures(currentInstance.transform.position, _previousInstance.transform.position) < _lineBreakDistance) { RotateSpawnedFigures(currentInstance); } } _figureHandler.HandleCreatedFigure(currentInstance); currentInstance.FigureFellAndLeftScreen += Despawn; _previousInstance = currentInstance; }
private void HandleFigure(DominoFigure figure) { _handles.Add(figure); figure.FigureFell += ResetFigureTimer; }
public void HandleCreatedFigure(DominoFigure figure) { HandleFigure(figure); }
private void Despawn(DominoFigure instance) { instance.FigureFellAndLeftScreen -= Despawn; _pool.ReturnObject(instance); }
private void RotateSpawnedFigures(DominoFigure current) { _previousInstance.SetRotation(current.transform); current.SetRotation(_previousInstance.transform); }
public void ReturnObject(DominoFigure instance) { instance.gameObject.SetActive(false); _availableObjects.Enqueue(instance); }