Example #1
0
        // P U B L I C   M E T H O D S
        // ---------------------------
        public BulletData(Bullet bulletStats,
						  Point2D bulletOrigin, 
						  Point2D bulletDestination)
        {
            Stats = bulletStats;
            Origin = bulletOrigin;
            Destination = bulletDestination;
        }
Example #2
0
 /// <summary>
 /// Method to draw half-transparent bullet-line & targeting-box (the size of a robot) on the battlefield. 
 /// The idea is to use this for visual debugging: Set start point to own robot's position, and end point 
 /// to where you mean the bullet to go. Then see if this really is where the bullet is heading: 
 /// 1) If the targeting-box is off the spot you wanted it, you got a bug in your target prediction code.
 /// 2) If the targeting-box is on the spot, but the bullet is off the line (and center of the box), you 
 ///    got a bug in your "gun turning and firing" code.
 /// </summary>
 public static void DrawBulletTarget(IGraphics graphics, Color drawColor, Point2D start, Point2D end)
 {
     // Set color to a semi-transparent one.
     Color halfTransparent = Color.FromArgb(128, drawColor);
     // Draw line and rectangle.
     graphics.DrawLine(new Pen(halfTransparent), (int)start.X, (int)start.Y, (int)end.X, (int)end.Y);
     graphics.FillRectangle(new SolidBrush(halfTransparent), (int)end.X - 18, (int)end.Y - 18, 36, 36);
 }
Example #3
0
        public bool Equals(Point2D point)
        {
            // If parameter is null return false:
            if ((Object)point == null) {
                return false;
            }

            // Return true if the fields match:
            return (X == point.X) && (Y == point.Y);
        }
Example #4
0
 // P U B L I C   M E T H O D S
 // ---------------------------
 public EnemyData()
 {
     Bullets = new List<BulletData>();
     Offset = new Vector2D();
     Position = new Point2D();
 }
Example #5
0
        /// <summary>
        /// Sets all EnemyData, EXCEPT bullets: Bullets are set when they're fired, the rest is set when enemy is scanned.
        /// </summary>
        public void SetEnemyData(long newTime,
							   ScannedRobotEvent newEnemyData,
							   Vector2D newOffset,
							   Point2D newPosition)
        {
            // First we set the stuff that depends on last updates' values:
            TurnRate = Utils.NormalRelativeAngleDegrees(newEnemyData.Heading - Heading) / (newTime - Time);
            Acceleration = (newEnemyData.Velocity - Velocity) / (newTime - Time);

            // General data:
            Time = newTime;

            // Compared-to-us data:
            Bearing = newEnemyData.Bearing;
            Distance = newEnemyData.Distance;
            Offset = newOffset;

            // Enemy specific data:
            Name = newEnemyData.Name;
            Energy = newEnemyData.Energy;
            Position = newPosition;
            Velocity = newEnemyData.Velocity;
            Heading = newEnemyData.Heading;
        }