public bool PickUpPlanet() { if (currentPlanet != null) { return(false); } if (stacks[currentStack] != null) { if (!stacks [currentStack].IsEmpty()) { currentPlanet = stacks [currentStack].GetTopPlanet(); currentPlanet.MoveUp(); stacks [currentStack].planets.Remove(stacks [currentStack].planets.FindLast(p => p)); stacks [currentStack].nextDropLongtitude -= currentPlanet.diameter; return(true); } } return(false); }
public void dynamicTransfer(List <Stack <PlanetController> > nestedPlanets, int startStack, int endStack, int total) { if (total == 1) { PlanetController planet = nestedPlanets [startStack].Pop(); nestedPlanets [endStack].Push(planet); bool isExist = stacks [endStack].planets.Any(x => x.name == planet.name); if (!isExist) { stacks [endStack].planets.Add(planet); } planet.MoveUp(); planet.MoveTo(endStack); planet.DropDown(); } else { int aux = 3 - startStack - endStack; dynamicTransfer(nestedPlanets, startStack, aux, total - 1); dynamicTransfer(nestedPlanets, startStack, endStack, 1); dynamicTransfer(nestedPlanets, aux, endStack, total - 1); } }