コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
 private void NotifyEnemyReachedEndOfPath(Enemy enemy, CelestialBody celestialBody)
 {
     if (EnemyReachedEndOfPath != null)
         EnemyReachedEndOfPath(enemy, celestialBody);
 }
コード例 #5
0
 private void RemoveFromWave(Enemy enemy)
 {
     foreach (var w in Waves)
         if (w.GetHashCode() == enemy.WaveId)
         {
             w.DoEnemyDestroyed();
             break;
         }
 }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        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;
        }
コード例 #11
0
        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;
        }
コード例 #12
0
ファイル: Simulator.cs プロジェクト: jodigiordano/commander
        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);
                }
            }
        }
コード例 #13
0
 public void Return(Enemy enemy)
 {
     EnemiesPools[enemy.Type].Return(enemy);
 }
コード例 #14
0
        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]);
        }
コード例 #15
0
        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);
        }
コード例 #16
0
 private void NotifyBulletDeflected(Enemy enemy, Bullet bullet)
 {
     if (BulletDeflected != null)
         BulletDeflected(enemy, bullet);
 }