private void Start() { Button newButton; _configMenu = new ConfigurationMenu("МЕНЮ", _prefabCamera, _prefabCube); _configs.Add(new ConfigurationMode1("ПЕРВЫЙ РЕЖИМ", _prefabCamera, _prefabCube)); _configs.Add(new ConfigurationMode2("ВТОРОЙ РЕЖИМ", _prefabCamera, _prefabCube)); _map = _configMenu.CreateMap(); _generator = _configMenu.CreateGenerator(); _factory = _configMenu.CreateFactoryFigure(); _mover = _configMenu.CreateMover(); _vectorDrop = _configMenu.CreateVectorDrop(); _delayDrop = _configMenu.DelayFrameDrop(); _map.SetCamera(_prefabCamera); foreach (var config in _configs) { newButton = Instantiate(_prefabButton, this.transform).GetComponent <Button>(); newButton.GetComponentInChildren <Text>().text = config.Name; newButton.onClick.AddListener(delegate { NewGame(config); }); _buttons.Add(newButton); } newButton = Instantiate(_prefabButton, this.transform).GetComponent <Button>(); newButton.GetComponentInChildren <Text>().text = "ВЫХОД"; newButton.onClick.AddListener(ExitGame); _buttons.Add(newButton); }
/// <summary> Класс описывает логику игры на SceneGame (Компонент Model). </summary> /// <see> Для получения информации по сущностям перейдите в Scripts/Global/GameConfigurators/AbstractConfigurator.cs </see> public TetrisGame() { AbstractConfigurator configurator = DataConfigs.LoadConfigurator(); if (configurator == null) { throw new TetrisException("Не выбран режим игры!"); } _map = configurator.CreateMap(); _generator = configurator.CreateGenerator(); _factory = configurator.CreateFactoryFigure(); _mover = configurator.CreateMover(); _rotator = configurator.CreateRotator(); _vectorDrop = configurator.CreateVectorDropInt(); _delayDrop = configurator.DelayFrameDrop(); _obstructions = configurator.CreateObstructions(); _stackFigures = configurator.CreateStackFigures(); _figure = _generator.NewFigure(_factory); }