diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/effectmanager.cpp | 85 | ||||
-rw-r--r-- | src/effectmanager.h | 57 | ||||
-rw-r--r-- | src/game.cpp | 3 | ||||
-rw-r--r-- | src/localplayer.cpp | 4 |
6 files changed, 153 insertions, 2 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 03224473..0c4dec38 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -408,6 +408,8 @@ SET(SRCS tileset.h vector.cpp vector.h + effectmanager.cpp + effectmanager.h ) ADD_EXECUTABLE(tmw ${SRCS}) diff --git a/src/Makefile.am b/src/Makefile.am index f4ad7b51..02d73b1a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -359,7 +359,9 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \ textparticle.h \ tileset.h \ vector.cpp \ - vector.h + vector.h \ + effectmanager.cpp \ + effectmanager.h # set the include path found by configure INCLUDES = \ diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp new file mode 100644 index 00000000..4b835355 --- /dev/null +++ b/src/effectmanager.cpp @@ -0,0 +1,85 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "effectmanager.h" + +#include "particle.h" +#include "log.h" +#include "sound.h" + +#include "utils/xml.h" + + +EffectManager::EffectManager() +{ + XML::Document doc("effects.xml"); + xmlNodePtr root = doc.rootNode(); + + if (!root || !xmlStrEqual(root->name, BAD_CAST "being-effects")) + { + logger->log("Error loading being effects file: effects.xml"); + return; + } + else + { + logger->log("Effects are now loading"); + } + + for_each_xml_child_node(node, root) + { + int id; + + if (xmlStrEqual(node->name, BAD_CAST "effect")) + { + EffectDescription ed; + ed.id = XML::getProperty(node, "id", -1); + ed.GFX = XML::getProperty(node, "particle", ""); + ed.SFX = XML::getProperty(node, "audio", ""); + mEffects.push_back(ed); + } + } +} + +EffectManager::~EffectManager() +{ + +} + +bool EffectManager::trigger(int id, int x, int y) +{ + bool rValue = false; + for (std::list<EffectDescription>::iterator i = mEffects.begin(); i != mEffects.end(); ++i) + { + if ((*i).id == id) + { + printf("Found effect, playing it"); + rValue = true; + if((*i).GFX != "") + particleEngine->addEffect((*i).GFX, x, y); + if((*i).SFX != "") + sound.playSfx((*i).SFX); + break; + } + } + return rValue; +} + diff --git a/src/effectmanager.h b/src/effectmanager.h new file mode 100644 index 00000000..b5451f27 --- /dev/null +++ b/src/effectmanager.h @@ -0,0 +1,57 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _EFFECT_MANAGER_H +#define _EFFECT_MANAGER_H + +#include <string> +#include <list> + +class EffectManager +{ + + public: + struct EffectDescription { + int id; + std::string GFX; + std::string SFX; + }; + + + EffectManager(); + + ~EffectManager(); + + /** + * Triggers a effect with the id, at x,y + * returns true if ID exists + */ + bool trigger(int id, int x = 0, int y = 0); + + private: + std::list<EffectDescription> mEffects; + +}; + +extern EffectManager *effectManager; + +#endif // _EFFECT_MANAGER_H diff --git a/src/game.cpp b/src/game.cpp index 901b8dea..b4c9190d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -44,6 +44,7 @@ #include "log.h" #include "npc.h" #include "particle.h" +#include "effectmanager.h" #include "gui/buy.h" #include "gui/buysell.h" @@ -133,6 +134,7 @@ BeingManager *beingManager = NULL; FloorItemManager *floorItemManager = NULL; ChannelManager *channelManager = NULL; CommandHandler *commandHandler = NULL; +EffectManager *effectManager = NULL; Particle *particleEngine = NULL; @@ -286,6 +288,7 @@ Game::Game(): floorItemManager = new FloorItemManager(); channelManager = new ChannelManager(); commandHandler = new CommandHandler(); + effectManager = new EffectManager(); particleEngine = new Particle(NULL); particleEngine->setupEngine(); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 9c1cd743..b6f478a0 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -33,6 +33,7 @@ #include "particle.h" #include "sound.h" #include "log.h" +#include "effectmanager.h" #include "net/gameserver/player.h" #include "net/chatserver/guild.h" @@ -326,7 +327,8 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y) mDestY = y; Net::GameServer::Player::walk(x, y); - particleEngine->addEffect("graphics/particles/hit.particle.xml", x, y); + //Debugging fire burst + effectManager->trigger(15,x,y); } mPickUpTarget = NULL; |