Beispiel #1
0
 public void Initialize()
 {
     _bullets = new List <IGameObject>();
     for (int i = 0; i < Math.Round(GameConstants.ProjectileConstants.MaxBulletsOnScreen * 0.8); i++)
     {
         var bullet = _projectileFactory.CreateBullet();
         bullet.Initialize();
         _collisionSystem.RegisterEntity(bullet);
         _bullets.Add(bullet);
     }
 }
Beispiel #2
0
    public CelestialSystem CreateFromSerialized(IProjectileFactory projectileFactory, IPlanetFactory planetFactory,
                                                IWeaponFactory weaponFactory)
    {
        var celestialSystem = resolver.Resolve <CelestialSystem>();
        var planets         = new List <IPlanet>();

        var central           = scs.planets.First(planet => planet.isCentral);
        var centralStarPlanet = planetFactory.CreatePlanet(central.entity.pos);

        central.entity.FillIn(centralStarPlanet.SimulatedEntity);
        celestialSystem.AddCentralStar(centralStarPlanet);

        foreach (var serializedPlanet in scs.planets.Except(new [] { central }))
        {
            var appearance = new PlanetAppearance()
            {
                color = serializedPlanet.color
            };
            var planet = planetFactory.CreatePlanet(serializedPlanet.entity.pos, appearance);
            weaponFactory.AddWeapon(serializedPlanet.weaponType, planet);
            serializedPlanet.entity.FillIn(planet.SimulatedEntity);
            planets.Add(planet);
        }
        celestialSystem.AddRaw(planets);
        projectileFactory.celestialSystem = celestialSystem;

        foreach (var projectile in scs.projectiles)
        {
            var proj = projectileFactory.CreateBullet(projectile.entity.pos);
            projectile.entity.FillIn(proj);
        }

        return(celestialSystem);
    }
Beispiel #3
0
    private void ShootImpl(Vector2 direction)
    {
        Vector2 pos2d = planet.SimulatedEntity.Position;
        var     distanceFromCenter = 0.4f;
        var     bulletEntity       = projectileFactory.CreateBullet(pos2d + direction * distanceFromCenter) as GravitatingObject;

        bulletEntity.Velocity            = planet.SimulatedEntity.Velocity;
        bulletEntity.Acceleration        = direction * 3;
        bulletEntity.TimeForAcceleration = 0.3f;

        var bullet = bulletEntity.GetComponent <Bullet>();

        bullet.SetOwnership(planet, 1f);

        ReloadAmount = 0;
    }