void addHelperShips(List<Entity> children, Entity parent, ShipModelComponent component)
 {
     children.Add(_pool.CreateEntity()
         .AddPosition(new Vector2(0.5f, 0.0f))
         .AddResource(Resource.Player)
         .AddChild(parent)
         .IsLeaderFollower(true)
         .AddVelocity(new Vector2())
         .AddVelocityLimit(5.0f)
         .AddHomeMissileSpawner(0.0f, component.homeMissileSpawnDelay, component.homeMissileDamage, ResourceWithColliders.MissileHoming, component.homeMissileVelocity, new Vector2(-component.homeMissileVelocity, -1.0f), 1.0f, 3.0f, CollisionTypes.Player));
     children.Add(_pool.CreateEntity()
         .AddPosition(new Vector2(0.0f, 0.5f))
         .AddResource(Resource.Player)
         .AddChild(parent)
         .IsLeaderFollower(true)
         .AddVelocity(new Vector2())
         .AddVelocityLimit(5.5f)
         .AddHomeMissileSpawner(0.0f, component.homeMissileSpawnDelay, component.homeMissileDamage, ResourceWithColliders.MissileHoming, component.homeMissileVelocity, new Vector2(-component.homeMissileVelocity, -1.0f), 1.0f, 3.0f, CollisionTypes.Player));
     children.Add(_pool.CreateEntity()
         .AddPosition(new Vector2(-0.5f, 0.0f))
         .AddResource(Resource.Player)
         .AddChild(parent)
         .IsLeaderFollower(true)
         .AddVelocity(new Vector2())
         .AddVelocityLimit(6.0f)
         .AddHomeMissileSpawner(0.0f, component.homeMissileSpawnDelay, component.homeMissileDamage, ResourceWithColliders.MissileHoming, component.homeMissileVelocity, new Vector2(-component.homeMissileVelocity, -1.0f), 1.0f, 3.0f, CollisionTypes.Player));
 }
 public Entity ReplaceCurrentShip(ShipModelComponent newModel)
 {
     var component = CreateComponent<CurrentShipComponent>(ComponentIds.CurrentShip);
     component.model = newModel;
     ReplaceComponent(ComponentIds.CurrentShip, component);
     return this;
 }
 void addHomeMissile(List<Entity> children, Entity parent, ShipModelComponent component)
 {
     children.Add(_pool.CreateEntity()
                  .AddRelativePosition(0.5f, -0.5f)
                  .AddPosition(new Vector2(0.0f, 0.0f))
                  .AddChild(parent)
                  .AddHomeMissileSpawner(0.0f, component.homeMissileSpawnDelay, component.homeMissileDamage, ResourceWithColliders.MissileHoming, component.homeMissileVelocity, new Vector2(component.homeMissileVelocity * 0.6f, -1.2f), 0.25f, 3.0f, CollisionTypes.Player));
     children.Add(_pool.CreateEntity()
                  .AddRelativePosition(-0.5f, -0.5f)
                  .AddPosition(new Vector2(0.0f, 0.0f))
                  .AddChild(parent)
                  .AddHomeMissileSpawner(0.0f, component.homeMissileSpawnDelay, component.homeMissileDamage, ResourceWithColliders.MissileHoming, component.homeMissileVelocity, new Vector2(-component.homeMissileVelocity * 0.6f, -1.2f), 0.25f, 3.0f, CollisionTypes.Player));
 }
Example #4
0
 void addWeapons(ShipModelComponent component, ShipBonusComponent bonusComponent, Entity e)
 {
     float missileSpawnDelay = bonusComponent == null ? component.missileSpawnDelay : component.missileSpawnDelay * (1.0f - bonusComponent.fireRateBoost);
     float secondaryMissileSpawnDelay = bonusComponent == null ? component.secondaryMissileSpawnDelay : component.secondaryMissileSpawnDelay * (1.0f - bonusComponent.fireRateBoost);
     float damageFactor = bonusComponent == null ? 1.0f : 1.0f + bonusComponent.damageBoost;
     e.AddMissileSpawner(0.0f, (int)((float)component.missileDamage * damageFactor), missileSpawnDelay, ResourceWithColliders.MissilePrimary, new Vector2(0.0f, component.missileVelocity), CollisionTypes.Player);
     if (component.hasSecondaryMissiles)
     {
         List<Entity> children = e.parent.children;
         for (int i = 0; i < children.Count; i++)
         {
             Entity child = children[i];
             if (child.isSecondaryWeapon)
             {
                 child.AddMissileSpawner(0.0f, (int)((float)component.secondaryMissileDamage * damageFactor), secondaryMissileSpawnDelay, ResourceWithColliders.MissileSecondary, new Vector2(0.0f, component.secondaryMissileVelocity), CollisionTypes.Player);
             }
         }
     }
 }
Example #5
0
    void removeWeapons(ShipModelComponent component, Entity e)
    {
        if (e.hasMissileSpawner)
        {
            e.RemoveMissileSpawner();

            if (component.hasSecondaryMissiles)
            {
                List<Entity> children = e.parent.children;
                for (int i = 0; i < children.Count; i++)
                {
                    Entity child = children[i];
                    if (child.isSecondaryWeapon)
                    {
                        child.RemoveMissileSpawner();
                    }
                }
            }
        }
    }
Example #6
0
 void applyUpgrade(ShipModelComponent model, UpgradeType key, float bonus)
 {
     switch (key)
     {
         case UpgradeType.Health:
             model.health += (int)bonus;
             break;
         case UpgradeType.LaserDamage:
             model.hasLaser = true;
             model.laserDamage += (int)bonus;
             break;
         case UpgradeType.MagnetRadius:
             model.hasMagnetField = true;
             model.magnetRadius += bonus;
             break;
         case UpgradeType.MissileDamage:
             model.missileDamage += (int)bonus;
             break;
         case UpgradeType.MissileSpawnDelay:
             model.missileSpawnDelay -= bonus;
             break;
         case UpgradeType.MissileSpeed:
             model.missileVelocity += bonus;
             break;
         case UpgradeType.SecondaryMisileSpawnDelay:
             model.hasSecondaryMissiles = true;
             model.secondaryMissileSpawnDelay -= bonus;
             break;
         case UpgradeType.SecondaryMissileDamage:
             model.hasSecondaryMissiles = true;
             model.secondaryMissileDamage += (int)bonus;
             break;
         case UpgradeType.SecondaryMissileSpeed:
             model.hasSecondaryMissiles = true;
             model.secondaryMissileVelocity += bonus;
             break;
         case UpgradeType.Speed:
             model.maxVelocity += bonus;
             break;
     }
 }
Example #7
0
 void updateModelByUpgrade(ShipModelComponent model, UpgradeType key, int value)
 {
     while (value > 0)
     {
         float bonus = upgrades[key].bonus[value - 1];
         applyUpgrade(model, key, bonus);
         --value;
     }
 }
 public Entity AddCurrentShip(ShipModelComponent newModel)
 {
     var component = CreateComponent<CurrentShipComponent>(ComponentIds.CurrentShip);
     component.model = newModel;
     return AddComponent(ComponentIds.CurrentShip, component);
 }
    List<Entity> getShipChildren(Entity parent, ShipModelComponent component)
    {
        List<Entity> children = new List<Entity>();
        if (component.hasHomeMissile) {
            //addHomeMissile(children, parent, component);
        }
        if (component.hasSecondaryMissiles) {
            addSecondaryMissiles(children, parent);
        }
        //addHelperShips(children, parent, component);
        //addShield(children, parent, component);

        addNonRemovable(children);
        return children;
    }
Example #10
0
    void createShip(ShipModelComponent shipModel)
    {
        Entity ship = _pool.CreateEntity()
            .AddPlayer(shipModel.name)
            .AddPosition(new Vector2(0.0f, 0.0f))
            .AddVelocity(new Vector2(0.0f, 0.0f))
            .AddVelocityLimit(shipModel.maxVelocity)
            .AddCollision(CollisionTypes.Player, 10)
            .AddHealth(shipModel.health)
            .AddResource(ResourceWithColliders.Player)
            .AddExplosionOnDeath(1.0f, Resource.Explosion)
            .AddGhost(0.0f, 0.1f, 0.3f)
            .IsMoveWithCamera(true);

        ship.AddParent(getShipChildren(ship, shipModel));

        createUI(ship);
    }
Example #11
0
 void addShield(List<Entity> children, Entity parent, ShipModelComponent component)
 {
     children.Add(_pool.CreateEntity()
         .AddPosition(new Vector2(0.0f, 0.0f))
         .AddRelativePosition(0.0f, 0.0f)
         .AddChild(parent)
         .AddCollision(CollisionTypes.Player, 10)
         .AddHealth(component.health * 100)
         .AddShieldCollision(0.0f, 0.1f, new Queue<Vector2>())
         .IsCollisionPosition(true)
         .AddResource(ResourceWithColliders.PlayerShield));
 }