public bool OnArea(AgarElement e) { if (e == null) { return(false); } if (e.ElementType == ElementType.Universe) { return(true); } if (e.ElementType == ElementType.World) { return(true); } var nTimesTheDiameter = Math.Max(Cell.Diameter * 5, 30); if (Cell.X - e.X + e.Radius > nTimesTheDiameter) { return(false); } if (e.X - e.Radius - Cell.X > nTimesTheDiameter) { return(false); } if (Cell.Y - e.Y + e.Radius > nTimesTheDiameter) { return(false); } if (e.Y - e.Radius - Cell.Y > nTimesTheDiameter) { return(false); } return(true); }
public static bool CanOneElementEatsOtherOneByCellGroup(AgarElement oneElement, AgarElement otherElement) { var bothAreCellParts = oneElement.ElementType != ElementType.CellPart && otherElement.ElementType != ElementType.CellPart; if (!bothAreCellParts) { return(true); } var oneCellPartElement = oneElement as CellPart; var otherCellPartElement = otherElement as CellPart; var sameCell = oneCellPartElement.Cell == otherCellPartElement.Cell; if (!sameCell) { return(true); } var bothEatables = oneCellPartElement.EatableByMySelf && otherCellPartElement.EatableByMySelf; return(bothEatables); }
public static bool CanOneElementEatsOtherOneByMass(AgarElement oneElement, AgarElement otherElement) { var r = oneElement._Mass * 0.9 > otherElement._Mass; return(r); }
public static bool Collides(AgarElement oneElement, AgarElement otherElement) { var r = ElementsHelper.TwoElementsCenterDistance(oneElement, otherElement) <= oneElement.Radius + otherElement.Radius; return(r); }
public static bool CanOneElementEatsOtherOneByDistance(AgarElement oneElement, AgarElement otherElement) { var r = ElementsHelper.TwoElementsCenterDistance(oneElement, otherElement) + otherElement.Radius * 0.4 < oneElement.Radius; return(r); }
public static double TwoElementsCenterDistance(AgarElement one, AgarElement other) => Math.Sqrt( Math.Pow(one.X - other.X, 2) + Math.Pow(one.Y - other.Y, 2) );