1 /***************************************************************************
2 * Copyright (C) 2010 by the Alterverse team *
3 * email: rynkruger@gmail.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
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. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write see: *
17 * <http://www.gnu.org/licenses/>. *
18 ***************************************************************************/
20 package org
.alterverse
.world
;
23 import org
.alterverse
.shapes
.*;
24 import org
.alterverse
.sound
.*;
25 import java
.util
.ArrayList
;
27 public class GameObject
implements Serializable
{
35 ArrayList
<Sound
> sounds
;
38 public GameObject(Area area
) {
39 this(area
,0.0,0.0,0.0,new Shape());
42 public GameObject(Area area
, Shape shape
) {
43 this.x
=(shape
.minX()+shape
.maxX())/2;
44 this.y
=(shape
.minY()+shape
.maxY())/2;
45 this.z
=(shape
.minZ()+shape
.maxZ())/2;
48 sounds
=new ArrayList
<Sound
>();
55 public GameObject(Area area
,double x
,double y
,double z
,Shape shape
) {
61 sounds
=new ArrayList
<Sound
>();
68 public boolean isTouching(GameObject other
) {
69 return this.getShape().isTouching(other
.getShape());
72 public void onBump(GameObject obj
) {
76 public boolean canEnter(GameObject othr
) {
77 return !(this.isSolid()&&othr
.isSolid());
80 public boolean isSolid() {
84 public void setSolid(boolean solid
) {
88 public boolean getSolid() {
92 public void addSound(Sound sound
) {
96 public void removeSound(Sound sound
) {
100 public ArrayList
<Sound
> getSounds() {
104 public void setPosition(double x
, double y
, double z
) {
110 public double getX() {
114 public double getY() {
118 public double getZ() {
122 public void updateData() {
123 for (Sound sound
: sounds
) {
124 sound
.setPosition(x
,y
,z
);
128 public void updateShape() {
129 shape
.setPosition(x
,y
,z
);
132 public void setX(double x
) {
136 public void setY(double y
) {
140 public void setZ(double z
) {
144 public Shape
getShape() {
148 public void setShape(Shape shape
) {
152 public void process() {
155 public double minX() {
159 public double maxX() {
163 public double minY() {
167 public double maxY() {
171 public double minZ() {
175 public double maxZ() {