public bool SendInput(Input keyPress) { if (State == GameState.InProgress) { if (Active != null) { if (keyPress == Input.MoveRight) { if (Active.GetBricks().All(a => a.X < Width - 1) && // wall !Collision(floor.ForEach().ToArray(), Active.GetBricks(Active.Position.AddX(1), Active.Rotation).ToArray()) ) { Active.Position = Active.Position.AddX(1); return(true); } return(false); } else if (keyPress == Input.MoveLeft) { if (Active.GetBricks().All(a => a.X > 0) && !Collision(floor.ForEach().ToArray(), Active.GetBricks(Active.Position.AddX(-1), Active.Rotation).ToArray()) ) { Active.Position = Active.Position.AddX(-1); return(true); } return(false); } else if (keyPress == Input.Rotate) { if (Active.GetBricks(Active.Rotation + 1).All(a => a.X >= 0 && a.X < Width)) { Active.Rotation++; return(true); } return(false); } else if (keyPress == Input.Drop) { while (!TouchesFloorPile(Active)) { Active.Position = Active.Position.AddY(1); } return(true); } } if (keyPress == Input.Quit) { SetMessage("Quitting... Bye Bye!"); State = GameState.GameOver; return(true); } } else if (State == GameState.WaitingStart && keyPress == Input.Start) { SetMessage("Good Luck..."); State = GameState.InProgress; Next = RandomHelper.ChooseOne(Tetromino.All); Active = CreatePiece(Next); Next = RandomHelper.ChooseOne(Tetromino.All); return(true); } return(true); }