| 1 | // SuperTux - "Will-O-Wisp" Badguy |
| 2 | // Copyright (C) 2007 Matthias Braun <matze@braunis.de> |
| 3 | // |
| 4 | // This program is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // |
| 9 | // This program is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | |
| 17 | #ifndef HEADER_SUPERTUX_BADGUY_TREEWILLOWISP_HPP |
| 18 | #define |
| 19 | |
| 20 | #include "badguy/badguy.hpp" |
| 21 | |
| 22 | class GhostTree; |
| 23 | class SoundSource; |
| 24 | |
| 25 | class TreeWillOWisp final : public BadGuy |
| 26 | { |
| 27 | public: |
| 28 | TreeWillOWisp(GhostTree* tree, const Vector& pos, float radius, float speed); |
| 29 | virtual ~TreeWillOWisp(); |
| 30 | |
| 31 | virtual void activate() override; |
| 32 | virtual void active_update(float dt_sec) override; |
| 33 | |
| 34 | virtual bool is_flammable() const override { return false; } |
| 35 | virtual bool is_freezable() const override { return false; } |
| 36 | virtual void kill_fall() override { vanish(); } |
| 37 | |
| 38 | virtual void draw(DrawingContext& context) override; |
| 39 | |
| 40 | virtual void stop_looping_sounds() override; |
| 41 | virtual void play_looping_sounds() override; |
| 42 | |
| 43 | /** make TreeWillOWisp vanish */ |
| 44 | void vanish(); |
| 45 | void start_sucking(const Vector& suck_target); |
| 46 | |
| 47 | void set_color(const Color& color); |
| 48 | Color get_color() const; |
| 49 | |
| 50 | protected: |
| 51 | virtual bool collides(GameObject& other, const CollisionHit& hit) const override; |
| 52 | virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override; |
| 53 | |
| 54 | private: |
| 55 | enum MyState { |
| 56 | STATE_DEFAULT, STATE_VANISHING, STATE_SUCKED |
| 57 | }; |
| 58 | |
| 59 | public: |
| 60 | bool was_sucked; |
| 61 | |
| 62 | private: |
| 63 | MyState mystate; |
| 64 | |
| 65 | Color color; |
| 66 | float angle; |
| 67 | float radius; |
| 68 | float speed; |
| 69 | |
| 70 | std::unique_ptr<SoundSource> sound_source; |
| 71 | GhostTree* tree; |
| 72 | |
| 73 | Vector suck_target; |
| 74 | |
| 75 | private: |
| 76 | TreeWillOWisp(const TreeWillOWisp&) = delete; |
| 77 | TreeWillOWisp& operator=(const TreeWillOWisp&) = delete; |
| 78 | }; |
| 79 | |
| 80 | #endif |
| 81 | |
| 82 | /* EOF */ |
| 83 | |