View Javadoc

1   package erland.game.tileadventure;
2   /*
3    * Copyright (C) 2004 Erland Isaksson (erland_i@hotmail.com)
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License
7    * as published by the Free Software Foundation; either version 2
8    * of the License, or (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18   *
19   */
20  
21  import erland.game.GameEnvironmentInterface;
22  import erland.util.ParameterValueStorageExInterface;
23  import erland.util.ParameterSerializable;
24  
25  import java.awt.*;
26  
27  
28  public class RoomObject implements Cloneable, MapObjectInterface {
29      /*** The block container which the block exist in */
30      private IrregularBlockContainerInterface cont;
31      /*** The x position of the block */
32      private float posX;
33      /*** The y position of the block */
34      private float posY;
35      /*** The z position of the block */
36      private float posZ;
37      /*** The game environment of the block */
38      private GameEnvironmentInterface environment;
39      /*** The blocks in the room */
40      private MapObjectContainerInterface maps;
41      /*** The extended level info for the room */
42      private ParameterSerializable extendedLevelInfo;
43      /*** Bounding box */
44      private Box3D boundingBox;
45  
46      public void init(GameEnvironmentInterface environment) {
47          this.environment = environment;
48      }
49  
50      public void setContainer(IrregularBlockContainerInterface cont) {
51          this.cont = cont;
52      }
53  
54      public IrregularBlockContainerInterface getContainer() {
55          return cont;
56      }
57  
58      public float getPosX() {
59          return posX;
60      }
61  
62      public float getPosY() {
63          return posY;
64      }
65  
66      public float getPosZ() {
67          return posZ;
68      }
69  
70      public void setPos(float x, float y, float z) {
71          this.posX = x;
72          this.posY = y;
73          this.posZ = z;
74          if(boundingBox!=null) {
75              boundingBox.setLocation(x,y,z);
76              boundingBox.setSize(999f,0.999f,0.999f);
77          }
78      }
79  
80      public void draw(Graphics g) {
81          // Nothing to draw
82      }
83  
84      public Object clone() {
85          RoomObject b=null;
86          try {
87              b = (RoomObject)super.clone();
88          } catch (CloneNotSupportedException e) {
89              e.printStackTrace();
90          }
91          return b;
92      }
93  
94      public void setBlocks(MapObjectContainerInterface maps) {
95          this.maps = maps;
96      }
97      public MapObjectContainerInterface getBlocks() {
98          return maps;
99      }
100 
101     public void setExtendedLevelInfo(ParameterSerializable extendedLevelInfo) {
102         this.extendedLevelInfo = extendedLevelInfo;
103     }
104     public ParameterSerializable getExtendedLevelInfo() {
105         return extendedLevelInfo;
106     }
107 
108     public Box3D getBoundingBox() {
109         if(boundingBox==null) {
110             boundingBox = new Box3D();
111             boundingBox.setLocation(posX,posY,posZ);
112             boundingBox.setSize(0.999f,0.999f,0.999f);
113         }
114         return boundingBox;
115     }
116 }
117