當前位置: 首頁>>代碼示例>>Java>>正文


Java Point.distanceSq方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:NovaStory,項目名稱:AeroStory,代碼行數:19,代碼來源:MapleMap.java

示例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();
    }
}
 
開發者ID:NovaStory,項目名稱:AeroStory,代碼行數:17,代碼來源:MapleMap.java

示例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();
    }
}
 
開發者ID:NovaStory,項目名稱:AeroStory,代碼行數:19,代碼來源:MapleMap.java

示例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));
    }
}
 
開發者ID:ergothvs,項目名稱:Lucid2.0,代碼行數:19,代碼來源:AbstractPlayerInteraction.java

示例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();
    }
}
 
開發者ID:ergothvs,項目名稱:Lucid2.0,代碼行數:19,代碼來源:MapleMap.java

示例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;
}
 
開發者ID:ergothvs,項目名稱:Lucid2.0,代碼行數:19,代碼來源:MapleMap.java

示例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;
}
 
開發者ID:ergothvs,項目名稱:Lucid2.0,代碼行數:19,代碼來源:MapleMap.java

示例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;
}
 
開發者ID:ergothvs,項目名稱:Lucid2.0,代碼行數:10,代碼來源:MapleMap.java


注:本文中的java.awt.Point.distanceSq方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。