Ejemplo n.º 1
0
        //Initialize game data
        private void Initialize()
        {
            //Enemies
            this.currentEnemies = new ObservableCollection <Enemy>();
            //When enemy is added or removed from collection "updateEnimies" is automatically called
            this.currentEnemies.CollectionChanged += UpdateEnemies;

            //Initialize lists
            this.playerBullets = new List <PlayerBullet>();
            this.enemyBullets  = new List <EnemyBullet>();
            this.deadBullets   = new List <Bullet>();

            //Initialize enemy factories
            this.enemyAFact    = new EnemyAFactory();
            this.enemyBFact    = new EnemyBFactory();
            this.midBossFact   = new MidBossFactory();
            this.finalBossFact = new FinalBossFactory();

            //Initialize bullet factories
            this.playerBulletFact     = new PlayerBulletFactory();
            this.playerSpecBulletFact = new PlayerSpecialBulletFactory();
            this.enemyABulletFact     = new EnemyABulletFactory();
            this.enemyBBulletFact     = new EnemyBBulletFactory();
            this.midBossBulletFact    = new MidBossBulletFactory();
            this.finalBossBulletFact  = new FinalBossBulletFactory();

            //Set difficulty to medium to start
            difficulty = Difficulty.Medium;
        }
Ejemplo n.º 2
0
    private Spawner <Ship> CreatePlayerShipSpawner()
    {
        var shipSpawnerGameObject = Game.Create <GameObject>();

        var shipSpawnerTransform = shipSpawnerGameObject.AddComponent <Transform>();

        shipSpawnerTransform.Position  = new Vector2(0, 0);
        shipSpawnerTransform.Scale     = new Vector2(3, 3);
        shipSpawnerTransform.Direction = new Vector2(0, 1);

        var shipSpawnerComponent = shipSpawnerGameObject.AddComponent <Spawner <Ship> >();

        var shipFactory            = new PlayerShipFactory();
        var playerBulletFactory    = new PlayerBulletFactory();
        var playerLaserAmmoFactory = new PlayerLaserAmmoFactory();

        playerBulletFactory.Spawned.AddListener((x) => unityPlayerBulletsFactory.OnSpawn(game, x));
        shipFactory.BulletFactory = playerBulletFactory;

        playerLaserAmmoFactory.Spawned.AddListener((x) => unityPlayerLaserAmmoFactory.OnSpawn(game, x));
        shipFactory.LaserAmmoFactory = playerLaserAmmoFactory;

        shipFactory.Spawned.AddListener((x) => unityPlayerShipFactory.OnSpawn(game, x));

        shipSpawnerComponent.Factory = shipFactory;

        return(shipSpawnerComponent);
    }
 public override PlayerBullet CreatePlayerBullet(Vector2 playerPos)
 {
     return(PlayerBulletFactory.CreatePlayerBullet(playerPos));
 }