com.eoi.freya.basic
Class BasicMap

java.lang.Object
  |
  +--com.eoi.freya.basic.BasicMap
All Implemented Interfaces:
Map

public class BasicMap
extends java.lang.Object
implements Map

The BasicMap is a huge 2D array of BasicLocations


Field Summary
protected static BasicMap mapInstance
           
 
Constructor Summary
protected BasicMap()
           
 
Method Summary
 org.jdom.Element convertToElement()
          Converts entire map to an element, filling missing xy's with a blank element.
 void createFromElement(org.jdom.Element mapElement)
          Given a root element createFromElement fills the map array with the XML data
static BasicMap getInstance()
           
 Location getLocation(BasicPosition pos)
          get the Location object of a give BasicPosition
 Location getLocation(int x, int y)
          get the Location object of a give x y spot
 org.jdom.Element getMapPortion(int x, int y, int width, int height)
          Creates a root element that contains a portion of map as XML
 int getMaxX()
           
 int getMaxY()
           
 boolean hasUnit(java.lang.String name, BasicPosition pos)
          return true is Location has a give unit at a given x y spot
 boolean hasUnit(java.lang.String name, int x, int y)
          return true is Location has a give unit at a given BasicPosition
 void read(java.lang.String filename)
          read the map from disk
 void setMap(BasicLocation[][] newMap)
           
 void write(java.lang.String filename)
          write the map to disk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapInstance

protected static BasicMap mapInstance
Constructor Detail

BasicMap

protected BasicMap()
Method Detail

getInstance

public static BasicMap getInstance()

createFromElement

public void createFromElement(org.jdom.Element mapElement)
Given a root element createFromElement fills the map array with the XML data

convertToElement

public org.jdom.Element convertToElement()
Converts entire map to an element, filling missing xy's with a blank element.

getMapPortion

public org.jdom.Element getMapPortion(int x,
                                      int y,
                                      int width,
                                      int height)
Creates a root element that contains a portion of map as XML

getLocation

public Location getLocation(int x,
                            int y)
get the Location object of a give x y spot
Specified by:
getLocation in interface Map

getLocation

public Location getLocation(BasicPosition pos)
get the Location object of a give BasicPosition

hasUnit

public boolean hasUnit(java.lang.String name,
                       BasicPosition pos)
return true is Location has a give unit at a given x y spot

hasUnit

public boolean hasUnit(java.lang.String name,
                       int x,
                       int y)
return true is Location has a give unit at a given BasicPosition

write

public void write(java.lang.String filename)
write the map to disk
Specified by:
write in interface Map

read

public void read(java.lang.String filename)
read the map from disk
Specified by:
read in interface Map

setMap

public void setMap(BasicLocation[][] newMap)

getMaxX

public int getMaxX()

getMaxY

public int getMaxY()


Freya Engine, The Turn Based Game Engine
Copyright(c) 2002 Alexander Bilton
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA