public InteractableObjectsController(GameObject gameObject, int objectID)
 {
     _objectID = objectID;
     _gameObject = gameObject;
     ControllersUpdater.AddUpdate(this);
     IsActive = true;
 }
 public void FromLoad()
 {
     Debug.Log(ObjectID + IsActive);
     if (IsActive)
     {
         _gameObject.SetActive(true);
         ControllersUpdater.AddUpdate(this);
     }
 }
Пример #3
0
 public ControllerFabric(IModel model, GameObject go)
 {
     _model = model;
     if (!go.TryGetComponent(out _rigidbody))
     {
         throw new ArgumentException("Невозможно получить RigidBody в " + model.GetType());
     }
     ControllersUpdater.AddUpdate(this);
 }
Пример #4
0
        private void Start()
        {
            if (GameObject.FindObjectsOfType <Transform>().Length <= 4)
            {
                SceneSaver.LoadScene();
            }
            else
            {
                _startPoint = GameObject.FindGameObjectWithTag("Respawn").transform;
                _uiGameOver = GameObject.FindGameObjectWithTag("Finish");
                _sliderUI   = GameObject.FindGameObjectWithTag("Slider").GetComponent <Slider>();
                var enemyesRespawns = GameObject.FindGameObjectsWithTag("EnemyRespawn");
                _pointsForEnemySpawn = new Transform[enemyesRespawns.Length];

                for (int i = 0; i < enemyesRespawns.Length; i++)
                {
                    _pointsForEnemySpawn[i] = enemyesRespawns[i].transform;
                }

                _interactiveObjects = GameObject.FindGameObjectWithTag("Bonuses").transform.GetComponentsInChildren <Transform>();

                var repository = new Repository(_serializer);
                ServiceLocator.SetDependency(repository);
                GameObject updaterGO = new GameObject("Updater");
                updaterGO.AddComponent <ControllersUpdater>();

                RadarController radar = new RadarController(FindObjectsOfType <Image>().FirstOrDefault(x => x.gameObject.CompareTag("Bonuses")).transform);
                ServiceLocator.SetDependency(radar);
                ControllersUpdater.AddUpdate(radar);

                _sliderUI.maxValue = _interactiveObjects.Length;
                var slider = new SliderController(_sliderUI);
                //ServiceLocator.SetDependency(slider);

                var gameOverChecker = new GameOverChecker(_uiGameOver, slider);
                new ButtonReloaderView(_uiGameOver.GetComponentInChildren <Button>());
                ServiceLocator.SetDependency(gameOverChecker);
                gameOverChecker.GameEnd(false, false);
                new PlayerInizializator(_playerData, _startPoint, UserName);

                //ServiceLocator.GetDependency<Repository>().AddDataToList(slider);
                repository.AddDataToList(slider);


                for (int i = 0; i < _interactiveObjects.Length; i++)
                {
                    var bonus = new PointBonus(_interactiveObjects[i].gameObject, i, slider);
                    repository.AddDataToList(bonus);
                    var sprite = Resources.Load <GameObject>("Textures/PickupRadar");
                    radar.AddingObject(_interactiveObjects[i].gameObject, sprite);
                }
                new EnemySpawner(_pointsForEnemySpawn, _enemyData);
                Destroy(gameObject);
            }

            #endregion
        }
Пример #5
0
        public void Initialize()
        {
            var player           = GameObject.Instantiate(_gameObject, _startPosition, _startRotation);
            var playerModel      = new PlayerModel(_struct);
            var playerController = new PlayerController(playerModel, player);
            var playerView       = new PlayerView(playerController, player);

            ServiceLocator.SetDependency(player);
            ServiceLocator.SetDependency(playerModel);
            ControllersUpdater.AddUpdate(playerView);
            var camera = new CameraController(ServiceLocator.GetDependency <GameObject>().transform);

            ControllersUpdater.AddUpdate(camera);
            ServiceLocator.SetDependency(camera);
            ServiceLocator.GetDependency <Repository>().AddDataToList(new PlayerSaveData(_playerName, playerModel, player.transform));
            var playerSprite = Resources.Load <GameObject>("Textures/PlayerRadar");

            ServiceLocator.GetDependency <RadarController>().AddingObject(player, playerSprite);
        }
Пример #6
0
 public EnemySpawner(Transform[] transforms, EnemyData data)
 {
     _pointsForSpawn.AddRange(transforms);
     _data = data;
     ControllersUpdater.AddUpdate(this);
 }
Пример #7
0
 public EnemyController(EnemyModel model, GameObject go) : base(model, go)
 {
     ControllersUpdater.AddUpdate(this);
     _transform = go.transform;
     _model     = model;
 }