Example #1
0
        public static BaseEnemy CreateNew(EnemyTypes enemyType, SerializableChromosome chromosome = null, bool isHorde = false)
        {
            BaseEnemy newEnemy;

            switch (enemyType)
            {
            case EnemyTypes.Chicken1: newEnemy = Chicken1EnemyFactory.CreateNew(); break;

            case EnemyTypes.Chicken2: newEnemy = Chicken2EnemyFactory.CreateNew(); break;

            case EnemyTypes.Chicken3: newEnemy = Chicken3EnemyFactory.CreateNew(); break;

            case EnemyTypes.Rabbit1: newEnemy = Rabbit1EnemyFactory.CreateNew(); break;

            case EnemyTypes.Rabbit2: newEnemy = Rabbit2EnemyFactory.CreateNew(); break;

            case EnemyTypes.Rabbit3: newEnemy = Rabbit3EnemyFactory.CreateNew(); break;

            case EnemyTypes.Sheep1: newEnemy = Sheep1EnemyFactory.CreateNew(); break;

            case EnemyTypes.Sheep2: newEnemy = Sheep2EnemyFactory.CreateNew(); break;

            case EnemyTypes.Sheep3: newEnemy = Sheep3EnemyFactory.CreateNew(); break;

            case EnemyTypes.Cow1: newEnemy = Cow1EnemyFactory.CreateNew(); break;

            case EnemyTypes.Cow2: newEnemy = Cow2EnemyFactory.CreateNew(); break;

            case EnemyTypes.Cow3: newEnemy = Cow3EnemyFactory.CreateNew(); break;

            case EnemyTypes.Pig1: newEnemy = Pig1EnemyFactory.CreateNew(); break;

            case EnemyTypes.Pig2: newEnemy = Pig2EnemyFactory.CreateNew(); break;

            case EnemyTypes.Pig3: newEnemy = Pig3EnemyFactory.CreateNew(); break;

            default:
                throw new ArgumentOutOfRangeException(nameof(enemyType), enemyType, null);
            }

            if (isHorde)
            {
                newEnemy.RushEndPoint();
            }
            else
            {
                newEnemy.OnDeath += OnCreateAction;
                newEnemy.FollowLine();
                newEnemy.SetGenetics(chromosome ?? GeneticsManager.GenerateNewChromsome());
            }

            return(newEnemy);
        }
Example #2
0
        private void InitializeFactories()
        {
            StructurePlacementFactory.EntitySpawned +=
                placement => placement.AddSpritesToLayers(LightLayer, InfoLayer);

            //Projectiles
            PiercingProjectileFactory.Initialize(ContentManagerName);
            PiercingProjectileFactory.EntitySpawned +=
                projectile => projectile.AddSpritesToLayers(LightLayer, InfoLayer);

            CannonProjectileFactory.Initialize(ContentManagerName);
            CannonProjectileFactory.EntitySpawned +=
                projectile => projectile.AddSpritesToLayers(LightLayer, InfoLayer);

            ElectricProjectileFactory.Initialize(ContentManagerName);
            ElectricProjectileFactory.EntitySpawned +=
                projectile => projectile.AddSpritesToLayers(LightLayer, InfoLayer);

            FireProjectileFactory.Initialize(ContentManagerName);
            FireProjectileFactory.EntitySpawned +=
                projectile => projectile.AddSpritesToLayers(LightLayer, InfoLayer);

            FrostProjectileFactory.Initialize(ContentManagerName);
            FrostProjectileFactory.EntitySpawned +=
                projectile => projectile.AddSpritesToLayers(LightLayer, InfoLayer);

            ChemicalProjectileFactory.Initialize(ContentManagerName);
            ChemicalProjectileFactory.EntitySpawned +=
                projectile => projectile.AddSpritesToLayers(LightLayer, InfoLayer);

            //Towers
            BombardingTowerFactory.Initialize(ContentManagerName);
            BombardingTowerFactory.EntitySpawned +=
                turrent => turrent.AddSpritesToLayers(LightLayer, InfoLayer);

            ChemicalTowerFactory.Initialize(ContentManagerName);
            ChemicalTowerFactory.EntitySpawned +=
                turrent => turrent.AddSpritesToLayers(LightLayer, InfoLayer);

            ElectricTowerFactory.Initialize(ContentManagerName);
            ElectricTowerFactory.EntitySpawned +=
                turrent => turrent.AddSpritesToLayers(LightLayer, InfoLayer);

            FireTowerFactory.Initialize(ContentManagerName);
            FireTowerFactory.EntitySpawned +=
                turrent => turrent.AddSpritesToLayers(LightLayer, InfoLayer);

            FrostTowerFactory.Initialize(ContentManagerName);
            FrostTowerFactory.EntitySpawned +=
                turrent => turrent.AddSpritesToLayers(LightLayer, InfoLayer);

            PiercingTowerFactory.Initialize(ContentManagerName);
            PiercingTowerFactory.EntitySpawned +=
                turrent => turrent.AddSpritesToLayers(LightLayer, InfoLayer);

            //Enemies
            Chicken1EnemyFactory.Initialize(ContentManagerName);
            Chicken1EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Chicken2EnemyFactory.Initialize(ContentManagerName);
            Chicken2EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Chicken3EnemyFactory.Initialize(ContentManagerName);
            Chicken3EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Cow1EnemyFactory.Initialize(ContentManagerName);
            Cow1EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Cow2EnemyFactory.Initialize(ContentManagerName);
            Cow2EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Cow3EnemyFactory.Initialize(ContentManagerName);
            Cow3EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Pig1EnemyFactory.Initialize(ContentManagerName);
            Pig1EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Pig2EnemyFactory.Initialize(ContentManagerName);
            Pig2EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Pig3EnemyFactory.Initialize(ContentManagerName);
            Pig3EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Sheep1EnemyFactory.Initialize(ContentManagerName);
            Sheep1EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Sheep2EnemyFactory.Initialize(ContentManagerName);
            Sheep2EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Sheep3EnemyFactory.Initialize(ContentManagerName);
            Sheep3EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Rabbit1EnemyFactory.Initialize(ContentManagerName);
            Rabbit1EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Rabbit2EnemyFactory.Initialize(ContentManagerName);
            Rabbit2EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };

            Rabbit3EnemyFactory.Initialize(ContentManagerName);
            Rabbit3EnemyFactory.EntitySpawned +=
                enemy =>
            {
                enemy.AddSpritesToLayers(WorldLayer, LightLayer, InfoLayer);
                enemy.OnDeath += MachineLearningManager.UpdateWaveScore;
            };
        }