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)); }
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])); } } }
private double AwayFromPoint(PairVector point, double fromHeading) { return -1*(TowardPoint(point, fromHeading)); }
private double TowardPoint(PairVector point, double fromHeading) { return TowardHeading(DegreeFromPoint(point), fromHeading); }
private double DistanceFromPoint(PairVector point) { double a = point.X - X; double b = point.Y - Y; return Math.Sqrt(a*a + b*b); }
private double DegreeFromPoint(PairVector point) { return Math.Atan2(Y - point.Y, point.X - X)/Math.PI*180%360; }