Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Map.cpp

Go to the documentation of this file.
00001 /*
00002 CS Senior Project 2003
00003 Team : Leftfield
00004 Project : ModernWarfare
00005 Members :
00006 - Russ Christensen              <rchriste@cs.utah.edu>
00007 - Todd Smith                    <tcsmith@cs.utah.edu>
00008 - Usit Duongsaa                 <duongsaa@cs.utah.edu>
00009 Copyright 2003 Russ Christensen, Usit Duongsaa, and Todd Smith. All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
00012 
00013 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
00014 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
00015 THIS SOFTWARE IS PROVIDED BY RUSS CHRISTENSEN, USIT DUONGSAA, AND TODD SMITH ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RUSS, USIT, TODD OR OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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     // cities will be assigned a color upon game creation
00077     return new City(Vec3D(x,y,z), 0);
00078   }
00079 } // end namepace Map

Generated on Wed Apr 23 05:50:15 2003 for Modern Warfare by doxygen1.3-rc2