00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <config.h>
00018
00019 #include "sprite/sprite.hpp"
00020 #include "sprite/sprite_manager.hpp"
00021 #include "util/reader.hpp"
00022 #include "video/drawing_context.hpp"
00023 #include "worldmap/special_tile.hpp"
00024
00025 namespace worldmap {
00026
00027 SpecialTile::SpecialTile(const Reader& lisp) :
00028 pos(),
00029 sprite(),
00030 map_message(),
00031 passive_message(false),
00032 script(),
00033 invisible(false),
00034 apply_action_north(true),
00035 apply_action_east(true),
00036 apply_action_south(true),
00037 apply_action_west(true)
00038 {
00039 lisp.get("x", pos.x);
00040 lisp.get("y", pos.y);
00041 lisp.get("invisible-tile", invisible);
00042
00043 if(!invisible) {
00044 std::string spritefile = "";
00045 lisp.get("sprite", spritefile);
00046 sprite = sprite_manager->create(spritefile);
00047 }
00048
00049 lisp.get("map-message", map_message);
00050 lisp.get("passive-message", passive_message);
00051 lisp.get("script", script);
00052
00053 std::string apply_direction;
00054 lisp.get("apply-to-direction", apply_direction);
00055 if(!apply_direction.empty()) {
00056 apply_action_north = false;
00057 apply_action_south = false;
00058 apply_action_east = false;
00059 apply_action_west = false;
00060 if(apply_direction.find("north") != std::string::npos)
00061 apply_action_north = true;
00062 if(apply_direction.find("south") != std::string::npos)
00063 apply_action_south = true;
00064 if(apply_direction.find("east") != std::string::npos)
00065 apply_action_east = true;
00066 if(apply_direction.find("west") != std::string::npos)
00067 apply_action_west = true;
00068 }
00069 }
00070
00071 SpecialTile::~SpecialTile()
00072 {
00073 }
00074
00075 void
00076 SpecialTile::draw(DrawingContext& context)
00077 {
00078 if(invisible)
00079 return;
00080
00081 sprite->draw(context, pos*32 + Vector(16, 16), LAYER_OBJECTS - 1);
00082 }
00083
00084 void
00085 SpecialTile::update(float )
00086 {
00087 }
00088
00089 }
00090
00091