Example #1
0
    public Turret CreateTurret(TurretType turretType)
    {
        Turret     Turret     = null;
        GameObject TurretGO   = FactoryManager.assetFactory.LoadTurret(turretType.ToString());
        TurretAttr TurretAttr = FactoryManager.attrFactory.GetTurretAttr(turretType);

        switch (turretType)
        {
        case TurretType.ShellTurret:
            Turret = new TurretShell(TurretGO, TurretAttr);
            break;

        case TurretType.MissileLauncher:
            Turret = new TurretMissile(TurretGO, TurretAttr);
            break;

        case TurretType.LaserBeamer:
            Turret = new TurretLaser(TurretGO, TurretAttr);
            break;

        case TurretType.CanonTurret:
            Turret = new TurretCanon(TurretGO, TurretAttr);
            break;
        }
        return(Turret);
    }
Example #2
0
        public void CreateProjectile(ProjectileTypes type,
                                     Vector2 position, Vector2 velocityOffset, float rotation,
                                     int projectileID, ICanFire firingObj, float charge, byte firingWeaponSlot)
        {
            IProjectile proj = null;

            Vector2 projectileVelocity = new Vector2(velocityOffset.X / 1000f + (float)(Math.Sin(rotation)) * _flyweights[type].BaseSpeed / 1000f,
                                                     velocityOffset.Y / 1000f - (float)(Math.Cos(rotation)) * _flyweights[type].BaseSpeed / 1000f);


            if (firingObj is Turret)
            {
                proj = new TurretLaser(_collisionManager, _spriteBatch, projectileID, firingWeaponSlot, ((Turret)firingObj).TurretType, _world);

                proj.BodyData = new ProjectileBodyDataObject(BodyTypes.Projectile, projectileID, firingObj, proj);
            }
            else
            {
                switch (type)
                {
                case ProjectileTypes.Laser:
                    proj = new LaserProjectile(_collisionManager, _spriteBatch, projectileID, firingWeaponSlot, _world);

                    break;

                case ProjectileTypes.LaserWave:
                    proj = new LaserWaveProjectile(_collisionManager, _particleManager, projectileVelocity, _spriteBatch, projectileID, firingWeaponSlot, _world);

                    break;

                case ProjectileTypes.PlasmaCannon:
                    proj = new PlasmaCannonProjectile(_collisionManager, _spriteBatch, projectileID, firingWeaponSlot, _world, charge);

                    break;

                case ProjectileTypes.BC_Laser:
                    proj = new BC_LaserProjectile(_collisionManager, _spriteBatch, projectileID, firingWeaponSlot, _world);
                    break;

                case ProjectileTypes.GravityBomb:
                    proj = new GravityBombProjectile(_collisionManager, _particleManager, projectileVelocity, firingObj, _world, projectileID, firingWeaponSlot, position);
                    break;

                case ProjectileTypes.MineSplash:
                    proj = new MineSplash(position, _world, _collisionManager, projectileID, firingWeaponSlot);
                    break;

                default:
                    ConsoleManager.WriteLine("ERROR: ProjectileType " + type + " not implemented in ProjectileManager.CreateProjectile().", ConsoleMessageType.Error);
                    break;
                }

                // Proj could be null here, but it should be an easy catch if we forget to add a switch case and it breaks
                proj.BodyData = new ProjectileBodyDataObject(BodyTypes.Projectile, projectileID, firingObj, proj);
            }



            proj.LinearVelocity = projectileVelocity;
            proj.Rotation       = rotation;
            proj.Position       = position;
            proj.Id             = projectileID;

            _projectileList.Add(proj);
        }