1/*
2 * Copyright 2007-2009 Parker Coates <coates@kde.org>
3 *
4 * This file is part of Killbots.
5 *
6 * Killbots is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Killbots is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Killbots. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef KILLBOTS_COORDINATOR_H
21#define KILLBOTS_COORDINATOR_H
22
23#include "actions.h"
24#include "sprite.h"
25
26class KGamePopupItem;
27
28#include <QtCore/QObject>
29#include <QtCore/QTimeLine>
30
31
32namespace Killbots
33{
34 class Scene;
35 class Engine;
36 class NumericDisplayItem;
37
38 class Coordinator : public QObject
39 {
40 Q_OBJECT
41
42 public: // functions
43 explicit Coordinator( QObject * parent = 0 );
44 virtual ~Coordinator();
45
46 void setEngine( Engine * engine );
47 void setScene( Scene * scene );
48
49 void setAnimationSpeed( int speed );
50
51 void beginNewAnimationStage();
52 Sprite * createSprite( SpriteType type, QPoint position );
53 void slideSprite( Sprite * sprite, QPoint position );
54 void teleportSprite( Sprite * sprite, QPoint position );
55 void destroySprite( Sprite * sprite );
56
57 public slots:
58 void requestNewGame();
59 void requestAction( int action );
60
61 private: // types
62 struct AnimationStage;
63
64 private: // functions
65 void startNewGame();
66 void doAction( HeroAction action );
67 void startAnimation();
68 void startAnimationStage();
69 void animationDone();
70
71 void showUnqueuedMessage( const QString & message, int timeOut = 3000 );
72 void showQueuedMessage( const QString & message );
73
74 private slots:
75 void nextAnimationStage();
76 void animate( qreal value );
77
78 void updateRound( int round );
79 void updateScore( int score );
80 void updateEnemyCount( int enemyCount );
81 void updateEnergy( int energy );
82
83 void showNewGameMessage();
84 void showRoundCompleteMessage();
85 void showBoardFullMessage();
86 void showGameOverMessage();
87
88 private: // data members
89 Engine * m_engine;
90 Scene * m_scene;
91
92 NumericDisplayItem * m_roundDisplay;
93 NumericDisplayItem * m_scoreDisplay;
94 NumericDisplayItem * m_enemyCountDisplay;
95 NumericDisplayItem * m_energyDisplay;
96
97 KGamePopupItem * m_unqueuedPopup;
98 KGamePopupItem * m_queuedPopup;
99
100 QTimeLine m_timeLine;
101
102 QList<AnimationStage> m_stages;
103
104 bool m_busyAnimating;
105 bool m_newGameRequested;
106 HeroAction m_repeatedAction;
107 HeroAction m_queuedAction;
108 };
109}
110
111#endif
112