Example #1
0
 private void setPortal(Portal portal) {
   switch (portal.getColor()) {
     case BLUE:
       bluePortal = portal;
       break;
     case ORANGE:
       orangePortal = portal;
       break;
     default:
       throw new NoSuchElementException(portal.getColor() + " is not a valid PortalColor");
   }
 }
Example #2
0
  /** Creates a Portal of the specified color */
  private void createPortal(PortalColor color) {
    Portal portal = getPortal(color);

    if (portal == null) {
      portal = new Portal(level, raycast.getPosition(), color, raycast.getPortalNormal());

      level.add(portal);
      setPortal(portal);
      linkPortals();
    } else {
      portal.setPosition(raycast.getPosition());
      portal.setNormal(raycast.getPortalNormal());
    }
  }
Example #3
0
 public boolean arePortalsLinked() {
   return orangePortal != null
       && orangePortal.isLinked()
       && bluePortal != null
       && bluePortal.isLinked();
 }
Example #4
0
 /**
  * Sets the opposite portal of both portals.
  *
  * @see Portal#oppositePortal
  */
 protected void linkPortals() {
   if (orangePortal != null && bluePortal != null) {
     bluePortal.setOppositePortal(orangePortal);
     orangePortal.setOppositePortal(bluePortal);
   }
 }