/// <summary> /// Creates a new sector. /// </summary> /// <param name="attackerX">The attacker x.</param> /// <param name="attackerY">The attacker y.</param> /// <param name="attackX">The attack x.</param> /// <param name="attackY">The attack y.</param> public Sector(int attackerX, int attackerY, int attackX, int attackY) { _attackerX = attackerX; _attackerY = attackerY; _attackX = attackX; _attackY = attackY; _degree = RangeTools.GetDegree(attackerX, attackX, attackerY, attackY); _addextra = false; }
/// <summary> /// Checks whether a coordinate is within the sector. /// </summary> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> /// <returns>True if the coordinate is within the sector.</returns> public bool Inside(int x, int y) { if (RangeTools.GetDistance(x, y, _attackerX, _attackerY) <= _distance) { int degree = RangeTools.GetDegree(_attackerX, x, _attackerY, y); if (_addextra) { degree += 360; } if (degree >= _leftside && degree <= _rightside) { return(true); } } return(false); }