Exemplo n.º 1
0
        public void onManagedUpdate(float secondsElapsed)
        {
            for (int i = 0; i < this.enemies.Count; ++i)
            {
                this.enemies[i].onManagedUpdate(secondsElapsed);
            }

            this.secondsElapsed += secondsElapsed;

            if (this.shotCount >= this.ShotCount)
            {
                if (this.secondsElapsed > this.RechargeTime)
                {
                    this.secondsElapsed -= this.RechargeTime;
                    this.shotCount = 0;
                }
            }

            while (this.secondsElapsed >= this.ShotTime && this.shotCount < this.ShotCount)
            {
                this.secondsElapsed -= this.ShotTime;
                float x = Options.Random.Next(Options.CameraWidth);
                float y = 0;
                float _x = Options.Random.Next(Options.CameraWidth);
                float _y = Options.CameraHeight;

                Enemy enemy = new Enemy()
                {
                    CenterX = x,
                    CenterY = y,
                    Width = this.BulletsWidth,
                    Height = this.BulletsHeight,
                    Angle = (float)Math.Atan2(_y - y, _x - x),
                    Speed = this.BulletsSpeed,
                    Health = (float)Options.Random.NextDouble()*10,
                };
                enemy.onManagedUpdate(this.secondsElapsed);
                this.enemies.Add(enemy);
                ++this.shotCount;
            }

            for (int i = 0; i < this.enemies.Count; ++i)
            {
                if (this.enemies[i].Y > Options.CameraHeight || this.enemies[i].Y + this.enemies[i].Height < 0)
                {
                    this.enemies.RemoveAt(i);
                    --i;
                }

            }
        }
Exemplo n.º 2
0
        public void onManagedUpdate(float secondsElapsed)
        {
            for (int i = 0; i < this.enemies.Count; ++i) {
                this.enemies [i].onManagedUpdate (secondsElapsed);
            }

            this.secondsElapsed += secondsElapsed;

            if (this.shotCount >= this.ShotCount && this.secondsElapsed >= this.RechargeTime) {
                this.secondsElapsed -= this.RechargeTime;
                this.shotCount = 0;
            }

            while (this.shotCount < this.ShotCount && this.secondsElapsed >= this.ShotTime) {
                this.secondsElapsed -= this.ShotTime;
                AimCursorX = Options.Random.Next (Options.CameraWidth);
                AimCursorY = 0;
                ShotCursorX = Options.Random.Next (Options.CameraWidth);
                ShotCursorY = Options.CameraHeight;
                Enemy enemy = new Enemy ()
                    {
                        Parent = this,
                            CenterX = AimCursorX,
                            CenterY = AimCursorY,
                            Width = this.EnemiesWidth,
                            Height = this.EnemiesHeight,
                            Angle = (float)Math.Atan2(ShotCursorY - AimCursorY, ShotCursorX - AimCursorX),
                            Speed = this.EnemiesSpeed,
                            LifeTime = this.EnemiesLifeTime,
                            Health = this.EnemiesHealth,
                        };
                this.enemies.Add (enemy);
                enemy.onManagedUpdate (this.secondsElapsed);
                ++this.shotCount;
            }
        }