本文整理匯總了Java中java.awt.Point.distanceSq方法的典型用法代碼示例。如果您正苦於以下問題:Java Point.distanceSq方法的具體用法?Java Point.distanceSq怎麽用?Java Point.distanceSq使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Point
的用法示例。
在下文中一共展示了Point.distanceSq方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: broadcastMessage
import java.awt.Point; //導入方法依賴的package包/類
private void broadcastMessage(MapleCharacter source, final byte[] packet, double rangeSq, Point rangedFrom) {
chrRLock.lock();
try {
for (MapleCharacter chr : characters) {
if (chr != source) {
if (rangeSq < Double.POSITIVE_INFINITY) {
if (rangedFrom.distanceSq(chr.getPosition()) <= rangeSq) {
chr.getClient().announce(packet);
}
} else {
chr.getClient().announce(packet);
}
}
}
} finally {
chrRLock.unlock();
}
}
示例2: getMapObjectsInRange
import java.awt.Point; //導入方法依賴的package包/類
public List<MapleMapObject> getMapObjectsInRange(Point from, double rangeSq, List<MapleMapObjectType> types) {
List<MapleMapObject> ret = new LinkedList<>();
objectRLock.lock();
try {
for (MapleMapObject l : mapobjects.values()) {
if (types.contains(l.getType())) {
if (from.distanceSq(l.getPosition()) <= rangeSq) {
ret.add(l);
}
}
}
return ret;
} finally {
objectRLock.unlock();
}
}
示例3: broadcastGMMessage
import java.awt.Point; //導入方法依賴的package包/類
private void broadcastGMMessage(MapleCharacter source, final byte[] packet, double rangeSq, Point rangedFrom) {
chrRLock.lock();
try {
for (MapleCharacter chr : characters) {
if (chr != source && chr.isGM()) {
if (rangeSq < Double.POSITIVE_INFINITY) {
if (rangedFrom.distanceSq(chr.getPosition()) <= rangeSq) {
chr.getClient().announce(packet);
}
} else {
chr.getClient().announce(packet);
}
}
}
} finally {
chrRLock.unlock();
}
}
示例4: warp
import java.awt.Point; //導入方法依賴的package包/類
public final void warp(final int map, String portal) {
final MapleMap mapz = getWarpMap(map);
if (map == 109060000 || map == 109060002 || map == 109060004) {
portal = mapz.getSnowballPortal();
}
if (map == c.getPlayer().getMapId()) { //test
final Point portalPos = new Point(c.getPlayer().getMap().getPortal(portal).getPosition());
if (portalPos.distanceSq(getPlayer().getTruePosition()) < 90000.0) { //estimation
c.getPlayer().checkFollow();
c.getSession().write(CField.instantMapWarp((byte) c.getPlayer().getMap().getPortal(portal).getId()));
c.getPlayer().getMap().movePlayer(c.getPlayer(), new Point(c.getPlayer().getMap().getPortal(portal).getPosition()));
} else {
c.getPlayer().changeMap(mapz, mapz.getPortal(portal));
}
} else {
c.getPlayer().changeMap(mapz, mapz.getPortal(portal));
}
}
示例5: broadcastMessage
import java.awt.Point; //導入方法依賴的package包/類
public void broadcastMessage(final MapleCharacter source, final byte[] packet, final double rangeSq, final Point rangedFrom) {
charactersLock.readLock().lock();
try {
for (MapleCharacter chr : characters) {
if (chr != source) {
if (rangeSq < Double.POSITIVE_INFINITY) {
if (rangedFrom.distanceSq(chr.getTruePosition()) <= rangeSq) {
chr.getClient().getSession().write(packet);
}
} else {
chr.getClient().getSession().write(packet);
}
}
}
} finally {
charactersLock.readLock().unlock();
}
}
示例6: getMapObjectsInRange
import java.awt.Point; //導入方法依賴的package包/類
public final List<MapleMapObject> getMapObjectsInRange(final Point from, final double rangeSq) {
final List<MapleMapObject> ret = new ArrayList<>();
for (MapleMapObjectType type : MapleMapObjectType.values()) {
mapobjectlocks.get(type).readLock().lock();
try {
Iterator<MapleMapObject> itr = mapobjects.get(type).values().iterator();
while (itr.hasNext()) {
MapleMapObject mmo = itr.next();
if (from.distanceSq(mmo.getTruePosition()) <= rangeSq) {
ret.add(mmo);
}
}
} finally {
mapobjectlocks.get(type).readLock().unlock();
}
}
return ret;
}
示例7: getClosestMapObjectInRange
import java.awt.Point; //導入方法依賴的package包/類
public final MapleMapObject getClosestMapObjectInRange(final Point from, final double rangeSq, final List<MapleMapObjectType> MapObject_types) {
MapleMapObject ret = null;
for (MapleMapObjectType type : MapObject_types) {
mapobjectlocks.get(type).readLock().lock();
try {
Iterator<MapleMapObject> itr = mapobjects.get(type).values().iterator();
while (itr.hasNext()) {
MapleMapObject mmo = itr.next();
if (from.distanceSq(mmo.getTruePosition()) <= rangeSq && (ret == null || from.distanceSq(ret.getTruePosition()) > from.distanceSq(mmo.getTruePosition()))) {
ret = mmo;
}
}
} finally {
mapobjectlocks.get(type).readLock().unlock();
}
}
return ret;
}
示例8: getPortalsInRange
import java.awt.Point; //導入方法依賴的package包/類
public final List<MaplePortal> getPortalsInRange(final Point from, final double rangeSq) {
final List<MaplePortal> ret = new ArrayList<>();
for (MaplePortal type : portals.values()) {
if (from.distanceSq(type.getPosition()) <= rangeSq && type.getTargetMapId() != mapid && type.getTargetMapId() != 999999999) {
ret.add(type);
}
}
return ret;
}