/// <summary> /// Avoids the lapin. /// </summary> /// <param name="_lapinAgent">The _lapin agent.</param> /// <returns></returns> internal bool AvoidLapin(LapinAgent _lapinAgent) { var squareDistanceToLapin = SquareDistanceTo(_lapinAgent); if (squareDistanceToLapin < SQUARE_DISTANCE_MIN) { var diffX = (_lapinAgent.PosX - PosX) / Math.Sqrt(squareDistanceToLapin); var diffY = (_lapinAgent.PosY - PosY) / Math.Sqrt(squareDistanceToLapin); speedX = SpeedX - diffX / 4; speedY = SpeedY - diffY / 4; Normalize(); return(true); } return(false); }
/// <summary> /// Avoids the renard. /// </summary> /// <param name="_lapinAgent">The _lapin agent.</param> /// <returns></returns> internal bool AvoidRenard(LapinAgent _lapinAgent) { var squareDistanceToRenard = SquareDistanceTo(_lapinAgent); if (squareDistanceToRenard < SQUARE_DISTANCE_MIN) { Debug.WriteLine("dedans"); var diffX = (_lapinAgent.PosX - PosX) / Math.Sqrt(squareDistanceToRenard); var diffY = (_lapinAgent.PosY - PosY) / Math.Sqrt(squareDistanceToRenard); speedX = SpeedX - diffX / 4; speedY = SpeedY - diffY / 4; Normalize(); return(true); } return(false); }
/// <summary> /// Nears the specified _lapin. /// </summary> /// <param name="_lapin">The _lapin.</param> /// <returns></returns> private bool Near(LapinAgent _lapin) { var squareDistance = SquareDistanceTo(_lapin); return(squareDistance < SQUARE_DISTANCE_MAX && squareDistance > SQUARE_DISTANCE_MIN); }
/// <summary> /// Deletes the lapin agent. /// </summary> /// <param name="lapinList">The lapin list.</param> /// <param name="lapin">The lapin.</param> protected void deleteLapinAgent(LapinAgent[] lapinList, LapinAgent lapin) { lapinList.ToList().Remove(lapin); }