Package lineage2.commons.geometry

Examples of lineage2.commons.geometry.Polygon


                }
              }
              Territory territory = null;
              if (spawnType == 2)
              {
                Polygon poly = new Polygon();
                for (Location loc : coords)
                {
                  poly.add(loc.x, loc.y).setZmin(loc.z).setZmax(loc.z);
                }
                if (!poly.validate())
                {
                  error("invalid spawn territory for instance id : " + instanceId + " - " + poly + "!");
                }
                territory = new Territory().add(poly);
              }
View Full Code Here


              Territory territory = null;
              for (Node s1 = d1.getFirstChild(); s1 != null; s1 = s1.getNextSibling())
              {
                if ("territory".equalsIgnoreCase(s1.getNodeName()))
                {
                  Polygon poly = new Polygon();
                  for (Node s2 = s1.getFirstChild(); s2 != null; s2 = s2.getNextSibling())
                  {
                    if ("add".equalsIgnoreCase(s2.getNodeName()))
                    {
                      int x = Integer.parseInt(s2.getAttributes().getNamedItem("x").getNodeValue());
                      int y = Integer.parseInt(s2.getAttributes().getNamedItem("y").getNodeValue());
                      int minZ = Integer.parseInt(s2.getAttributes().getNamedItem("zmin").getNodeValue());
                      int maxZ = Integer.parseInt(s2.getAttributes().getNamedItem("zmax").getNodeValue());
                      poly.add(x, y).setZmin(minZ).setZmax(maxZ);
                    }
                  }
                  territory = new Territory().add(poly);
                  if (!poly.validate())
                  {
                    _log.error("HellboundManager: Invalid spawn territory : " + poly + "!");
                    continue;
                  }
                }
View Full Code Here

   * @param forceUse boolean
   */
  private void addTargetsToList(List<Creature> targets, Creature aimingTarget, Creature activeChar, boolean forceUse)
  {
    int count = 0;
    Polygon terr = null;
    if (_targetType == SkillTargetType.TARGET_TUNNEL)
    {
      int radius = 100;
      int zmin1 = activeChar.getZ() - 200;
      int zmax1 = activeChar.getZ() + 200;
      int zmin2 = aimingTarget.getZ() - 200;
      int zmax2 = aimingTarget.getZ() + 200;
      double angle = PositionUtils.convertHeadingToDegree(activeChar.getHeading());
      double radian1 = Math.toRadians(angle - 90);
      double radian2 = Math.toRadians(angle + 90);
      terr = new Polygon().add(activeChar.getX() + (int) (Math.cos(radian1) * radius), activeChar.getY() + (int) (Math.sin(radian1) * radius)).add(activeChar.getX() + (int) (Math.cos(radian2) * radius), activeChar.getY() + (int) (Math.sin(radian2) * radius)).add(aimingTarget.getX() + (int) (Math.cos(radian2) * radius), aimingTarget.getY() + (int) (Math.sin(radian2) * radius)).add(aimingTarget.getX() + (int) (Math.cos(radian1) * radius), aimingTarget.getY() + (int) (Math.sin(radian1) * radius)).setZmin(Math.min(zmin1, zmin2)).setZmax(Math.max(zmax1, zmax2));
    }
    for (Creature target : aimingTarget.getAroundCharacters(_skillRadius, 300))
    {
      if ((terr != null) && !terr.isInside(target.getX(), target.getY(), target.getZ()))
      {
        continue;
      }
      if ((target == null) || (activeChar == target) || ((activeChar.getPlayer() != null) && (activeChar.getPlayer() == target.getPlayer())))
      {
View Full Code Here

   */
  public void addTargetsToLakcis(List<Creature> targets, Creature activeChar, boolean isHealTask)
  {   
    _skillHealStance = isHealTask;
    int count = 0;
    Polygon terr = null;
    for (Creature target : activeChar.getAroundCharacters(_skillRadius, 300))
    {
      if ((terr != null) && !terr.isInside(target.getX(), target.getY(), target.getZ()))
      {
        continue;
      }
      if ((target == null) || (activeChar == target) || ((activeChar.getPlayer() != null) && (activeChar.getPlayer() == target.getPlayer())))
      {
View Full Code Here

              territory.addBanned(shape);
            }
          }
          else if ((isShape = "polygon".equalsIgnoreCase(n.getName())) || "banned_polygon".equalsIgnoreCase(n.getName()))
          {
            Polygon shape = parsePolygon(n);
            if (!shape.validate())
            {
              error("ZoneParser: invalid territory data : " + shape + ", zone: " + zoneDat.getString("name") + "!");
            }
            if (territory == null)
            {
View Full Code Here

   * @param shape Element
   * @return Polygon * @throws Exception
   */
  public static Polygon parsePolygon(Element shape) throws Exception
  {
    Polygon poly = new Polygon();
    for (Iterator<Element> i = shape.elementIterator(); i.hasNext();)
    {
      Element d = i.next();
      if ("coords".equals(d.getName()))
      {
        String[] coord = d.attributeValue("loc").split("[\\s,;]+");
        if (coord.length < 4)
        {
          poly.add(Integer.parseInt(coord[0]), Integer.parseInt(coord[1])).setZmin(World.MAP_MIN_Z).setZmax(World.MAP_MAX_Z);
        }
        else
        {
          poly.add(Integer.parseInt(coord[0]), Integer.parseInt(coord[1])).setZmin(Integer.parseInt(coord[2])).setZmax(Integer.parseInt(coord[3]));
        }
      }
    }
    return poly;
  }
View Full Code Here

            }
            territory.add(shape);
          }
          else if ("polygon".equalsIgnoreCase(n.getName()))
          {
            Polygon shape = ZoneParser.parsePolygon(n);
            if (!shape.validate())
            {
              error("RestartPointParser: invalid territory data : " + shape + "!");
            }
            if (territory == null)
            {
View Full Code Here

   * @param e Element
   * @return Polygon
   */
  private Polygon parsePolygon0(String name, Element e)
  {
    Polygon temp = new Polygon();
    for (Iterator<Element> addIterator = e.elementIterator("add"); addIterator.hasNext();)
    {
      Element addElement = addIterator.next();
      int x = Integer.parseInt(addElement.attributeValue("x"));
      int y = Integer.parseInt(addElement.attributeValue("y"));
      int zmin = Integer.parseInt(addElement.attributeValue("zmin"));
      int zmax = Integer.parseInt(addElement.attributeValue("zmax"));
      temp.add(x, y).setZmin(zmin).setZmax(zmax);
    }
    if (!temp.validate())
    {
      error("Invalid polygon: " + name + "{" + temp + "}. File: " + getCurrentFileName());
    }
    return temp;
  }
View Full Code Here

        for (Iterator<Element> i = listElement.elementIterator(); i.hasNext();)
        {
          Element n = i.next();
          if ("polygon".equalsIgnoreCase(n.getName()))
          {
            Polygon shape = ZoneParser.parsePolygon(n);
            if (!shape.validate())
            {
              error("DomainParser: invalid territory data : " + shape + "!");
            }
            if (territory == null)
            {
View Full Code Here

        Location doorPos;
        int x = Integer.parseInt(posElement.attributeValue("x"));
        int y = Integer.parseInt(posElement.attributeValue("y"));
        int z = Integer.parseInt(posElement.attributeValue("z"));
        doorSet.set("pos", doorPos = new Location(x, y, z));
        Polygon shape = new Polygon();
        int minz = 0, maxz = 0;
        Element shapeElement = doorElement.element("shape");
        minz = Integer.parseInt(shapeElement.attributeValue("minz"));
        maxz = Integer.parseInt(shapeElement.attributeValue("maxz"));
        shape.add(Integer.parseInt(shapeElement.attributeValue("ax")), Integer.parseInt(shapeElement.attributeValue("ay")));
        shape.add(Integer.parseInt(shapeElement.attributeValue("bx")), Integer.parseInt(shapeElement.attributeValue("by")));
        shape.add(Integer.parseInt(shapeElement.attributeValue("cx")), Integer.parseInt(shapeElement.attributeValue("cy")));
        shape.add(Integer.parseInt(shapeElement.attributeValue("dx")), Integer.parseInt(shapeElement.attributeValue("dy")));
        shape.setZmin(minz);
        shape.setZmax(maxz);
        doorSet.set("shape", shape);
        doorPos.setZ(minz + 32);
        for (Iterator<Element> i = doorElement.elementIterator(); i.hasNext();)
        {
          Element n = i.next();
          if ("set".equals(n.getName()))
          {
            doorSet.set(n.attributeValue("name"), n.attributeValue("value"));
          }
          else if ("ai_params".equals(n.getName()))
          {
            if (aiParams == null)
            {
              aiParams = new StatsSet();
              doorSet.set("ai_params", aiParams);
            }
            for (Iterator<Element> aiParamsIterator = n.elementIterator(); aiParamsIterator.hasNext();)
            {
              Element aiParamElement = aiParamsIterator.next();
              aiParams.set(aiParamElement.attributeValue("name"), aiParamElement.attributeValue("value"));
            }
          }
        }
        doorSet.set("uid", doorElement.attributeValue("id"));
        doorSet.set("name", doorElement.attributeValue("name"));
        doorSet.set("baseHpMax", doorElement.attributeValue("hp"));
        doorSet.set("basePDef", doorElement.attributeValue("pdef"));
        doorSet.set("baseMDef", doorElement.attributeValue("mdef"));
        doorSet.set("collision_height", (maxz - minz) & 0xfff0);
        doorSet.set("collision_radius", Math.max(50, Math.min(doorPos.x - shape.getXmin(), doorPos.y - shape.getYmin())));
        DoorTemplate template = new DoorTemplate(doorSet);
        getHolder().addTemplate(template);
      }
    }
  }
View Full Code Here

TOP

Related Classes of lineage2.commons.geometry.Polygon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.