private void Awake() { _reference = new Reference(); PlayerBase player = null; if (PlayerType == PlayerType.Ball) { player = _reference.PlayerBall; } _radar = new Radar(player, _radarGameObject, this); //_listFixedUpdateObjects = new ListExecuteObject(); _listFixedUpdateObjects = new List <IExecute>(); var interactiveObjects = UnityEngine.Object.FindObjectsOfType <InteractiveObject>(); for (var i = 0; i < interactiveObjects.Length; i++) { interactiveObjects[i].gameObject.AddComponent <RadarObj>().SetRadar(_radar); if (interactiveObjects[i] is IExecute interactiveObject) { _listFixedUpdateObjects.Add(interactiveObject); } } _listLateUpdateObjects = new List <IExecute>(); _listUpdateObjects = new List <IExecute>(); _cameraController = new CameraController(player.transform, _reference.MainCamera.transform); _listLateUpdateObjects.Add(_cameraController); _miniMap = new MiniMap(_miniMapGameObject); _listLateUpdateObjects.Add(_miniMap); _listUpdateObjects.Add(_radar); _playerController = new PlayerController(player, _effectData); _listUpdateObjects.Add(_playerController); _effectManager = new EffectManager(_playerController, _effectData, this); _displayingInformation = new DisplayingInformation(_playerController); _checkForWinGame = new CheckForWinGame(this); //с этим управление в билде не работает //if (Application.platform == RuntimePlatform.WindowsEditor) //{ // _inputController = new InputController(player); // _interactiveObject.AddExecuteObject(_inputController); //} //List<InteractiveObject> interactiveObjects1 = new List<InteractiveObject>(); //for(int i = 0; i < _listFixedUpdateObjects.Count; i++) //{ // if(_listFixedUpdateObjects[i] is InteractiveObject interactiveObject) // { // interactiveObjects1.Add(interactiveObject); // } //} _inputController = new InputController(player, new List <InteractiveObject>(interactiveObjects)); _listFixedUpdateObjects.Add(_inputController); _displayEndGame = new DisplayEndGame(_reference.EndGame); _displayBonuses = new DisplayBonuses(_reference.Bonuse); _displayStartGame = new DisplayStartGame(_reference.EndGame); _displayWinGame = new DisplayWinGame(_reference.EndGame, this); foreach (var o in _listFixedUpdateObjects) { if (o is BadBonus badBonus) { badBonus.SetEffectManager(_effectManager); //я избавился от всех событий, эти строки кода стали не нужны //badBonus.OnCaughtPlayerChange += CaughtPlayer; //badBonus.OnCaughtPlayerChange += _displayEndGame.GameOver; } if (o is GoodBonus goodBonus) { goodBonus.SetEffectManager(_effectManager); GoodBonusesCount++; //goodBonus.OnPointChange += AddBonuse; } } _reference.RestartButton.onClick.AddListener(RestartGame); _reference.RestartButton.gameObject.SetActive(false); _reference.StartButton.onClick.AddListener(StartGame); _displayStartGame.StartGame(); Time.timeScale = 0.0f; }