Example #1
0
 void SolveTower(int numOfDiscs, TowerRod fromRod, TowerRod toRod, TowerRod auxRod)
 {
     if (numOfDiscs == 1)
     {
         moves.Add(new Move(fromRod, toRod));
         return;
     }
     SolveTower(numOfDiscs - 1, fromRod, auxRod, toRod);
     moves.Add(new Move(fromRod, toRod));
     SolveTower(numOfDiscs - 1, auxRod, toRod, fromRod);
 }
Example #2
0
    IEnumerator MoveDisc(TowerRod fromRod, TowerRod toRod)
    {
        Disc    disc      = fromRod.GetDisc();
        Vector3 targetPos = toRod.GetTopPosition();

        Debug.Log("Moving disc from " + fromRod.rodName + " to " + toRod.rodName);

        disc.transform.DOLocalMoveY(300f, moveDuration);
        yield return(new WaitForSeconds(moveDuration));

        disc.transform.DOLocalMoveX(toRod.transform.localPosition.x + targetPos.x, moveDuration);
        yield return(new WaitForSeconds(moveDuration));

        disc.transform.DOLocalMoveY(toRod.transform.localPosition.y + targetPos.y, moveDuration);
        toRod.AddDisc(disc);
        yield return(new WaitForSeconds(moveDuration));
    }
Example #3
0
 public Move(TowerRod fromRod, TowerRod toRod)
 {
     this.fromRod = fromRod;
     this.toRod   = toRod;
 }