예제 #1
0
 public override void Tick(Events events)
 {
     if (Time==0) Partner = Center();
     CheckPartnerMsgs();
     if (ScannedEnemy()) Fire(FirePower);
     AdjustGunAccordingTo(TurnRobot());
     Broadcast("_PP" + X.ToString(CultureInfo.InvariantCulture) + "|" + Y.ToString(CultureInfo.InvariantCulture));
 }
예제 #2
0
 private void CheckPartnerMsgs()
 {
     var partnerSaid = Events.Broadcasts;
     if (partnerSaid.Count == 0)
         _partnerDead = true;
     else
     {
         _partnerDead = false;
         if (partnerSaid[0] != null)
         {
             var locationParts = partnerSaid[0].Substring(3).Split('|');
             Partner = new PairVector(Convert.ToDouble(locationParts[0]), Convert.ToDouble(locationParts[1]));
         }
     }
 }
예제 #3
0
 private double AwayFromPoint(PairVector point, double fromHeading)
 {
     return -1*(TowardPoint(point, fromHeading));
 }
예제 #4
0
 private double TowardPoint(PairVector point, double fromHeading)
 {
     return TowardHeading(DegreeFromPoint(point), fromHeading);
 }
예제 #5
0
 private double DistanceFromPoint(PairVector point)
 {
     double a = point.X - X;
     double b = point.Y - Y;
     return Math.Sqrt(a*a + b*b);
 }
예제 #6
0
 private double DegreeFromPoint(PairVector point)
 {
     return Math.Atan2(Y - point.Y, point.X - X)/Math.PI*180%360;
 }