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

📄 townmap.java

📁 Vyger offers a D & D and Rogue-like environment in a graphical online roleplay game.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * Light And Shadow. A Persistent Universe based on Robert Jordan's Wheel of Time Books.
 * Copyright (C) 2001-2002 WOTLAS Team
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
package wotlas.common.universe;

import wotlas.libs.graphics2D.ImageIdentifier;
import wotlas.common.*;
import wotlas.common.router.*;
import wotlas.utils.*;

import java.awt.Rectangle;
import java.awt.Point;

 /** A TownMap represents a town in our Game Universe.
  *
  * @author Petrus, Aldiss, Diego
  * @see wotlas.common.universe.WorldMap
  * @see wotlas.common.universe.Building
  */
 
public class TownMap extends ScreenRectangle implements WotlasMap {

 /*------------------------------------------------------------------------------------*/
 
  /** ID of the TownMap (index in the array of townmaps in the WorldMap)
   */
    private int townMapID;
     
  /** Full name of the Town
   */
    private String fullName;
   
  /** Short name of the Town
   */
    private String shortName;

  /** Small Image (identifier) of this town for WorldMaps.
   */
    private ImageIdentifier smallTownImage;

  /** Full Image (identifier) of this town
   */
    private ImageIdentifier townImage;

  /** Point of insertion (teleportation, arrival)
   */
    private ScreenPoint insertionPoint;

  /** Music Name
   */
    private String musicName;

  /** Map exits...
   */
    private MapExit[] mapExits;

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

  /** Link to the worldMap we belong to...
   */
    private transient WorldMap myWorldMap;

  /** Array of Building
   */
    private transient Building[] buildings;
  
  /** Our message router. Owns the list of players of this map (not in buildings).
   */
    private transient MessageRouter messageRouter;

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

  /** Constructor for persistence.
   */
    public TownMap() {
    }
   
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /** Constructor with x,y positions & width,height dimension on WorldMap.
   * @param x x position of this building on a WorldMap.
   * @param y y position of this building on a WorldMap.
   * @param width width dimension of this building on a WorldMap.
   * @param height height dimension of this building on a WorldMap.
   */
    public TownMap(int x, int y, int width, int height) {
       super(x,y,width,height);
    }

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

  /*
   * List of setter and getter used for persistence
   */
    public void setTownMapID(int myTownMapID) {
      this.townMapID = myTownMapID;
    }

    public int getTownMapID() {
      return townMapID;
    }

    public void setFullName(String myFullName) {
      this.fullName = myFullName;
    }

    public String getFullName() {
      return fullName;
    }

    public void setShortName(String myShortName) {
      this.shortName = myShortName;
    }

    public String getShortName() {
      return shortName;
    }

    public void setSmallTownImage(ImageIdentifier smallTownImage) {
      this.smallTownImage = smallTownImage;
    }

    public ImageIdentifier getSmallTownImage() {
      return smallTownImage;
    }

    public void setTownImage(ImageIdentifier townImage) {
      this.townImage = townImage;
    }

    public ImageIdentifier getTownImage() {
      return townImage;
    }

    public void setMapExits(MapExit[] myMapExits) {
      this.mapExits = myMapExits;
    }

    public MapExit[] getMapExits() {
      return mapExits;
    }

    public void setInsertionPoint(ScreenPoint myInsertionPoint) {
      this.insertionPoint = myInsertionPoint;
    }

    public ScreenPoint getInsertionPoint() {
      return new ScreenPoint( insertionPoint );
    }

    public void setMusicName(String musicName) {
      this.musicName = musicName;
    }

    public String getMusicName() {
      return musicName;
    }

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

  /** Transient fields getter & setter
   */

    public WorldMap getMyWorldMap() {
      return myWorldMap;
    }

    public void setBuildings(Building[] myBuildings) {
      this.buildings = myBuildings;
    }

    public Building[] getBuildings() {
      return buildings;
    }

    public MessageRouter getMessageRouter() {
      return messageRouter;
    }

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

  /** To Get a building by its ID.
   *
   * @param id buildingID
   * @return corresponding building, null if ID does not exist.
   */
    public Building getBuildingFromID( int id ) {
   	if(id>=buildings.length || id<0) {
           Debug.signal( Debug.ERROR, this, "getBuildingFromID : Bad building ID "+id );
   	   return null;
   	}
   	
        return buildings[id];
    }

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

  /** To get the wotlas location associated to this Map.
   *  @return associated Wotlas Location
   */
    public WotlasLocation getLocation() {
       return new WotlasLocation( myWorldMap.getWorldMapID(),townMapID );
    }

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

  /** Add a new Building object to our list {@link #buildings buildings})
   *
   * @param building Building object to add
   */
    public void addBuilding( Building building ) {
        if ( buildings == null ) {
             buildings = new Building[building.getBuildingID()+1];
        }
        else if( buildings.length <= building.getBuildingID() ) {
           Building[] myBuildings = new Building[building.getBuildingID()+1];
           System.arraycopy( buildings, 0, myBuildings, 0, buildings.length );
           buildings = myBuildings;
        }

        buildings[building.getBuildingID()] = building;        
    }

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

  /** Add a new Building object to the array {@@link #buildings buildings})
   *
   * @return a new Building object

⌨️ 快捷键说明

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