1// SuperTux - Boss "GhostTree"
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_GHOSTTREE_HPP
18#define HEADER_SUPERTUX_BADGUY_GHOSTTREE_HPP
19
20#include "badguy/badguy.hpp"
21
22class TreeWillOWisp;
23class Lantern;
24
25class GhostTree final : public BadGuy
26{
27public:
28 GhostTree(const ReaderMapping& mapping);
29
30 virtual bool is_flammable() const override { return false; }
31 virtual bool is_freezable() const override { return false; }
32 virtual void kill_fall() override { }
33
34 virtual void activate() override;
35 virtual void active_update(float dt_sec) override;
36 virtual void draw(DrawingContext& context) override;
37
38 virtual bool collides(GameObject& other, const CollisionHit& hit) const override;
39 virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
40
41 virtual std::string get_class() const override { return "ghosttree"; }
42 virtual std::string get_display_name() const override { return _("Ghost Tree"); }
43
44 void willowisp_died(TreeWillOWisp* willowisp);
45 void die();
46
47private:
48 enum MyState {
49 STATE_IDLE, STATE_SUCKING, STATE_SWALLOWING, STATE_DYING
50 };
51
52private:
53 bool is_color_deadly(Color color) const;
54 void spawn_lantern();
55
56private:
57 MyState mystate;
58 Timer willowisp_timer;
59 float willo_spawn_y;
60 float willo_radius;
61 float willo_speed;
62 int willo_color;
63
64 SpritePtr glow_sprite;
65 Timer colorchange_timer;
66 Timer suck_timer;
67 Timer root_timer;
68 int treecolor;
69 Color suck_lantern_color;
70
71 Lantern* suck_lantern; /**< Lantern that is currently being sucked in */
72
73 std::vector<TreeWillOWisp*> willowisps;
74
75private:
76 GhostTree(const GhostTree&) = delete;
77 GhostTree& operator=(const GhostTree&) = delete;
78};
79
80#endif
81
82/* EOF */
83