📄 groupofgraphics.java
字号:
/* * * * * GRAN CASINO IN CORSO: * IL SALVATAGGIO DEI GROUP OF GRAPHICS DENTRO LE TILEMAPS * CREA NUOVE DISTINTE ISTANZE DEGLI STESSI IN MEMORIA. * * IO INVECE VOGLIO UNA SOLA ISTANZA DI QUESTI COSI :) * * * * * * * Light And Shadow. A Persistent Universe based on Robert Jordan's Wheel of Time Books. * Copyright (C) 2001-2003 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.libs.graphics2D;import wotlas.libs.graphics2D.ImageIdentifier;import wotlas.libs.graphics2D.GraphicsDirector;import wotlas.common.*;import wotlas.libs.persistence.*;import wotlas.common.universe.*;import java.awt.*;import java.awt.Point;import java.awt.image.BufferedImage;import javax.swing.*; /** Group of graphics represents an Id+ the size of the Tiles inside the image, and the name of the image * * WHT'S THE USE of Group of graphics? * * well let's explain: * * Every TileMap, from Flat to FakeIso, needs to load images, with ImageIdentifier. * TileMap need many ImageIdentifier, but it need even information about 'em, * beacause inside every image, there are at least 5 tiles. * To use the tiles, you need to know the dimension of 'em width*height this value * is saved inside <singleTileSize> * * How do you create an object? With this function: * public GroupOfGraphics( byte Id, byte[] singleTileSize, String tileImageSet ) * * <Id> this Id it's used from the TileMap data * <singleTileSize> was just explained * <tileImageSet> is the name of the image with inside at least 5 tiles * * @author Diego * @see wotlas.common.universe.TileMap * @see wotlas.common.universe.TilePosition * @see wotlas.client.TileMapData */ public class GroupOfGraphics implements BackupReady { /** id used in Serialized interface. */ private static final long serialVersionUID = 556565L; /** Pre-definies set of data array[7] of GroupOfGraphics * */ static public GroupOfGraphics[] DEMO_SET = { new GroupOfGraphics( (byte)0, TileMap.PIXEL_50, TileMap.TILE, "tilemaps-cat-3/openmap-set-1/basic_tile-0/grass-0.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)1, TileMap.PIXEL_50, TileMap.TILE, "tilemaps-cat-3/openmap-set-1/add_tile-1/little_road-10.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)2, TileMap.PIXEL_50, TileMap.TILE, "tilemaps-cat-3/openmap-set-1/add_tile-1/water-4.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)3, TileMap.PIXEL_50, TileMap.TILE, "tilemaps-cat-3/fakeiso-set-0/floor-set-0/fix-5.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)4, TileMap.PIXEL_50, TileMap.TILE, "tilemaps-cat-3/fakeiso-set-0/carpet-set-2/carpet-2.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)5, TileMap.PIXEL_80X40, TileMap.WALLX, "tilemaps-cat-3/fakeiso-set-0/wall-set-1/fix_wallwoodX6-20.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)6, TileMap.PIXEL_40X80, TileMap.WALLY, "tilemaps-cat-3/fakeiso-set-0/wall-set-1/fix_wallwoodY6-31.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)7, TileMap.PIXEL_80X40, TileMap.WALLX, "tilemaps-cat-3/fakeiso-set-0/wall-set-1/fix_wallwoodX3-3.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)8, TileMap.PIXEL_40X80, TileMap.WALLY, "tilemaps-cat-3/fakeiso-set-0/wall-set-1/fix_wallwoodY3-11.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)9, TileMap.PIXEL_70X35, TileMap.TILE, "tilemaps-cat-3/fakeiso-set-0/door-set-3/door-x-0.png", TileMap.TILE_FREE ) }; static public GroupOfGraphics[] ROGUE_SET = { new GroupOfGraphics( (byte)0, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/ground-0/onlygrounds-0.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)1, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/ground-0/tree-1.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)2, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/ground-0/roads-2.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)3, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/ground-0/roads2-3.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)4, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/ground-0/mixwater-4.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)5, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/ground-0/dungeons-5.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)6, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/ground-0/strange-6.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)7, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/ground-0/wall-7.png", TileMap.TILE_NOT_FREE ) };/* static public GroupOfGraphics[] ROGUE_SET_ISO = { new GroupOfGraphics( (byte)0, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/ground/dg_iso32-13.png" ) }; */ static public GroupOfGraphics[] ROGUE_NPC_SET = { new GroupOfGraphics( (byte)0, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/classes-0.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)1, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_dragon32-1.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)2, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_humans32-2.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)3, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_monster132-3.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)4, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_monster232-4.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)5, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_monster332-5.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)6, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_monster432-6.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)7, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_monster532-7.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)8, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_monster632-8.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)9, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_monster732-9.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)10, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_people32-10.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)11, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_undead32-11.png", TileMap.TILE_NOT_FREE ) ,new GroupOfGraphics( (byte)12, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/npc-1/dg_uniques32-12.png", TileMap.TILE_NOT_FREE ) }; static public GroupOfGraphics[] ROGUE_EFFECT_SET = { new GroupOfGraphics( (byte)0, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/effects-2/dg_effects32-0.png", TileMap.TILE_FREE ) }; static public GroupOfGraphics[] ROGUE_ITEM_SET = { new GroupOfGraphics( (byte)0, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/item-3/dg_armor32-0.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)1, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/item-3/dg_weapons32-1.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)2, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/item-3/dg_wands32-2.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)3, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/item-3/dg_potions32-3.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)4, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/item-3/dg_books32-4.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)5, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/item-3/dg_jewls32-5.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)6, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/item-3/dg_food32-6.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)7, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/item-3/dg_misc32-7.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)8, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/item-3/fountains-8.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)9, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/item-3/doors-9.png", TileMap.TILE_FREE ) ,new GroupOfGraphics( (byte)10, TileMap.PIXEL_32, TileMap.TILE, "tilemaps-cat-3/angband-rougue-library-2/item-3/system-10.png", TileMap.TILE_FREE ) }; /*------------------------------------------------------------------------------------*/ /** <Id> this Id it's used from the TileMap data */ private byte Id; /** ............... */ private boolean freeWalk; /** ............... */ private byte tileType; /** read class description */ private Dimension tileDim; /** <tileImageSet> is the name of the image with inside at least 5 tiles */ private String tileImageSet; transient private ImageIdentifier image; transient private int Xlen; transient private int Ylen; transient protected int[][] Pos; transient protected short[][] Offset; public GroupOfGraphics() { } /** create the object, read class description */ public GroupOfGraphics( byte Id, Dimension tileDim, byte tileType , String tileImageSet, boolean freeWalk ) { this.Id = Id; this.tileDim = tileDim; this.tileType = tileType; this.freeWalk = freeWalk; this.tileImageSet = tileImageSet; } public void init( GraphicsDirector gDirector ) { image = new ImageIdentifier(tileImageSet); gDirector.getImageLibrary().loadImage( image ); } /*------------------------------------------------------------------------------------*/ /** String Info. */ public String toString(){ return "GroupOfGraphics - "; } /*------------------------------------------------------------------------------------*/ /** id version of data, used in serialized persistance.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -