/// <summary> /// 生成新游戏 /// </summary> /// <param name="user">用户名</param> /// <param name="controller">控制器</param> /// <param name="withItem">是否启用道具</param> /// <returns></returns> public TetrisGame NewGame(string user = "", IController controller = null, bool withItem = true) { var id = games.Count; ITetrisFactory factory; if (withItem) { factory = new CacheFactory(Square.Styles(styles), ran); (factory as TetrisItemFactory).GenSpecialBlock = true; } else { factory = new TetrisFactory(Square.Styles(styles), ran); } // use AdvancedGUI.Styles.WindowSizeGenerator to set the game size! shuo han int gameWidth = AdvancedGUI.Styles.WindowSizeGenerator.gameWidth; int gameHeight = AdvancedGUI.Styles.WindowSizeGenerator.gameHeight; var game = new TetrisGame(id, Square.Styles(styles), _engine, factory, gameWidth, gameHeight, Settings.Default.DefaultSpeed); game.SetController(controller); ItemSystem.Bind(game); ScoreSystem.Bind(game); AchievementSystem.Bind(game, user); games[id] = game; return(game); }