1 // ============================================================== 2 // This file is part of Glest (www.glest.org) 3 // 4 // Copyright (C) 2001-2008 Marti�o Figueroa 5 // 6 // You can redistribute this code and/or modify it under 7 // the terms of the GNU General Public License as published 8 // by the Free Software Foundation; either version 2 of the 9 // License, or (at your option) any later version 10 // ============================================================== 11 12 #ifndef _GLEST_GAME_TIMEFLOW_H_ 13 #define _GLEST_GAME_TIMEFLOW_H_ 14 15 #include "tileset.h" 16 #include "sound.h" 17 18 namespace Glest{ namespace Game{ 19 20 using Shared::Sound::StrSound; 21 using Shared::Sound::StrSound; 22 using Shared::Sound::StaticSound; 23 24 25 // ===================================================== 26 // class TimeFlow 27 // 28 /// Raises time related events (day/night cycle) 29 // ===================================================== 30 31 class TimeFlow{ 32 public: 33 static const float dusk; 34 static const float dawn; 35 36 private: 37 bool firstTime; 38 Tileset *tileset; 39 float time; 40 float lastTime; 41 float timeInc; 42 43 public: 44 void init(Tileset *tileset); 45 getTime()46 float getTime() const {return time;} isDay()47 bool isDay() const {return time>dawn && time<dusk;} isNight()48 bool isNight() const {return !isDay();} isTotalNight()49 bool isTotalNight() const {return time<dawn+1.f || time>dusk-1.f;} 50 51 void update(); 52 private: 53 bool isAproxTime(float time); 54 }; 55 56 }} //end namespace 57 58 #endif 59