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);
     }
 }
Example #3
0
 public ControllerFabric(IModel model, GameObject go)
 {
     _model = model;
     if (!go.TryGetComponent(out _rigidbody))
     {
         throw new ArgumentException("Невозможно получить RigidBody в " + model.GetType());
     }
     ControllersUpdater.AddUpdate(this);
 }
Example #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
        }
Example #5
0
 public void Load()
 {
     foreach (var data in _datas)
     {
         if (data is IUpdatable)
         {
             ControllersUpdater.RemoveUpdate((IUpdatable)data);
         }
         var item = data;
         _saver.Load(ref item, _folderPath);
     }
     Loaded.Invoke();
 }
        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);
        }
Example #7
0
 public void FromLoad()
 {
     ControllersUpdater.RemoveUpdate(this);
 }
 public void Dispose()
 {
     ServiceLocator.GetDependency<RadarController>().RemoveObject(_gameObject);
     ControllersUpdater.RemoveUpdate(this);
     _gameObject.SetActive(false);
 }
Example #9
0
 public EnemySpawner(Transform[] transforms, EnemyData data)
 {
     _pointsForSpawn.AddRange(transforms);
     _data = data;
     ControllersUpdater.AddUpdate(this);
 }
Example #10
0
 public void Reload()
 {
     ControllersUpdater.Dispose();
     ServiceLocator.Dispose();
     SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex);
 }
Example #11
0
 public EnemyController(EnemyModel model, GameObject go) : base(model, go)
 {
     ControllersUpdater.AddUpdate(this);
     _transform = go.transform;
     _model     = model;
 }