void UpdateLogic() { if (ticks_to_spawn-- == 0) { ticks_to_spawn = SPAWN_PERIOD; Tetromino tetromino = Instantiate(PRESETS[Random.Range(0, PRESETS.Length)]); TetrominoFactory.FromPreset(tetromino); tetrominos.Add(tetromino); } for (int i = 0; i < tetrominos.Count; ++i) { tetrominos[i].WriteVoxels(i); } for (int i = 0; i < tetrominos.Count; ++i) { tetrominos[i].UpdateFalling(i); } for (int i = 0; i < tetrominos.Count; ++i) { tetrominos[i].Fall(i); } // do stuff that would change indices here }
/// <summary> /// Initializes the field, TetrominoFactory, queues and gameplay states needed for handling the gameplay logic /// </summary> public GameplayScreen(bool isDemo) : base() { field = new Field(new Point(0, -(Globals.MinoHeight * 2)), Globals.FieldWidth, Globals.FieldHeight); factory = new TetrominoFactory(); nextQueue = new Queue <Tetromino>(); currentGameplayState = isDemo ? GameplayState.DemoStart : GameplayState.PlayerStart; fallSpeed = 0; fallSpeedDelta = fallSpeed; LevelGoals = new int[] { 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75 }; FallSpeeds = new int[] { 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 25, 10 }; linesClearedDelta = LevelGoals[level]; fallSpeed = FallSpeeds[level]; nextQueue.Enqueue(factory.GenerateRandomTetromino()); }