// fsm interface public void FillForInit(float aniTime) { sequence = new Sequence(blockGenerator); // needs optimization while (true) { var matches = new Solver(sequence).SearchPatternIn(); if (matches.IsNullOrEmpty()) { break; } sequence = new Sequence(blockGenerator); } for (int i = 0; i < PuzzleOption.BlockCountX; i++) { for (int j = PuzzleOption.BlockCountY - 1; j >= 0; j--) { var block = sequence.blocks.Get(i, j); if (j == PuzzleOption.BlockCountY - 1) { block.Offset = block.Offset - new Vector2(0, PuzzleOption.BlockCountY + Random.Range(0f, 2f)); } else { var below = sequence.blocks.Get(i, j + 1); block.Offset = below.Offset - new Vector2(0, 1f + Random.Range(0f, 2f)); } sequence.blocks.Set(i, j, block); } } aniStartTime = TimeTool.time; aniFullTime = aniTime; SetDirty(); }