Exemplo n.º 1
0
        public override void CreateBullet()
        {
            for (int i = 0; i <= 360; i += 20)
            {
                _dx = SwinGame.Sine(i);
                _dy = SwinGame.Cosine(i);

                //_dx = SwinGame.Tangent(i);
                //_dy = SwinGame.Sine(i);

                //_dx = SwinGame.Tangent(i);
                //_dy = SwinGame.Cosine(i);

                //_dx = SwinGame.Sine(i);
                //_dy = SwinGame.Tangent(i);

                //_dy = 1;
                //_dx = SwinGame.Cosine(i);
                //_dy += 0.5f;

                _storingList.Add(new SprayBullet(_gunPower, this.Position, _fireRate, _dx, _dy));

                SwinGame.PlaySoundEffect(_gunSound);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Point the tower to target X,Y.
 /// </summary>
 /// <param name="x">The x coordinate.</param>
 /// <param name="y">The y coordinate.</param>
 public void PointTo(float x, float y)
 {
     _angle   = SwinGame.CalculateAngle(_position[0], _position[1], x, y);
     _pointAx = _barrelLength * SwinGame.Cosine(_angle - _barrelWidth) + _position[0];
     _pointAy = _barrelLength * SwinGame.Sine(_angle - _barrelWidth) + _position[1];
     _pointBx = _barrelLength * SwinGame.Cosine(_angle + _barrelWidth) + _position[0];
     _pointBy = _barrelLength * SwinGame.Sine(_angle + _barrelWidth) + _position[1];
     _pointSx = _barrelLength * SwinGame.Cosine(_angle) + _position[0];
     _pointSy = _barrelLength * SwinGame.Sine(_angle) + _position[1];
 }
Exemplo n.º 3
0
        /// <summary>
        /// Draw this instance.
        /// </summary>
        public override void Draw()
        {
            SwinGame.FillCircle(Color.White, _position[0], _position[1], _size);

            for (int angle = _angle; angle < 360 + _angle; angle += 51)
            {
                float pointAx = 10 * SwinGame.Cosine(angle - 30) + _position[0];
                float pointAy = 10 * SwinGame.Sine(angle - 30) + _position[1];
                float pointBx = 10 * SwinGame.Cosine(angle + 30) + _position[0];
                float pointBy = 10 * SwinGame.Sine(angle + 30) + _position[1];
                float pointCx = 15 * SwinGame.Cosine(angle) + _position[0];
                float pointCy = 15 * SwinGame.Sine(angle) + _position[1];
                SwinGame.FillTriangle(Color.White, pointAx, pointAy, pointBx, pointBy, pointCx, pointCy);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Calculates the angle to move to and moves by speed distance, move half as fast when slowed
        /// </summary>
        /// <param name="destx">destination X</param>
        /// <param name="desty">destination Y</param>
        public void Move(float destx, float desty)
        {
            float angle = SwinGame.CalculateAngle(_position[0], _position[1], destx, desty);

            if (!_slowed)
            {
                _position[0] += (_speed * SwinGame.Cosine(angle));
                _position[1] += (_speed * SwinGame.Sine(angle));
            }
            else
            {
                _position[0] += ((int)(_speed / 2) * SwinGame.Cosine(angle));
                _position[1] += ((int)(_speed / 2) * SwinGame.Sine(angle));
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Move this instance to the direction its facing in speed amount.
 /// </summary>
 public void Move()
 {
     _position[0] += (_speed * SwinGame.Cosine(_direction));
     _position[1] += (_speed * SwinGame.Sine(_direction));
 }