protected override void Tick(object source = null, System.Timers.ElapsedEventArgs e = null) { // Calculate random path to Hill if (Waypoint.Equals(new Vector2f(-1, -1))) { int pointCount = Utils.RandomInt(10, 20); float originalAngle = (float)Utils.GetAngle(Game.Hill.Position, Obj.Position); Vector2f destination = Utils.GetPointInDirection(Game.Hill.Position, originalAngle, Game.Hill.Radius - 2); float originalDistance = Utils.Distance(Obj.Position, destination); Vector2f pos; for (int i = 0; i < pointCount; i++) { pos = Utils.GetPointInDirection(Obj.Position, (float)(Utils.GetAngle(Obj.Position, destination)), (originalDistance / pointCount) * (i + 1)); if (i != pointCount - 1 && (i + 1) % 2 == 0) { pos += Utils.GetPointInDirection(new Vector2f(), originalAngle + (Utils.RandomInt() == 1 ? 90 : -90), Utils.RandomInt(10, 60)); } AddWaypointToPath(pos); } PossibleLandmineAtWaypoint = Utils.RandomInt(0, WaypointPath.Count - 1); //Debug_ShowWaypoints(); } base.Tick(source, e); }
protected override void OnDeath(dynamic sourceObject = null) { // Explosions Explosion explosion = new Explosion(Game, 100); explosion.Position = Position; Game.Layer_OtherAbove.AddChild(explosion); explosion = new Explosion(Game, 60); explosion.Position = Utils.GetPointInDirection(Position, Rotation, 40); Game.Layer_OtherAbove.AddChild(explosion); explosion = new Explosion(Game, 60); explosion.Position = Utils.GetPointInDirection(Position, Rotation, -40); Game.Layer_OtherAbove.AddChild(explosion); // Deploy Rowboats if (AmountOfInfantry <= 6 || (AI != null && ((ShipAI)AI).ReachedBeach)) { base.OnDeath((object)sourceObject); return; } int amountOfRowboats = Utils.RandomInt(0, 2); for (int i = 0; i < amountOfRowboats; i++) { Rowboat rowboat = (Rowboat)Game.AIManager.SpawnEnemy(AIManager.TYPE_ROWBOAT, Utils.GetPointInDirection(Position, i == 0 ? 90 : -90, 100)); rowboat.Rotation = Rotation; } base.OnDeath((object)sourceObject); }
protected override void Tick(object source = null, System.Timers.ElapsedEventArgs e = null) { if (!ReachedBeach && Waypoint.Equals(new Vector2f(-1, -1))) { // Generate path to Beach int pointCount = Utils.RandomInt(3, 8); float originalAngle = (float)Utils.GetAngle(Game.Island.Position, Obj.Position); Vector2f destination = Utils.GetPointInDirection(Game.Island.Position, originalAngle, Game.Island.Radius); float originalDistance = Utils.Distance(Obj.Position, destination); Vector2f pos; for (int i = 0; i < pointCount; i++) { pos = Utils.GetPointInDirection(Obj.Position, (float)(Utils.GetAngle(Obj.Position, destination)), (originalDistance / pointCount) * (i + 1)); if (i != pointCount - 1 && (i + 1) % 2 == 0) { pos += Utils.GetPointInDirection(new Vector2f(), originalAngle + (Utils.RandomInt() == 1 ? 90 : -90), Utils.RandomInt(4, 20)); } AddWaypointToPath(pos); } //Debug_ShowWaypoints(); } base.Tick(source, e); }
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); } }
protected override void OnKeyReleased(object sender, KeyEventArgs e) { if (IsDead() || !KeyDown || (e != null && Game.KeyIsNotAllowed(e.Code))) { return; } KeyDown = false; if (!Game.IsRunning()) { // Interrupt aiming if the player releases the key while paused if (!CanRotate) { AimAssistance.AimEnd(); foreach (AimAssistance a in AimAssistanceExtras) { a.AimEnd(); } } return; } if (CanRotate) { return; } Weapon.Fire(Utils.GetPointInDirection(Position, Rotation, 40), Rotation, Utils.GetPointInDirection(Position, Rotation, AimAssistance.Reticle.Y)); foreach (AimAssistance a in AimAssistanceExtras) { Weapon.Fire(Utils.GetPointInDirection(Position, Rotation + a.RotationOffset, 40), Rotation + a.RotationOffset, Utils.GetPointInDirection(Position, Rotation + a.RotationOffset, a.Reticle.Y)); } StartRotationDelay(); AimAssistance.AimEnd(); foreach (AimAssistance a in AimAssistanceExtras) { a.AimEnd(); } }
protected override void Tick(object source = null, System.Timers.ElapsedEventArgs e = null) { if (!Waypoint.Equals(new Vector2f(-1, -1))) { base.Tick(source, e); return; } if (!ReachedBeach) { // Generate path to Beach int pointCount = Utils.RandomInt(10, 20); float originalAngle = (float)Utils.GetAngle(Game.Island.Position, Obj.Position); Vector2f destination = Utils.GetPointInDirection(Game.Island.Position, originalAngle, Game.Island.Radius + 132.5f); float originalDistance = Utils.Distance(Obj.Position, destination); Vector2f pos; for (int i = 0; i < pointCount; i++) { pos = Utils.GetPointInDirection(Obj.Position, (float)(Utils.GetAngle(Obj.Position, destination)), (originalDistance / pointCount) * (i + 1)); if (i != pointCount - 1 && (i + 1) % 2 == 0) { pos += Utils.GetPointInDirection(new Vector2f(), originalAngle + (Utils.RandomInt() == 1 ? 90 : -90), Utils.RandomInt(10, 40)); } AddWaypointToPath(pos); } //Debug_ShowWaypoints(); } else if (((Ship)Obj).AmountOfInfantry <= 0) { // Generate path off screen LeavingArea = true; Obj.CanMove = false; // Can't move until Ship rotates to first waypoint in path if (Obj.Model is AnimatedSprite) { Obj.Model.Sprite.Color = new Color(255, 255, 255, 100); if (Obj.FlashOnDamageBright) { Obj.FlashOnDamageOriginalColor = Obj.Model.Color; // just in case the Ship's Colour has already been changed temporarily } Obj.Model.Play(); } else { Obj.Model.Color = new Color(255, 255, 255, 100); if (Obj.FlashOnDamageBright) { Obj.FlashOnDamageOriginalColor = Obj.Model.Color; // just in case the Ship's Colour has already been changed temporarily } } int pointCount = Utils.RandomInt(4, 15); float originalAngle = (float)Utils.GetAngle(Game.Island.Position, Obj.Position) + (Utils.RandomInt(50, 80) * (Utils.RandomInt() == 1 ? 1 : -1)); Vector2f intersectPoint = Utils.RaycastAgainstBounds(Game.Bounds, Game.Center, Utils.GetPointInDirection(Game.Center, originalAngle, Game.Size.X)); Vector2f destination = Utils.GetPointInDirection(intersectPoint, originalAngle, 200); float originalDistance = Utils.Distance(Obj.Position, destination); Vector2f pos; for (int i = 0; i < pointCount; i++) { pos = Utils.GetPointInDirection(Obj.Position, (float)(Utils.GetAngle(Obj.Position, destination)), (originalDistance / pointCount) * (i + 1)); if (i != pointCount - 1 && (i + 1) % 2 == 0) { pos += Utils.GetPointInDirection(new Vector2f(), originalAngle + (Utils.RandomInt() == 1 ? 90 : -90), Utils.RandomInt(10, 40)); } AddWaypointToPath(pos); } } base.Tick(source, e); }