示例#1
0
        public void Init(
            IEnumerable <PlanetContext> planets,
            GravitySystem gravitySystem,
            SystemsUpdater systemsUpdater,
            HealthsContainer healthsContainer,
            RocketState[] rocketsStates
            )
        {
            MovementSystem = new RocketsMovementSystem(gravitySystem);
            systemsUpdater.AddPhysicsTicker(MovementSystem);
            _rocketsFactory = new RocketsFactory(
                _rockets,
                MovementSystem,
                _rocketsParent,
                healthsContainer,
                _cameraTransform
                );
            _rocketsFactory.CreateRockets(rocketsStates);

            foreach (var planet in planets)
            {
                planet.CannonProvider.SetFactory(_rocketsFactory);
                var cannon = planet.CannonProvider.GetCannon();
                systemsUpdater.AddFrameTicker(cannon);
            }
        }
示例#2
0
 public RocketsFactory(
     RocketsStorage rocketsStorage,
     RocketsMovementSystem movementSystem,
     Transform rocketsParent,
     HealthsContainer healthsContainer,
     Transform cameraTransform
     )
 {
     _storage          = rocketsStorage;
     _movementSystem   = movementSystem;
     _rocketsParent    = rocketsParent;
     _healthsContainer = healthsContainer;
     _cameraTransform  = cameraTransform;
 }
示例#3
0
        public void Init(
            GravitySystem gravitySystem,
            OrbitsSystem orbitsSystem,
            PlanetsStorage planetsStorage
            )
        {
            HealthsContainer = new HealthsContainer();
            foreach (var planet in planetsStorage.Planets)
            {
                HealthsContainer.AddHealth(planet.HealthProvider.GetHealth());
            }

            HealthsContainer.OnKilled += gravitySystem.Remove;
            HealthsContainer.OnKilled += orbitsSystem.Remove;
            HealthsContainer.OnKilled += planetsStorage.RemovePlanet;
        }