Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 private void Awake()
 {
     _displayBonuses = new DisplayBonuses();
     _material       = GetComponent <Renderer>().material;
     _lengthFlay     = UnityEngine.Random.Range(1.0f, 5.0f);
 }