⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interiormapdata.java

📁 Vyger offers a D & D and Rogue-like environment in a graphical online roleplay game.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    myPlayer.getDrawable(),   // reference for screen movements
                    new Dimension( JClientScreen.leftWidth, JClientScreen.mapHeight )   // screen default dimension
                   );

    // 7 - We show the roomLinks
    if (SHOW_DEBUG) {
      RoomLink[] roomLinks = room.getRoomLinks();
      if (roomLinks != null) {
        System.out.println("\tDrawing RoomLink");
        for (int i=0; i<roomLinks.length; i++) {
          //System.out.println("\t\troomLinks["+i+"] = " + roomLinks[i]);
          dataManager.drawScreenRectangle(roomLinks[i].toRectangle(), Color.green);
        }
        roomLinks = null;
      }
    }

    // 8 - We show the mapExits
    if (SHOW_DEBUG) {
      MapExit[] mapExits = room.getMapExits();
      if (mapExits!= null) {
        System.out.println("\tDrawing MapExit");
        for (int i=0; i<mapExits.length; i++) {
          //System.out.println("\t\tmapExits["+i+"] = " + mapExits[i]);
          dataManager.drawScreenRectangle(mapExits[i].toRectangle(), Color.yellow);
        }
        mapExits = null;
      }
    }

    // 9 - We add visual properties to the player (shadows...)
    if (SHOW_DEBUG)
      System.out.println("Player init visual properties");

    myPlayer.initVisualProperties(gDirector);

    // 10 - We show some informations on the screen
    gDirector.addDrawable(myPlayer.getGameScreenFullPlayerName());

    String[] strTemp2 = { room.getFullName() };
    mltLocationName = new MultiLineText(strTemp2, 10, 10, Color.black, 15.0f, "Lucida Blackletter", ImageLibRef.TEXT_PRIORITY, MultiLineText.RIGHT_ALIGNMENT);
    gDirector.addDrawable(mltLocationName);

    // 11 - We add eventual doors...
      Room rooms[] = imap.getRooms();

        // Init doors state
        for( int r=0; r<rooms.length; r++ ) {
             if(rooms[r]==null) continue;
        
             Door doors[] = rooms[r].getDoors();
             
             if(doors==null) continue;
             
             for( int d=0; d<doors.length; d++ )
                doors[d].clean();
        }

        // Display doors
        for( int r=0; r<rooms.length; r++ ) {
             if(rooms[r]==null) continue;

             Door doors[] = rooms[r].getDoors();

             if(doors==null) continue;

             for( int d=0; d<doors.length; d++ )
                  if( !doors[d].isDisplayed() ) {
                      gDirector.addDrawable( doors[d].getDoorDrawable() );
                      doors[d].setIsDisplayed(true);
                  }
        }

    // 12 - We play the map's music
    String midiFile = imap.getMusicName();

    if(midiFile != null)
       SoundLibrary.getMusicPlayer().playMusic( midiFile );
    
    //  13 - We retrieve non-local data ( door state, players, chat info, etc... )
      if (SHOW_DEBUG)
        System.out.println("Sending final AllDataLeftMessage...");

      dataManager.sendMessage( new AllDataLeftPleaseMessage() );
  }

 /*------------------------------------------------------------------------------------*/

  /** To update the location<br>
   * - test if player is intersecting a screenZone<br>
   * - test if player is entering a new WotlasLocation<br>
   * - change the current MapData
   */
  public void locationUpdate(PlayerImpl myPlayer) {

    if(dataManager==null)
       return;

    // Has the currentLocation changed ?

    if ( currentInteriorMapID != myPlayer.getLocation().getInteriorMapID() ) {
      if (DataManager.SHOW_DEBUG)
        System.out.println("LOCATION HAS CHANGED in InteriorMapData");
        
      Debug.signal( Debug.NOTICE, null, "LOCATION HAS CHANGED in InteriorMapData");

      dataManager.getPlayers().clear();
      dataManager.cleanInteriorMapData(); // suppress drawables, shadows, data
      dataManager.getClientScreen().getChatPanel().reset();

      //  - We clean eventual doors data...
      Room rooms[] = imap.getRooms();

      for( int r=0; r<rooms.length; r++ ) {
        Door doors[] = rooms[r].getDoors();
        for( int d=0; d<doors.length; d++ )
          doors[d].clean();
      }

      dataManager.changeMapData();
      return;
    }

    if (currentRoomID != myPlayer.getLocation().getRoomID() ) {
      Debug.signal( Debug.NOTICE, null, "ROOM HAS CHANGED in InteriorMapData");
      currentRoomID = myPlayer.getLocation().getRoomID();
      Room room = myPlayer.getMyRoom();

      couldBeMovingToAnotherRoom = true;

      // We must reset the room
      resetRoom = true;
    }

    Room myRoom = dataManager.getWorldManager().getRoom( myPlayer.getLocation() );

    // I - ROOMLINK INTERSECTION UPDATE ( is the player moving to another room ? )
    RoomLink rl = myRoom.isIntersectingRoomLink( myPlayer.getCurrentRectangle() );

    // is there a Door ?
    if ( rl!=null && rl.getDoor()!=null ) {
      if ( !rl.getDoor().isOpened()
            && !rl.getDoor().canMove(myPlayer.getCurrentRectangle(),
                                        myPlayer.getEndPosition() ) ) {
        myPlayer.stopMovement();
      }
    }

    // Moving to another Room ?
    if ( rl!=null && !couldBeMovingToAnotherRoom ) {
      // Player is intersecting a RoomLink
         latestRoomLink = rl;
         couldBeMovingToAnotherRoom = true;
    } else if ( rl==null && couldBeMovingToAnotherRoom ) {
      // ok, no intersection now, are we in an another room ?
      couldBeMovingToAnotherRoom = false;

      int newRoomID;
      if (!resetRoom) {
        newRoomID = myRoom.isInOtherRoom( latestRoomLink, myPlayer.getCurrentRectangle() );
      } else {
        newRoomID = myRoom.getRoomID();
        //System.out.println("Net congestion => resetting the room");
        resetRoom = false;
      }

      if ( newRoomID>=0 ) {
        // Ok, we move to this new Room
        WotlasLocation location = myPlayer.getLocation();
        location.setRoomID( newRoomID );
        currentRoomID = newRoomID;
        myPlayer.setLocation(location);
        Room room = myPlayer.getMyRoom();

        if (SHOW_DEBUG)
          System.out.println("dataManager.sendMessage( new EnteringRoomMessage(...) )");

        dataManager.sendMessage( new EnteringRoomMessage(myPlayer.getPrimaryKey(), myPlayer.getLocation(),
                                                         myPlayer.getX(), myPlayer.getY(),
                                                         (float)myPlayer.getAngle() ) );

        if (SHOW_DEBUG)
          System.out.println("Changing main ChatRoom");

        dataManager.getClientScreen().getChatPanel().reset();
        dataManager.getClientScreen().getChatPanel().changeMainJChatRoom(room.getShortName());

        String[] strTemp = { room.getFullName() };
        mltLocationName.setText(strTemp);

        if (SHOW_DEBUG)
          System.out.print("Move to another room : " + newRoomID + " -> " + room.getFullName());

        if (SHOW_DEBUG) {
          RoomLink[] roomLinks = room.getRoomLinks();
          if (roomLinks != null) {
            for (int i=0; i<roomLinks.length; i++) {
              dataManager.drawScreenRectangle(roomLinks[i].toRectangle(), Color.green);
            }
            roomLinks = null;
          }
        }

        if (SHOW_DEBUG) {
          MapExit[] mapExits = room.getMapExits();
          if (mapExits!= null) {
            for (int i=0; i<mapExits.length; i++) {
              dataManager.drawScreenRectangle(mapExits[i].toRectangle(), Color.yellow);
            }
            mapExits = null;
          }
        }

      }
    } // End of part I

    // II - MAPEXIT INTERSECTION UPDATE ( is the player moving to another map ? )
    if ( myPlayer.isMoving() ) {
      Point destination = myPlayer.getEndPosition();
      MapExit mapExit = myRoom.isIntersectingMapExit( destination.x,
                                                      destination.y,
                                                      myPlayer.getCurrentRectangle()
                                                     );
      if ( mapExit!=null ) {
        // Ok, we are going to a new map...
        if (SHOW_DEBUG)
          System.out.println("We are going to a new map...");

        myPlayer.getMovementComposer().resetMovement();

        if (isNotMovingToAnotherMap) {
          isNotMovingToAnotherMap = false;
          myPlayer.sendMessage( new CanLeaveIntMapMessage( myPlayer.getPrimaryKey(),
                                        mapExit.getTargetWotlasLocation(),
                                        mapExit.getTargetPosition().x, mapExit.getTargetPosition().y,
                                        mapExit.getTargetOrientation() ) );
        }
      }
    } // End of part II
  }

 /*------------------------------------------------------------------------------------*/

}


  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -