Beispiel #1
0
 private void Awake()
 {
     _interactableObject = new ListInteractableObject();
     _displayEndGame     = new DisplayEndGame(_finishGameLabel);
     foreach (var item in _interactableObject)
     {
         if (item is BadBonus badBonus)
         {
             badBonus.CaughPlayer += CaughPlayer;
             badBonus.CaughPlayer += _displayEndGame.GameOver;
             badBonus.CaughPlayer += (sender, args) =>
             { Debug.Log($"Вы проиграли. Вас убил {((InteractiveObject)sender).name} {args.Color} цвета"); };
         }
     }
 }
Beispiel #2
0
        private void Awake()
        {
            new GameInitializator();

            _interactiveObject  = new ListExecuteObject();
            _saveDataRepository = new SaveDataRepository();
            _reference          = new Reference();

            PlayerBase player = null;

            if (PlayerType == PlayerType.Ball)
            {
                player          = _reference.PlayerBall;
                _saveController = new SaveController(player);
            }

            _cameraController = new CameraController(player.transform, _reference.CameraMain.transform);
            _interactiveObject.AddExecuteObject(_cameraController);

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                _inputController = new InputController(player, _saveController, _saveDataRepository);
                _interactiveObject.AddExecuteObject(_inputController);
            }


            if (_reference.Ghost)
            {
                _interactiveObject.AddExecuteObject(_reference.Ghost);
            }


            for (int i = 0; i < CountEnemy; i++)
            {
                var tp    = _reference.Ghost.GeneratePoint();
                var ghost = Instantiate(_reference.Ghost, tp, Quaternion.identity);
                _interactiveObject.AddExecuteObject(ghost);
            }

            _displayEndGame = new DisplayEndGame(_reference.EndGame);
            _displayBonuses = new DisplayBonuses(_reference.Bonuse);

            foreach (var soloObject in _interactiveObject)
            {
                if (soloObject is BadBonus badBonus)
                {
                    badBonus.OnCaughtPlayerChange += CaughtPlayer;
                    badBonus.OnCaughtPlayerChange += _displayEndGame.GameOver;

                    _saveController.ListObjects.Add(badBonus);
                    //badBonus.AddTo(_saveController.ListObjects);
                }

                if (soloObject is GoodBonus goodBonus)
                {
                    goodBonus.OnPointChange += AddBonuse;

                    _saveController.ListObjects.Add(goodBonus);
                    //goodBonus.AddTo(_saveController.ListObjects);
                }
            }

            _reference.RestartButton.onClick.AddListener(RestartGame);
            _reference.RestartButton.gameObject.SetActive(false);
        }