public static double GetAdjustedAngleTo(this Unit me, Unit target)
		{
			double x = target.X + target.SpeedX;
			double y = target.Y + target.SpeedY;

			return me.GetAngleTo (x, y);
		}
        public static double GetAdjustedBackwardsAngleTo(this Unit me, Unit target)
        {
            double x = target.X + target.SpeedX;
            double y = target.Y + target.SpeedY;

            double angle = me.GetAngleTo(x, y) + Math.PI;

            while (angle > Math.PI)
            {
                angle -= 2.0D * Math.PI;
            }

            while (angle < -Math.PI)
            {
                angle += 2.0D * Math.PI;
            }

            return angle;
        }
		private Unit CurrentStrikePosition()
		{
			if (Math.Abs(me.X - world.GetOpponentPlayer().NetFront) < strikeDistanceFromNet + 100 && currentStrikePosition != null)
			{
				Console.WriteLine("SELF X {0} NET FRONT {1}", me.X, world.GetOpponentPlayer().NetFront);
				return currentStrikePosition;
			}
				
			var hockeyists = world.EnemyTeam ().ToArray ();

			if (hockeyists.Average(x => x.X) > me.X)
			{
				return PickClosestStrikePoint();
			}

			double enemyPosition = hockeyists.Average(x => x.Y);
			double maxDistance = strikePoints.Select(strikePoint => Math.Abs(strikePoint.Y - enemyPosition)).Concat(new double[] {0}).Max();
			var point = strikePoints.First(strikePoint => Math.Abs(Math.Abs(strikePoint.Y - enemyPosition) - maxDistance) < 1);

			return currentStrikePosition = point;
		}
        public void GoTo(Unit self, double tX, double tY, double tSpeedX, double tSpeedY, double back, Game game, Move move)
        {
            double Rx = self.X - tX;
            double Ry = self.Y - tY;
            double Vx = self.SpeedX - tSpeedX;
            double Vy = self.SpeedY - tSpeedY;

            double t = (Vx * Vx + Vy * Vy) / (Vx * Vx + Vy * Vy + Rx * Rx + Ry * Ry);
            double Ax = -Rx * (1 - t) - Vx * t;
            double Ay = -Ry * (1 - t) - Vy * t;

            move.SpeedUp = Math.Cos(GetAngleBetween(0, 0, Ax, Ay, self.Angle))
                * Math.Sqrt(Ax * Ax + Ay * Ay);

            if (move.SpeedUp > 0) move.SpeedUp /= game.HockeyistSpeedUpFactor;
            else move.SpeedUp /= game.HockeyistSpeedDownFactor;

            double Frw = GetAngleBetween(0, 0, Ax, Ay, self.Angle);
            double Bck = GetAngleBetween(0, 0, -Ax, -Ay, self.Angle);

            move.Turn = (self.GetDistanceTo(tX, tY) > back || Math.Abs(Frw) < Math.Abs(Bck)) ? Frw : Bck;
        }
 public double GetDistanceTo(Unit unit) {
     return GetDistanceTo(unit.x, unit.y);
 }
 public double GetAngleTo(Unit unit) {
     return GetAngleTo(unit.x, unit.y);
 }
 public void GoTo(Unit self, Unit target, double back, Game game, Move move)
 {
     GoTo(self, target.X, target.Y, target.SpeedX, target.SpeedY, back, game, move);
 }
 public bool CanShot(Unit self, Puck Puck, double Speed, double Sector,
     double TX, double TY, double GoalieMaxSpeed)
 {
     return CanShot(self.Angle, self.Radius, Puck.X, Puck.Y,
         Puck.Radius, Speed, Sector, TX, TY, GoalieMaxSpeed);
 }
		public ReachAndSlowdownBehaviour (Hockeyist me, Unit target, bool backwardsMovement) : base(me)
		{
			this.target = target;
		    this.backwardsMovement = backwardsMovement;
		}