IEnumerator Move(int discs, Pole fromPole, Pole toPole, Pole otherPole, float onePoleFlyTime = 2f) { yield return(new WaitForSeconds(0.2f)); // Pause time before pick float time = onePoleFlyTime * Mathf.Abs(fromPole.Index - toPole.Index); if (discs == 1) { DiscComponent disk = fromPole.Pop(); toPole.Push(disk); disk.Animate(_yPickPosition, new Vector3(toPole.Position.x, (toPole.Count - 1) * _discHeigh), time); yield return(new WaitForSeconds(time)); CheckForWin(); yield break; } yield return(StartCoroutine(Move(discs - 1, fromPole, otherPole, toPole))); DiscComponent anotherDisk = fromPole.Pop(); toPole.Push(anotherDisk); anotherDisk.Animate(_yPickPosition, new Vector3(toPole.Position.x, (toPole.Count - 1) * _discHeigh), time); yield return(new WaitForSeconds(time)); yield return(StartCoroutine(Move(discs - 1, otherPole, toPole, fromPole))); }
public void Push(DiscComponent disk) { _disks.Push(disk); }