private bool CheckEnemyIsInRange(int index) { Enemy e = Enemies[index]; if (HiddenEnemies.Output.ContainsKey(e)) return true; if (NearestEnemy != null && NearestEnemy.Displacement > e.Displacement) return true; if (Physics.CircleCicleCollision(CurrentTurretRange, e.Circle)) NearestEnemy = e; return true; }
public EnemiesWidget(List<Enemy> enemies, int width, int nbColumns) { Enemies = enemies; CheckBoxes = new Dictionary<Enemy, ImageCheckBox>(); foreach (var e in enemies) CheckBoxes.Add(e, new ImageCheckBox(new Image(e.Name) { SizeX = 5 } )); FirstCheckBox = CheckBoxes[Enemies[0]]; LastCheckBox = CheckBoxes[Enemies[Enemies.Count - 1]]; Width = width; NbColumns = nbColumns; DistanceBetweenTwoChoices = 20; ClickedCount = 0; HoverEnemy = null; }
public void Sync() { Output.Clear(); for (int i = 0; i < Turrets.Count; i++) { NearestEnemy = null; CurrentTurret = Turrets[i]; if (CurrentTurret.Type == TurretType.Gravitational || CurrentTurret.Type == TurretType.Booster) continue; SyncRectangleAndCircle(); EnemiesGrid.GetItems(CurrentTurretRectangle, Handler); if (NearestEnemy != null) Output.Add(new KeyValuePair<Turret, Enemy>(CurrentTurret, NearestEnemy)); } }
private void NotifyEnemyReachedEndOfPath(Enemy enemy, CelestialBody celestialBody) { if (EnemyReachedEndOfPath != null) EnemyReachedEndOfPath(enemy, celestialBody); }
private void RemoveFromWave(Enemy enemy) { foreach (var w in Waves) if (w.GetHashCode() == enemy.WaveId) { w.DoEnemyDestroyed(); break; } }
private void ExtractMinerals(Enemy enemy) { foreach (var m in enemy.Minerals) { m.Position = enemy.Position; Vector3 direction; Path.Direction(enemy.Displacement, out direction); m.Direction = direction; Minerals.Add(m); } }
private void ExtractSwarm(Enemy enemy) { for (int j = 0; j < 3; j++) { var e = EnemyDescriptor.Pool.Get(); e.Type = EnemyType.Swarm; e.CashValue = enemy.CashValue / 10; e.LivesLevel = enemy.Level; e.SpeedLevel = enemy.Level; e.StartingPosition = enemy.Displacement; ActiveWaves[0].AddEnemy(e); } }
private void AddEnemy(Enemy e, Wave w) { e.Path = this.Path; e.PathPreview = this.PathPreview; e.Translation.Y = Main.Random.Next(-20, 20); e.WaveId = w.GetHashCode(); e.Initialize(); if (e.Type != EnemyType.Swarm) { while (MineralsDistribution.Count > 0 && MineralsDistribution[MineralsDistribution.Count - 1].Key == EnemiesCreatedCounter) { e.Minerals.Add(Simulator.MineralsFactory.Get(MineralsDistribution[MineralsDistribution.Count - 1].Value, e.Image.VisualPriority + 0.01)); MineralsDistribution.RemoveAt(MineralsDistribution.Count - 1); } EnemiesCreatedCounter++; } var fadeInEffect = Core.Visual.VisualEffects.FadeInFrom0(Simulator.WorldMode? 150 : 255, 0, e.FadeInTime); Simulator.Scene.VisualEffects.Add(e.Image, fadeInEffect); Enemies.Add(e); NotifyObjectCreated(e); }
public void DoBulletDeflected(Enemy enemy, Bullet bullet) { Vector3 direction = enemy.Position - bullet.Position; float rotation = Math.Max(0.8f, 0.08f * bullet.Speed) * (1 - direction.Length() / bullet.DeflectZone); rotation = Main.Random.Next(0, 2) == 0 ? rotation : -rotation; Matrix.CreateRotationZ(rotation, out RotationMatrix); bullet.Direction = Vector3.Transform(bullet.Direction, RotationMatrix); bullet.Direction.Normalize(); bullet.Image.Rotation = MathHelper.PiOver2 + (float) Math.Atan2(bullet.Direction.Y, bullet.Direction.X); if (bullet is MissileBullet) ((MissileBullet) bullet).Wander = true; if (!bullet.Deflected) { bullet.Deflected = true; NotifyBulletDeflected(bullet); } }
protected override bool Hover(Circle circle) { foreach (var w in CheckBoxes) if (w.Value.DoHover(circle)) { HoverEnemy = w.Key; return true; } HoverEnemy = null; return false; }
protected override bool Click(Circle circle) { foreach (var w in CheckBoxes) if (w.Value.DoClick(circle)) { ClickedCount += w.Value.Value ? 1 : -1; ClickedEnemy = w.Key; return true; } return false; }
private void DoEnemyReachedEndOfPath(Enemy enemy, CelestialBody celestialBody) { if (State == GameState.Won) return; if (!DemoMode && State != GameState.Lost) { foreach (var player in Inputs.Players) { //Inputs.VibrateControllerHighFrequency(player, 300, 0.5f); Inputs.VibrateControllerLowFrequency(player, 300, 0.9f); } } }
public void Return(Enemy enemy) { EnemiesPools[enemy.Type].Return(enemy); }
private void ShowLife(Enemy e, int imagesIndex, bool applyApha) { float LivesRatio = e.LifePoints / e.StartingLifePoints; int statusIndex = (int) Math.Round((1 - LivesRatio) * 5); var image = Lives[imagesIndex][statusIndex]; image.Position = e.Position - new Vector3(0, e.Image.AbsoluteSize.Y, 0); image.VisualPriority = e.VisualPriority - 0.000001f; if (applyApha) image.Alpha = (byte) Math.Max(0, e.BeingHitPourc * 255); else image.Alpha = 255; Simulator.Scene.Add(Lives[imagesIndex][statusIndex]); }
public void DoEnemyReachedEnd(Enemy enemy, CelestialBody celestialBody) { if (Simulator.State == GameState.Won) return; if (celestialBody == null || !celestialBody.Alive) return; if (!(celestialBody is AsteroidBelt)) celestialBody.DoHit(enemy); if (!Simulator.DemoMode && celestialBody.Alive) NotifyObjectHit(celestialBody); }
private void NotifyBulletDeflected(Enemy enemy, Bullet bullet) { if (BulletDeflected != null) BulletDeflected(enemy, bullet); }