public Spawner(LevelScreen screen, EnemyFormation formation, float spawnTime, EnemyFormation dependantFormation) { this.screen = screen; this.formation = formation; this.spawnTime = spawnTime; this.dependantFormation = dependantFormation; spawnTimer = 0; // start the spawner ready to spawn dead = false; }
public void update(TimeSpan timeSpan) { if (screen.getMapOffset().X + PikeAndShotGame.SCREENWIDTH > formation.getPosition().X) dead = true; else if(dependantFormation != null && !findDependantFormation(screen._enemyFormations)) dead = true; else{ spawnTimer -= (float)timeSpan.TotalMilliseconds; if (spawnTimer <= 0f) { EnemyFormation newFormation = new EnemyFormation(formation.name = " spawn", formation._pattern, screen, formation.getPosition().X, formation.getPosition().Y, 10, formation.getSide()); spawnTimer = spawnTime; screen._enemyFormations.Add(newFormation); foreach (Soldier s in formation.getSoldiers()) Soldier.getNewSoldier(s.getClass(), screen, newFormation, newFormation.getPosition().X, newFormation.getPosition().Y); } } }
private void assignRescue(EnemyFormation formation, int type) { if (_formation.numberOfPikes < 10 || _formation.numberOfShots < 10) { Soldier soldier; switch(type) { case Soldier.TYPE_PIKE: soldier = new Pikeman(this, formation.getPosition().X, formation.getPosition().Y, SIDE_PLAYER); break; case Soldier.TYPE_SHOT: soldier = new Arquebusier(this, formation.getPosition().X, formation.getPosition().Y, SIDE_PLAYER); break; case Soldier.TYPE_SWINGER: if(doppelType) soldier = new Dopple(this, formation.getPosition().X, formation.getPosition().Y, SIDE_PLAYER); else soldier = new CrossbowmanPavise(this, formation.getPosition().X, formation.getPosition().Y, SIDE_PLAYER); break; default: soldier = new Dopple(this, formation.getPosition().X, formation.getPosition().Y, SIDE_PLAYER); break; } formation.addSoldier(soldier); soldier.setSpeed(0.25f); } //TODO: HEY MAN, THIS COULD CAUSE PRO-BLEMS else { formation.addSoldier(new Dopple(this, formation.getPosition().X, formation.getPosition().Y, SIDE_PLAYER)); } }
protected void checkLevelData() { for(int f = 0; f < _levelData.formations.Count; f++) { if (_levelData.formationTimes[f] <= (double)_mapOffset.X + PikeAndShotGame.SCREENWIDTH && !_usedFormations.Exists(i => i == f)) { _usedFormations.Add(f); _newEnemyFormation = new EnemyFormation(_levelData.formationNames[f], _levelData.formationActions[f], this, (_levelData.formationPositions[f]).X, (_levelData.formationPositions[f]).Y, 10, _levelData.formationSides[f]); string formationName = _levelData.formationNames[f]; float x = _newEnemyFormation.getPosition().X; float y = _newEnemyFormation.getPosition().Y; for (int i = 0; i < _levelData.formations[f].Count; i++) { Soldier.getNewSoldier((_levelData.formations[f])[i], this, _newEnemyFormation, x, y); } if (formationName.StartsWith("spawner:")) { foreach (Soldier s in _newEnemyFormation.getSoldiers()) this.removeScreenObject(s); char[] separator = { ':' }; EnemyFormation dependantFormation = getDependantFormation(formationName.Split(separator)[2]); Spawner newSpawner = new Spawner(this, _newEnemyFormation, float.Parse(formationName.Split(separator)[1]), dependantFormation); _spawners.Add(newSpawner); } else { _enemyFormations.Add(_newEnemyFormation); } } } for (int f = 0; f < _levelData.terrains.Count; f++) { if (_levelData.terrainTimes[f] <= (double)_mapOffset.X + PikeAndShotGame.SCREENWIDTH && !_usedTerrain.Exists(i => i == f)) { _usedTerrain.Add(f); Terrain.getNewTerrain(_levelData.terrains[f], this, _levelData.terrainPositions[f].X, _levelData.terrainPositions[f].Y, f); } } }
public Vector2 spawnRescue(int type) { EnemyFormation formation; formation = new EnemyFormation("Reinforcement", null, this, getMapOffset().X - Soldier.WIDTH, _formation._position.Y, 1, SIDE_PLAYER); assignRescue(formation, type); _enemyFormationsToAdd.Add(formation); return formation.getPosition(); }
void FormListener.updateLevel(Level level, int selectedFormation) { _levelData = level; foreach (EnemyFormation f in _enemyFormations) { _deadFormations.Add(f); } foreach (Terrain t in _terrain) { _deadThings.Add(t); } _enemyFormations.Clear(); _terrain.Clear(); for (int f = 0; f < _levelData.formations.Count; f++) { _newEnemyFormation = new EnemyFormation(_levelData.formationNames[f], _levelData.formationActions[f], this, (_levelData.formationPositions[f]).X, (_levelData.formationPositions[f]).Y, 5, _levelData.formationSides[f], f); for (int i = 0; i < _levelData.formations[f].Count; i++) { switch ((_levelData.formations[f])[i]) { case Soldier.CLASS_MERC_PIKEMAN: _newEnemyFormation.addSoldier(new Pikeman(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_ENEMY)); break; case Soldier.CLASS_MERC_ARQUEBUSIER: _newEnemyFormation.addSoldier(new Arquebusier(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_ENEMY)); break; case Soldier.CLASS_MERC_CROSSBOWMAN: _newEnemyFormation.addSoldier(new Crossbowman(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_ENEMY)); break; case Soldier.CLASS_MERC_SOLDIER: _newEnemyFormation.addSoldier(new Targeteer(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_ENEMY)); break; case Soldier.CLASS_GOBLIN_SLINGER: _newEnemyFormation.addSoldier(new Slinger(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_ENEMY)); break; case Soldier.CLASS_MERC_DOPPLE: _newEnemyFormation.addSoldier(new Dopple(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_ENEMY)); break; case Soldier.CLASS_GOBLIN_BERZERKER: _newEnemyFormation.addSoldier(new Berzerker(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_ENEMY)); break; case Soldier.CLASS_GOBLIN_BRIGAND: _newEnemyFormation.addSoldier(new Brigand(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_ENEMY)); break; case Soldier.CLASS_MERC_CROSSBOWMAN_PAVISE: _newEnemyFormation.addSoldier(new CrossbowmanPavise(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_ENEMY)); break; case Soldier.CLASS_MERC_CAVALRY: _newEnemyFormation.addSoldier(new Cavalry(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_ENEMY)); break; case Soldier.CLASS_GOBLIN_WOLF: _newEnemyFormation.addSoldier(new Wolf(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_ENEMY)); break; case Soldier.CLASS_NPC_FLEER: _newEnemyFormation.addSoldier(new NPCFleer(this, _newEnemyFormation.getPosition().X, _newEnemyFormation.getPosition().Y, SIDE_NEUTRAL)); break; } } _enemyFormations.Add(_newEnemyFormation); } for (int f = 0; f < _levelData.terrains.Count; f++) { Terrain.getNewTerrain(_levelData.terrains[f], this, _levelData.terrainPositions[f].X, _levelData.terrainPositions[f].Y, f); } if (selectedFormation != -1 && _enemyFormations.Count > selectedFormation) { ((EnemyFormation)_enemyFormations[selectedFormation]).selected = true; } }