| 1 | // SuperTux |
| 2 | // Copyright (C) 2006 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_OBJECT_COIN_HPP |
| 18 | #define |
| 19 | |
| 20 | #include "object/path_object.hpp" |
| 21 | #include "object/moving_sprite.hpp" |
| 22 | #include "supertux/physic.hpp" |
| 23 | |
| 24 | class Path; |
| 25 | class PathWalker; |
| 26 | class TileMap; |
| 27 | |
| 28 | class Coin : public MovingSprite, |
| 29 | public PathObject |
| 30 | { |
| 31 | |
| 32 | friend class HeavyCoin; |
| 33 | |
| 34 | public: |
| 35 | Coin(const Vector& pos); |
| 36 | Coin(const ReaderMapping& reader); |
| 37 | virtual void finish_construction() override; |
| 38 | |
| 39 | virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override; |
| 40 | |
| 41 | virtual void update(float dt_sec) override; |
| 42 | virtual std::string get_class() const override { return "coin" ; } |
| 43 | virtual std::string get_display_name() const override { return _("Coin" ); } |
| 44 | |
| 45 | virtual ObjectSettings get_settings() override; |
| 46 | virtual void after_editor_set() override; |
| 47 | virtual void editor_update() override; |
| 48 | |
| 49 | virtual void move_to(const Vector& pos) override; |
| 50 | |
| 51 | void collect(); |
| 52 | |
| 53 | private: |
| 54 | Vector m_offset; |
| 55 | bool m_from_tilemap; |
| 56 | bool m_add_path; |
| 57 | Physic m_physic; |
| 58 | std::string m_collect_script; |
| 59 | |
| 60 | private: |
| 61 | Coin(const Coin&) = delete; |
| 62 | Coin& operator=(const Coin&) = delete; |
| 63 | }; |
| 64 | |
| 65 | class HeavyCoin final : public Coin |
| 66 | { |
| 67 | public: |
| 68 | HeavyCoin(const Vector& pos, const Vector& init_velocity); |
| 69 | HeavyCoin(const ReaderMapping& reader); |
| 70 | |
| 71 | virtual void update(float dt_sec) override; |
| 72 | virtual void collision_solid(const CollisionHit& hit) override; |
| 73 | |
| 74 | virtual std::string get_class() const override { return "heavycoin" ; } |
| 75 | virtual std::string get_display_name() const override { return _("Heavy Coin" ); } |
| 76 | |
| 77 | virtual ObjectSettings get_settings() override; |
| 78 | virtual void after_editor_set() override; |
| 79 | |
| 80 | private: |
| 81 | Physic m_physic; |
| 82 | |
| 83 | private: |
| 84 | HeavyCoin(const HeavyCoin&) = delete; |
| 85 | HeavyCoin& operator=(const HeavyCoin&) = delete; |
| 86 | }; |
| 87 | |
| 88 | #endif |
| 89 | |
| 90 | /* EOF */ |
| 91 | |