Пример #1
0
 private void UfoFiresBullet()
 {
     Sprite newBullet = new Sprite(_ufobullet.Texture);
     Vector2 velocity = _ship.Position - _ufo.Position;
     velocity.Normalize();
     newBullet.Rotation = (float) Math.Atan2(velocity.Y, velocity.X) + MathHelper.PiOver2;
     velocity *= 6.0f;
     newBullet.Velocity = velocity;
     newBullet.Position = _ufo.Position;
     newBullet.Damage = 1;
     newBullet.Create();
     _ufobullets.Add(newBullet);
 }
Пример #2
0
        private void ShipSpecialAttack()
        {
            //_ship.Velocity += new Vector2(
            //    (float) (Math.Cos(_ship.Rotation - MathHelper.PiOver2)*0.5f),
            //    (float) ((Math.Sin(_ship.Rotation - MathHelper.PiOver2)*0.5f)));
            float chunk = MathHelper.TwoPi/BulletsInSpecialAttack;

            for (int i = 0; i < BulletsInSpecialAttack; i++)
            {
                Sprite newBullet = new Sprite(_specialBulletTexture);
                newBullet.Position = _ship.Position;
                newBullet.Damage = 2;
                newBullet.Velocity = new Vector2((float)Math.Cos(-MathHelper.Pi + chunk * i), (float)Math.Sin(-MathHelper.Pi + chunk * i))*10;
                newBullet.Create();
                _bullets.Add(newBullet);
            }
        }
Пример #3
0
        private void NewAsteroid(Sprite a, int index)
        {
            Sprite tempSprite = new Sprite(_asteroidTextures[index])
                                    {
                                        Index = index,
                                        Position = a.Position,
                                        Velocity = RandomVelocity(),
                                        Rotation = (float) _random.NextDouble()*
                                                   MathHelper.Pi*4 - MathHelper.Pi*2

                                    };

            if (a.Index < 3)
            {
                tempSprite.Life = 3;
            }
            else if (a.Index < 6)
            {
                tempSprite.Life = 1;
            }

            tempSprite.Create();
            _asteroids.Add(tempSprite);
        }
Пример #4
0
 private void ShipFiresBullet()
 {
     Sprite newBullet = new Sprite(_bullet.Texture);
     Vector2 velocity = new Vector2(
         (float)Math.Cos(_ship.Rotation - MathHelper.PiOver2) ,
         (float)Math.Sin(_ship.Rotation - MathHelper.PiOver2) );
     velocity.Normalize();
     velocity *= 10.0f;
     newBullet.Velocity = velocity;
     newBullet.Position = _ship.Position + newBullet.Velocity*2;
     newBullet.Damage = 1;
     newBullet.Rotation = _ship.Rotation;
     newBullet.Create();
     _bullets.Add(newBullet);
 }
Пример #5
0
        /*
         *
         * UPDATE LOGIC BLOC
         *
         *
         */
        private void GenerateAidkits(TimeSpan totalTime)
        {
            if (_random.Next(0, 700) == 301)
            {
                Sprite aidkit = new Sprite(_aidkitTexture);

                double xPos = 0;
                double yPos = 0;

                int value = _random.Next(0, 4);

                switch (value)
                {
                    case 0:
                    case 1:
                        xPos = aidkit.Width + _random.NextDouble() * 40;
                        yPos = _random.NextDouble() * _screenHeight;
                        break;
                    case 2:
                    case 3:
                        xPos = _screenWidth - _random.NextDouble() * 40;
                        yPos = _random.NextDouble() * _screenHeight;
                        break;
                    case 4:
                    case 5:
                        xPos = _random.NextDouble() * _screenWidth;
                        yPos = aidkit.Height + _random.NextDouble() * 40;
                        break;
                    default:
                        xPos = _random.NextDouble() * _screenWidth;
                        yPos = _screenHeight - _random.NextDouble() * 40;
                        break;
                }

                aidkit.Position = new Vector2((float)xPos, (float)yPos);
                aidkit.Rotation = (float)_random.NextDouble() *
                                         MathHelper.Pi * 4 - MathHelper.Pi * 2;
                aidkit.Life = _random.Next(3, 6);
                aidkit.LastUpdate = totalTime.TotalMilliseconds;
                aidkit.Create();
                _aidkits.Add(aidkit);
            }
        }