private void checkForPraysInRadar() { pray = null; velocity = 8; double deltaX, deltaY, distance, percentage; foreach (Pray p in prays) { deltaX = (p.getPosition().X - position.X); deltaY = (p.getPosition().Y - position.Y); distance = Math.Sqrt(((Math.Pow(deltaX, 2)) + (Math.Pow(deltaY, 2)))); if ((distance < radius) && (!p.isHunted()) && (!isHunting())) { pray = p; pray.setPredator(this); if (distance < size / 2) { pray.losesHealth(); } percentage = ((distance * 100) / radius); percentage = Math.Abs(percentage - radius); velocity = velocity + ((int)((percentage * velocity) / 100)); objective = pray.getPosition(); } } }
public Predator(int iD, int radarSize, Vertex vA, List <Pray> prays) { this.iD = iD; this.velocity = 6; this.index = 0; this.size = 36; this.radius = radarSize / 2; this.sizeR = radius * 2; this.position = vA.getPoint(); this.objective = new Point(); this.vA = vA; this.edge = null; this.pointList = new List <Point>(); this.prays = prays; this.pray = null; this.color = Color.FromArgb(50, 124, 252, 0); this.brush = new SolidBrush(color); this.pen = new Pen(Color.LawnGreen, 5); this.random = new Random(); }
// PRESA // public void addPray(Pray p) => prays.Add(p);