BulletMLLib.Bullet.GetAimDir C# (CSharp) Method

GetAimDir() public method

Get the direction to aim that bullet
public GetAimDir ( ) : float
return float
        public float GetAimDir()
        {
            //get the player position so we can aim at that little fucker
              System.Diagnostics.Debug.Assert(null != MyBulletManager);
              Vector2 shipPos = MyBulletManager.PlayerPosition(this);

              //TODO: this function doesn't seem to work... bullets sometimes just spin around in circles?

              //get the angle at that dude
              float val = Mathf.Atan2((shipPos.x - X), -(shipPos.y - Y));
              return val;
        }

Usage Example

Exemplo n.º 1
0
        private float GetDirection(Bullet bullet)
        {
            //How do we want to change direction?
            float delta = 0.0f;

            switch (ChangeType)
            {
            case ENodeType.sequence:
            {
                //We are going to add this amount to the direction every frame
                delta = NodeDirection;
            }
            break;

            case ENodeType.absolute:
            {
                //We are going to go in the direction we are given, regardless of where we are pointing right now
                delta = NodeDirection - bullet.Direction;
            }
            break;

            case ENodeType.relative:
            {
                //The direction change will be relative to our current direction
                delta = NodeDirection;
            }
            break;

            default:
            {
                //the direction change is to aim at the enemy
                delta = ((NodeDirection + bullet.GetAimDir()) - bullet.Direction);
            }
            break;
            }

            //keep the direction between -180 and 180
            delta = MathHelper.WrapAngle(delta);

            //The sequence type of change direction is unaffected by the duration
            if (ChangeType == ENodeType.relative)
            {
                //Divide by the duration so we ease into the direction change
                delta /= Duration;
            }
            //The sequence type of change direction is unaffected by the duration
            else if (ChangeType != ENodeType.sequence)
            {
                //divide by the amount fo time remaining
                delta /= Duration - RunDelta;
            }

            return(delta);
        }
All Usage Examples Of BulletMLLib.Bullet::GetAimDir