Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 244 | chris | 1 | ////////////////////////////////////////////////////////////////////////// |
| 2 | // LevelupEffect.h |
||
| 3 | // |
||
| 4 | // Does the level up effect, from the bouncing "LEVEL UP!" text to |
||
| 5 | // the stats display and weird transition effects. |
||
| 6 | ////////////////////////////////////////////////////////////////////////// |
||
| 7 | |||
| 8 | |||
| 9 | #ifndef __LEVELUP_EFFECT_H__ |
||
| 10 | #define __LEVELUP_EFFECT_H__ |
||
| 11 | |||
| 12 | #include "SexyAppFramework/Common.h" |
||
| 13 | #include "SexyAppFramework/Rect.h" |
||
| 14 | |||
| 15 | namespace Sexy |
||
| 16 | { |
||
| 17 | |||
| 18 | class Graphics; |
||
| 19 | |||
| 20 | |||
| 21 | ////////////////////////////////////////////////////////////////////////// |
||
| 22 | // Represents a letter that bounces, used for the "LEVEL UP!" text. |
||
| 23 | ////////////////////////////////////////////////////////////////////////// |
||
| 24 | struct BouncyChar |
||
| 25 | { |
||
| 26 | SexyString mChar; // The character bouncing |
||
| 27 | bool mDone; // Completed bouncing yet? |
||
| 28 | float mX, mY; |
||
| 29 | float mBounceSpeed; // How fast up or down it's bouncing, affected by "gravity" |
||
| 30 | float mOldBounceSpeed; // The base value that mBounceSpeed started at. Gets reduced over time. |
||
| 31 | |||
| 32 | BouncyChar(SexyString t, float x, float y, float s) |
||
| 33 | {mChar = t; mX = x; mY = y; mBounceSpeed = mOldBounceSpeed = s; mDone = false;} |
||
| 34 | }; |
||
| 35 | |||
| 36 | ////////////////////////////////////////////////////////////////////////// |
||
| 37 | // Contains stat info to display after completing a level. |
||
| 38 | ////////////////////////////////////////////////////////////////////////// |
||
| 39 | struct LevelupStats |
||
| 40 | { |
||
| 41 | int mPopulationEaten; |
||
| 42 | int mPercentComplete; |
||
| 43 | int mLevelCompleted; |
||
| 44 | |||
| 45 | // Always 3 strings per planet: |
||
| 46 | // Planet name, exports, population (comma delimited) |
||
| 47 | std::vector<SexyString> mPlanetsEaten; |
||
| 48 | |||
| 49 | }; |
||
| 50 | |||
| 51 | class LevelupEffect |
||
| 52 | { |
||
| 53 | |||
| 54 | private: |
||
| 55 | |||
| 56 | // States that the level up effect goes through |
||
| 57 | enum |
||
| 58 | { |
||
| 59 | LEVELUP_TEXT, // Displaying the bouncy LEVEL UP! text |
||
| 60 | CURTAIN_IN, // Moving the black "curtain" inward to cover up the level |
||
| 61 | CURTAIN_OUT, // Moving the red "curtain" out after above to reveal the stats |
||
| 62 | SHOWING_STATS, // Displaying level stats |
||
| 63 | COVERING_STATS, // Doing the weird transitionary cover-up screen after clicking to continue |
||
| 64 | FADE_OUT_STATS // Fading out the above screen |
||
| 65 | }; |
||
| 66 | |||
| 67 | std::vector<BouncyChar> mText; // The letters that spell LEVEL UP!, as BouncyChar structures |
||
| 68 | LevelupStats mStats; // Stat info to display |
||
| 69 | bool mActive; // If true, means we're doing the level up sequence |
||
| 70 | bool mDone; // If done, means all finished and the next level can actually begin |
||
| 71 | bool mStartNextLevel; // When true, indicates that the board should set up the next level so that it'll be there when we fade out |
||
| 72 | |||
| 73 | int mHue; // For hue/saturation/luminence crazy weird flashing effect |
||
| 74 | int mCurtainX; // X location of the black/red curtain edge (for the left curtain, the right is the same size) |
||
| 75 | int mState; // One of the above nums |
||
| 76 | |||
| 77 | // When doing the COVERING_STATS phase, this is how wide 1/2 of the filled in part of the screen is. The other half |
||
| 78 | // is the same size. |
||
| 79 | int mCoverWidth; |
||
| 80 | int mStripHeight; // For the above, we make strips quickly appear, alternating up/down filling |
||
| 81 | |||
| 82 | // Indicates whether the strips are increasing Y (so strip comes from top) or decreasing |
||
| 83 | // (so strip comes from bottom) |
||
| 84 | int mStripSizeChange; |
||
| 85 | int mFadeOutAlpha; // Alpha amount for the final fade out effect |
||
| 86 | |||
| 87 | ////////////////////////////////////////////////////////////////////////// |
||
| 88 | // Function: Init |
||
| 89 | // |
||
| 90 | // Purpose: Sets up and initializes/resets all variables. |
||
| 91 | ////////////////////////////////////////////////////////////////////////// |
||
| 92 | void Init(); |
||
| 93 | |||
| 94 | public: |
||
| 95 | |||
| 96 | LevelupEffect(); |
||
| 97 | |||
| 98 | ////////////////////////////////////////////////////////////////////////// |
||
| 99 | // Function: Update |
||
| 100 | // Parameters: |
||
| 101 | // theFrac - Value from Board::UpdateF, used for smooth motion |
||
| 102 | // |
||
| 103 | ////////////////////////////////////////////////////////////////////////// |
||
| 104 | void Update(float theFrac); |
||
| 105 | |||
| 106 | ////////////////////////////////////////////////////////////////////////// |
||
| 107 | // Draw |
||
| 108 | ////////////////////////////////////////////////////////////////////////// |
||
| 109 | void Draw(Graphics* g); |
||
| 110 | |||
| 111 | ////////////////////////////////////////////////////////////////////////// |
||
| 112 | // Function: Activate |
||
| 113 | // Parameters: |
||
| 114 | // ls - A stat structure containing the info for the past level |
||
| 115 | // |
||
| 116 | // Purpose: Begins the level up sequence |
||
| 117 | ////////////////////////////////////////////////////////////////////////// |
||
| 118 | void Activate(LevelupStats ls); |
||
| 119 | |||
| 120 | ////////////////////////////////////////////////////////////////////////// |
||
| 121 | // Function: DoneViewingStats |
||
| 122 | // |
||
| 123 | // Purpose: Called by Board when the user clicks the mouse button, |
||
| 124 | // indicating that they want the stats screen to go away and have the |
||
| 125 | // next level begin. |
||
| 126 | ////////////////////////////////////////////////////////////////////////// |
||
| 127 | void DoneViewingStats(); |
||
| 128 | |||
| 129 | ////////////////////////////////////////////////////////////////////////// |
||
| 130 | // Function: StartNextLevel |
||
| 131 | // Returns: true or false, indicating if the next level can be started. |
||
| 132 | // |
||
| 133 | // Purpose: Called by the Board's Update method, this returns true |
||
| 134 | // when the board should initialize the next level, so that when the |
||
| 135 | // level up effect fades out, the next level will appear underneath it. |
||
| 136 | // When the function returns true, it automatically sets internal variables |
||
| 137 | // so that the next time the function is called, it will return false, |
||
| 138 | // preventing the Board from accidentally initializing the same level |
||
| 139 | // multiple times. After the next call to Activate, it is allowed to |
||
| 140 | // return true again. |
||
| 141 | // |
||
| 142 | // Once the screen is totally filled after closing the stats display, |
||
| 143 | // the Board is allowed to init the next level. |
||
| 144 | ////////////////////////////////////////////////////////////////////////// |
||
| 145 | bool StartNextLevel(); |
||
| 146 | |||
| 147 | ////////////////////////////////////////////////////////////////////////// |
||
| 148 | // Function: IsDone |
||
| 149 | // Returns: true or false indicating if the entire sequence is done |
||
| 150 | // |
||
| 151 | // Purpose: Used to let the board know when playing of the next level |
||
| 152 | // can begin. |
||
| 153 | ////////////////////////////////////////////////////////////////////////// |
||
| 154 | bool IsDone() {return mDone;} |
||
| 155 | |||
| 156 | ////////////////////////////////////////////////////////////////////////// |
||
| 157 | // Function: IsActive |
||
| 158 | // Returns: true or false indicating if the sequence is running or not |
||
| 159 | ////////////////////////////////////////////////////////////////////////// |
||
| 160 | bool IsActive() {return mActive;} |
||
| 161 | |||
| 162 | ////////////////////////////////////////////////////////////////////////// |
||
| 163 | // Function: ShowingStats |
||
| 164 | // Returns: true or false indicating if the stats display is visible |
||
| 165 | ////////////////////////////////////////////////////////////////////////// |
||
| 166 | bool ShowingStats() {return mState == SHOWING_STATS;} |
||
| 167 | |||
| 168 | ////////////////////////////////////////////////////////////////////////// |
||
| 169 | // Function: HideBoard |
||
| 170 | // Returns: true or false indicating whether or not the board should |
||
| 171 | // hide all of its display stuff, except for the starfield which always |
||
| 172 | // displays. |
||
| 173 | ////////////////////////////////////////////////////////////////////////// |
||
| 174 | bool HideBoard() {return (mState == SHOWING_STATS) || (mState == CURTAIN_OUT) || (mState == COVERING_STATS);} |
||
| 175 | |||
| 176 | ////////////////////////////////////////////////////////////////////////// |
||
| 177 | // Function: HidePlanets |
||
| 178 | // Returns: true or false indicating if just the planets should be |
||
| 179 | // hidden. |
||
| 180 | // |
||
| 181 | // Purpose: Used to hide the planets but still allow the rest of the |
||
| 182 | // game board to display. Used during the transtion to the stats |
||
| 183 | // display screen. |
||
| 184 | ////////////////////////////////////////////////////////////////////////// |
||
| 185 | bool HidePlanets() {return IsActive() && (HideBoard() || (mState == LEVELUP_TEXT) || (mState == CURTAIN_IN));} |
||
| 186 | }; |
||
| 187 | |||
| 188 | |||
| 189 | } |
||
| 190 | |||
| 191 | #endif //__LEVELUP_EFFECT_H__ |