private void AddInfantryman(Vector2f position) { Infantryman infantryman = new Infantryman(Game, 1, null); infantryman.Visible = true; infantryman.SetPosition(position); AddChild(infantryman); InfantryPassengers.Add(infantryman); }
private void SpawnOverTimeTimerHandler(Object source = null, ElapsedEventArgs e = null) { if (Game.Player == null) { StopSpawnEnemiesOverTime(); return; } if (Game.Player.HasPowerup(Powerup.FREEZE_TIME)) { return; } // Spawn enemy Character enemy; switch (SpawnOverTimeType) { case TYPE_SHIP: { enemy = new Ship(Game); int angle = Utils.RandomInt(0, 359); Vector2f intersectPoint = Utils.RaycastAgainstBounds(Game.Bounds, Game.Center, Utils.GetPointInDirection(Game.Center, angle, Game.Size.X)); enemy.SetPosition(Utils.GetPointInDirection(intersectPoint, angle, 200)); break; } default: { enemy = new Infantryman(Game); enemy.SetPosition(Utils.GetPointInDirection(Game.Island.Position, Utils.RandomInt(0, 359), Game.Island.Radius - 5)); break; } } enemy.Death += OnEnemyDeath; EnemyCount++; Game.Layer_Objects.AddChild(enemy); SpawnOverTimeCount++; if (SpawnOverTimeCount >= SpawnOverTimeAmount) { // Finish spawning enemies over time StopSpawnEnemiesOverTime(); } }
public void OnRowboatReachedBeach(Rowboat rowboat) { const float gapX = 4; for (int i = 0; i < rowboat.AmountOfInfantry; i++) { Infantryman enemy = new Infantryman(Game); enemy.SetPosition(Utils.GetPointInDirection( Game.Island.Position, (float)Utils.GetAngle(Game.Island.Position, rowboat.Position) - ((rowboat.AmountOfInfantry / 2) * gapX) + (i * gapX), Game.Island.Radius - 5) ); enemy.Death += OnEnemyDeath; EnemyCount++; Game.Layer_Objects.AddChild(enemy); } }
public void OnShipReachedBeach(Ship ship) { const float gapX = 4; for (int i = 0; i < ship.AmountOfInfantry; i++) { Infantryman enemy = new Infantryman(Game, Utils.RandomInt(0, 5000), ship); enemy.SetPosition(Utils.GetPointInDirection( Game.Island.Position, (float)Utils.GetAngle(Game.Island.Position, ship.Position) - ((ship.AmountOfInfantry / 2) * gapX) + (i * gapX), Game.Island.Radius - 5) ); enemy.Death += OnEnemyDeath; EnemyCount++; Game.Layer_Objects.AddChild(enemy); } }
private void SpawnOverTimeTimerHandler(Object source = null, ElapsedEventArgs e = null) { if (Game.Player == null) { StopSpawnEnemiesOverTime(); return; } if (Game.Player.HasPowerup(Powerup.FREEZE_TIME)) return; // Spawn enemy Character enemy; switch (SpawnOverTimeType) { case TYPE_SHIP: { enemy = new Ship(Game); int angle = Utils.RandomInt(0, 359); Vector2f intersectPoint = Utils.RaycastAgainstBounds(Game.Bounds, Game.Center, Utils.GetPointInDirection(Game.Center, angle, Game.Size.X)); enemy.SetPosition(Utils.GetPointInDirection(intersectPoint, angle, 200)); break; } default: { enemy = new Infantryman(Game); enemy.SetPosition(Utils.GetPointInDirection(Game.Island.Position, Utils.RandomInt(0, 359), Game.Island.Radius - 5)); break; } } enemy.Death += OnEnemyDeath; EnemyCount++; Game.Layer_Objects.AddChild(enemy); SpawnOverTimeCount++; if (SpawnOverTimeCount >= SpawnOverTimeAmount) { // Finish spawning enemies over time StopSpawnEnemiesOverTime(); } }