private void AddAreaRecursively(int idx, int step, Block block, List<long> possibleAreas) { if (possibleAreas.Contains(block.Area) == false) possibleAreas.Add(block.Area); if (idx < Step) FillPossibleAreas(++idx, step, block, possibleAreas); }
private void FillPossibleAreas(int idx, int step, Block block, List<long> possibleAreas) { Block byHeight = Clone(block); byHeight.Height += 1; AddAreaRecursively(idx, step, byHeight, possibleAreas); Block byLength = Clone(block); byLength.Length += 1; AddAreaRecursively(idx, step, byLength, possibleAreas); }
private static Block Clone(Block block) { Block clone = new Block() { Height = block.Height, Length = block.Length }; return clone; }
private void GetNextArea(int idx, int step, Block block) { var possibleAreas = new List<long>(); FillPossibleAreas(idx, step, block, possibleAreas); Area = possibleAreas.Random(); }
public void LevelUp(Block block) { GetNextArea(0, Step, block); IncrementStep(); }