diff options
Diffstat (limited to 'src/koopatlas')
-rw-r--r-- | src/koopatlas/shop.cpp | 106 | ||||
-rw-r--r-- | src/koopatlas/shop.h | 6 |
2 files changed, 93 insertions, 19 deletions
diff --git a/src/koopatlas/shop.cpp b/src/koopatlas/shop.cpp index 27f6077..c8bbdca 100644 --- a/src/koopatlas/shop.cpp +++ b/src/koopatlas/shop.cpp @@ -3,6 +3,7 @@ CREATE_STATE(dWMShop_c, Hidden); CREATE_STATE(dWMShop_c, ShowWait); CREATE_STATE(dWMShop_c, ButtonActivateWait); +CREATE_STATE(dWMShop_c, CoinCountdown); CREATE_STATE(dWMShop_c, Wait); CREATE_STATE(dWMShop_c, HideWait); @@ -149,21 +150,24 @@ int dWMShop_c::onCreate() { "shop_Show.brlan", "shop_Hide.brlan", "shop_ActivateButton.brlan", - "shop_DeactivateButton.brlan" + "shop_DeactivateButton.brlan", + "shop_CountCoin.brlan" }; static const char *groupNames[] = { "BaseGroup", "BaseGroup", "GBtn00", "GBtn01", "GBtn02", "GBtn03", "GBtn1", "GBtn2", "GBtn00", "GBtn01", "GBtn02", "GBtn03", "GBtn1", "GBtn2", + "GCoinCount" }; static const int brlanIDs[] = { 0, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, + 4, }; - layout.loadAnimations(brlanNames, 4); - layout.loadGroups(groupNames, brlanIDs, 14); + layout.loadAnimations(brlanNames, 5); + layout.loadGroups(groupNames, brlanIDs, 15); layout.disableAllAnimations(); layout.drawOrder = 1; @@ -301,7 +305,10 @@ void dWMShop_c::executeState_ShowWait() { state.setState(&StateID_ButtonActivateWait); } } -void dWMShop_c::endState_ShowWait() { } +void dWMShop_c::endState_ShowWait() { + MapSoundPlayer(SoundRelatedClass, SE_OBJ_CLOUD_BLOCK_TO_JUGEM, 1); + timer = 1; +} // ButtonActivateWait void dWMShop_c::beginState_ButtonActivateWait() { } @@ -309,12 +316,12 @@ void dWMShop_c::executeState_ButtonActivateWait() { if (!layout.isAnyAnimOn()) state.setState(&StateID_Wait); } -void dWMShop_c::endState_ButtonActivateWait() { - UpdateSelectCursor(Buttons[0], 0, false); -} +void dWMShop_c::endState_ButtonActivateWait() { } // Wait -void dWMShop_c::beginState_Wait() { timer = 1; MapSoundPlayer(SoundRelatedClass, SE_OBJ_CLOUD_BLOCK_TO_JUGEM, 1); } +void dWMShop_c::beginState_Wait() { + showSelectCursor(); +} void dWMShop_c::executeState_Wait() { if (timer < 90) { scaleEase = -((cos(timer * 3.14 /20)-0.9)/timer*10)+1; @@ -365,15 +372,12 @@ void dWMShop_c::executeState_Wait() { layout.enableNonLoopAnim(DEACTIVATE_BUTTON+selected); layout.enableNonLoopAnim(ACTIVATE_BUTTON+newSelection); - switch (newSelection) { - case 4: UpdateSelectCursor(Btn1Base, 0, false); break; - case 5: UpdateSelectCursor(Btn2Base, 0, false); break; - default: UpdateSelectCursor(Buttons[newSelection], 0, false); - } selected = newSelection; if (newSelection <= 3) lastTopRowChoice = newSelection; + + showSelectCursor(); } } void dWMShop_c::endState_Wait() { } @@ -585,7 +589,7 @@ void dWMShop_c::buyItem(int item) { SaveFile *file = GetSaveFile(); SaveBlock *block = file->GetBlock(file->header.current_file); - block->spentStarCoins += cost; + coinsRemaining = cost; // Work out what we need to apply int appliedItems[ITEM_TYPE_COUNT]; @@ -596,7 +600,6 @@ void dWMShop_c::buyItem(int item) { for (int i = 0; i < invCount; i++) appliedItems[(int)Inventory[shopKind][invStartIndex+i]]++; - // TODO: Make this work with hammers for (int i = 0; i < 8; i++) { block->powerups_available[i] += appliedItems[i]; @@ -616,9 +619,74 @@ void dWMShop_c::buyItem(int item) { if (appliedItems[(int)ONE_UP] > 0) MapSoundPlayer(SoundRelatedClass, SE_SYS_100COIN_ONE_UP, 1); - // load the coin count - int scCount = getUnspentStarCoinCount(); - WriteNumberToTextBox(&scCount, CoinCount, false); - WriteNumberToTextBox(&scCount, CoinCountShadow, false); + state.setState(&StateID_CoinCountdown); + HideSelectCursor(SelectCursorPointer, 0); +} + + +void dWMShop_c::beginState_CoinCountdown() { + timerForCoinCountdown = 8; +} + +void dWMShop_c::endState_CoinCountdown() { } + +void dWMShop_c::executeState_CoinCountdown() { + timerForCoinCountdown--; + if (timerForCoinCountdown <= 0) { + + SaveBlock *save = GetSaveFile()->GetBlock(-1); + save->spentStarCoins++; + + // load the coin count + int scCount = getUnspentStarCoinCount(); + WriteNumberToTextBox(&scCount, CoinCount, false); + WriteNumberToTextBox(&scCount, CoinCountShadow, false); + + layout.enableNonLoopAnim(COUNT_COIN); + VEC3 efPos = { + CoinCount->effectiveMtx[0][3], + CoinCount->effectiveMtx[1][3], + 0.0f}; + + // ARGHHHHHHHHHHHHHHHHh. + if (IsWideScreen()) { + float div = 5.0f; + if (scCount < 100) + div = 3.6f; + if (scCount < 10) + div = 2.7f; + efPos.x -= (CoinCount->size.x / div); + efPos.y -= (CoinCount->size.y / 2.0f); + } else { + float div = 5.8f; + if (scCount < 100) + div = 8.2f; + if (scCount < 10) + div = 14.5f; + efPos.x += (CoinCount->size.x / div); + efPos.y -= (CoinCount->size.y / 2.8f); + } + + VEC3 efScale = {0.7f, 0.7f, 0.7f}; + SpawnEffect("Wm_2d_moviecoinvanish", 0, &efPos, 0, &efScale); + + coinsRemaining--; + if (coinsRemaining <= 0) { + MapSoundPlayer(SoundRelatedClass, SE_PLY_GET_ITEM_AGAIN, 1); + state.setState(&StateID_Wait); + } else { + MapSoundPlayer(SoundRelatedClass, SE_SYS_STAR_COIN_PAY, 1); + beginState_CoinCountdown(); + } + } +} + + +void dWMShop_c::showSelectCursor() { + switch (selected) { + case 4: UpdateSelectCursor(Btn1Base, 0, false); break; + case 5: UpdateSelectCursor(Btn2Base, 0, false); break; + default: UpdateSelectCursor(Buttons[selected], 0, false); + } } diff --git a/src/koopatlas/shop.h b/src/koopatlas/shop.h index d7dcc67..03750fb 100644 --- a/src/koopatlas/shop.h +++ b/src/koopatlas/shop.h @@ -27,11 +27,14 @@ class dWMShop_c : public dActor_c { int selected, lastTopRowChoice; int shopKind; + int coinsRemaining, timerForCoinCountdown; + enum Animation { SHOW_ALL = 0, HIDE_ALL = 1, ACTIVATE_BUTTON = 2, // 3, 4, 5, 6, 7 DEACTIVATE_BUTTON = 8, // 9, 10, 11, 12, 13 + COUNT_COIN = 14, }; enum ItemTypes { @@ -95,12 +98,15 @@ class dWMShop_c : public dActor_c { void buyItem(int item); + void showSelectCursor(); + dStateWrapper_c<dWMShop_c> state; USING_STATES(dWMShop_c); DECLARE_STATE(Hidden); DECLARE_STATE(ShowWait); DECLARE_STATE(ButtonActivateWait); + DECLARE_STATE(CoinCountdown); DECLARE_STATE(Wait); DECLARE_STATE(HideWait); }; |