00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "Map.h"
00019 #include "GameState.h"
00020
00021 namespace Map
00022 {
00023
00024 WorldMap createWorldMap(string &line)
00025 {
00026 WorldMap wm;
00027 istringstream is(line);
00028
00029 Vec2D ul, lr;
00030
00031 is >> ul.x >> ul.y >> lr.x >> lr.y >> wm.gridWidth >> wm.gridHeight;
00032 wm.bounds.setBounds(ul, lr);
00033 wm.width = lr.x - ul.x;
00034 wm.height = lr.y - ul.y;
00035
00036 return wm;
00037 }
00038
00039
00041 Vec3D getColorVec3D(string &color)
00042 {
00043 if( color == TOK_NEUTRAL) return Globals::NO_OWNER;
00044 else if( color == TOK_BLACK) return Colors::black;
00045 else if( color == TOK_BLUE ) return Colors::blue;
00046 else if( color == TOK_CYAN ) return Colors::cyan;
00047 else if( color == TOK_GREEN ) return Colors::green;
00048 else if( color == TOK_MAGENTA ) return Colors::magenta;
00049 else if( color == TOK_RED ) return Colors::red;
00050 else if( color == TOK_WHITE ) return Colors::white;
00051 else if( color == TOK_YELLOW ) return Colors::yellow;
00052 else throw Error("Map parse error Map::getColorVec3D Invalid Color");
00053 }
00054
00055 MilitaryUnit * createUnit(string &line)
00056 {
00057 istringstream is(line);
00058 string type;
00059 float x,y,z;
00060 string color;
00061
00062 is >> type >> x >> y >> z >> color;
00063
00064 if( type == TOK_LIGHT_TANK )
00065 return new LightTank(Vec3D(x,y,z), GameState::findPlayer(getColorVec3D(color)), DEFAULT_LIGHT_TANK_SIZE );
00066 else
00067 throw Error("Map parse error Map::createUnit Invalid Unit Type");
00068 }
00069
00070 City * createCity(string &line)
00071 {
00072 istringstream is(line);
00073 float x,y,z;
00074 string color;
00075 is >> x >> y >> z >> color;
00076
00077 return new City(Vec3D(x,y,z), 0);
00078 }
00079 }