Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

KoduConditionTimer.h

Go to the documentation of this file.
00001 #ifndef KODU_CONDITION_TIMER_H_
00002 #define KODU_CONDITION_TIMER_H_
00003 
00004 // C++ Library
00005 #include <iostream>
00006 
00007 // Kodu Library
00008 #include "Kodu/Primitives/KoduCondition.h"
00009 #include "Kodu/General/GeneralMacros.h"
00010 #include "Kodu/Generators/KoduGenerators.h"
00011 
00012 /**
00013  * NAME:            KODU CONDITION TIMER
00014  * TYPE:            CONDITION
00015  * KODU EQUIVALENT: TIMER
00016  * DESCRIPTION:
00017  *      
00018 **/
00019 
00020 namespace Kodu {
00021 
00022     class KoduWorld;
00023 
00024     class KoduConditionTimer : public KoduCondition {
00025     public: 
00026         //! Constructor
00027         KoduConditionTimer(bool useNot, const NumericGenerator& kNumericGen)
00028           : KoduCondition("KoduConditionTimer", KoduCondition::CT_TIMER),
00029             numericGen(kNumericGen),
00030             timerThreshold(0.0f),
00031             notModifierEnabled(useNot),
00032             needToInitialize(true),
00033             currentTime(0),
00034             startTime(0)
00035         { }
00036         
00037         //! Copy constructor
00038         KoduConditionTimer(const KoduConditionTimer& kCondition)
00039           : KoduCondition(kCondition),
00040             numericGen(kCondition.numericGen),
00041             timerThreshold(kCondition.timerThreshold),
00042             notModifierEnabled(kCondition.notModifierEnabled),
00043             needToInitialize(kCondition.needToInitialize),
00044             currentTime(kCondition.currentTime),
00045             startTime(kCondition.startTime)
00046         { }
00047 
00048         //! Destructor
00049         ~KoduConditionTimer() {
00050             // no explicit implementation
00051         }
00052 
00053         //! Assignment operator
00054         KoduConditionTimer& operator=(const KoduConditionTimer& kCondition) {
00055             if (this != &kCondition) {
00056                 KoduCondition::operator=(kCondition);
00057                 numericGen = kCondition.numericGen;
00058                 timerThreshold = kCondition.timerThreshold;
00059                 notModifierEnabled = kCondition.notModifierEnabled;
00060                 needToInitialize = kCondition.needToInitialize;
00061                 currentTime = kCondition.currentTime;
00062                 startTime = kCondition.startTime;
00063             }
00064             return *this;
00065         }
00066         
00067         //! Checks if the timer threshold has been reached or exceeded
00068         virtual bool evaluate(const KoduWorld&);
00069         
00070         //! Tests if the primitive argument is the same as the calling class
00071         static bool isSameTypeAs(const KoduPrimitive*);
00072         
00073         //! Used to reinitialize certain variables each condition and action type
00074         virtual void reinitialize();
00075         
00076         //! Prints the attributes of a particular instance
00077         virtual void printAttrs() const;
00078 
00079         //! Gets the behavior runtime in seconds
00080         float getTimeInSec();
00081 
00082     private:
00083         NumericGenerator numericGen;    //!< returns a constant or random timer value
00084         float timerThreshold;           //!< amount of time needed to past
00085         bool notModifierEnabled;        //!< states if the not modifier is in use
00086         bool needToInitialize;          //!< used to initialize start time
00087         float currentTime;              //!< most recent time request
00088         float startTime;                //!< used for time elapsed calculation
00089     };
00090 }
00091 
00092 #endif // KODU_CONDITION_TIMER_H_

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:43 2016 by Doxygen 1.6.3