当前位置: 首页>>代码示例>>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;未经允许,请勿转载。