NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_multi_manager.cpp
1#include <game/bases/d_multi_manager.hpp>
3#include <game/bases/d_a_player_manager.hpp>
4#include <game/bases/d_bg_parameter.hpp>
5#include <game/bases/d_game_com.hpp>
6#include <game/bases/d_info.hpp>
7#include <game/bases/d_s_stage.hpp>
8#include <game/bases/d_SmallScore.hpp>
10
12
16
18
20 for (int i = 0; i < PLAYER_COUNT; i++) {
21 mScore[i] = 0;
22 mCoin[i] = 0;
23 mBattleCoin[i] = 0;
24 mEnemyDown[i] = 0;
25 mCollectionCoin[i] = 0;
26 }
27}
28
30 dBgParameter_c *bgParam = dBgParameter_c::ms_Instance_p;
31 mVec2_c pos(
32 bgParam->xStart() + bgParam->xSize() / 2,
33 bgParam->yStart() - bgParam->ySize() / 2
34 );
35 dAudio::SoundEffectID_t(SE_SYS_NICE_S).playMapSound(pos, 0);
36}
37
38void dMultiMng_c::setRest(int rest, int playerNo) {
39 mRest[playerNo] = rest;
40}
41
42void dMultiMng_c::addScore(int value, int plrNo) {
43 daPyMng_c::changeItemKinopioPlrNo(plrNo);
44 mScore[plrNo] += value;
45 if (mScore[plrNo] > MAX_EXTRA_MODE_SCORE) {
47 }
48}
49
50void dMultiMng_c::incCoin(int plrNo) {
51 daPyMng_c::changeItemKinopioPlrNo(plrNo);
52 mCoin[plrNo]++;
53}
54
56 daPyMng_c::changeItemKinopioPlrNo(plrNo);
57 mEnemyDown[plrNo]++;
58}
59
60void dMultiMng_c::setBattleCoin(int plrNo, int value) {
61 if (
62 (dInfo_c::mGameFlag & dInfo_c::GAME_FLAG_4) &&
63 (dInfo_c::mGameFlag & dInfo_c::GAME_FLAG_IS_COIN_COURSE)
64 ) {
65 mBattleCoin[plrNo] += value;
66
68 switch (value) {
69 case 2: popupType = dSmallScore_c::POPUP_TYPE_COIN_2; break;
70 case 3: popupType = dSmallScore_c::POPUP_TYPE_COIN_3; break;
71 case 5: popupType = dSmallScore_c::POPUP_TYPE_COIN_5; break;
72 case 10: popupType = dSmallScore_c::POPUP_TYPE_COIN_10; break;
73 case 15: popupType = dSmallScore_c::POPUP_TYPE_COIN_15; break;
74 case 20: popupType = dSmallScore_c::POPUP_TYPE_COIN_20; break;
75 }
76 if (popupType != dSmallScore_c::POPUP_TYPE_INVALID) {
77 dAcPy_c *player = daPyMng_c::getCtrlPlayer(plrNo);
78 if (player == nullptr) {
79 return;
80 }
81 mVec3_c popupPos = player->mPos;
82 popupPos.y += player->mSmallScoreOffset;
83 dGameCom::CreateSmallScore(popupPos, popupType, plrNo, false);
84 }
85 }
86}
87
89 for (int i = 0; i < PLAYER_COUNT; i++) {
90 mCollectionCoin[i] = 0;
91 }
92
93 /// @unofficial
94 static const int masks[STAR_COIN_COUNT] = { 1, 2, 4 };
95 for (int i = 0; i < STAR_COIN_COUNT; i++) {
96 int coin = dScStage_c::mCollectionCoin[i];
97 if (coin != PLAYER_COUNT) {
98 mCollectionCoin[coin] |= masks[i];
99 }
100 }
101}
mVec3_c mPos
The actor's position.
static unsigned int mGameFlag
See GAME_FLAG_e.
Definition d_info.hpp:89
Multiplayer manager. Keeps track of statistics for each player, used for Coin Battle and Free Mode.
void incEnemyDown(int plrNo)
Increments the enemy kill count for a player.
void initStage()
Initializes all counters to zero.
u8 mCollectionCoin[PLAYER_COUNT]
The star coin collection status for each player. Each byte is a bitfield representing whether each st...
dMultiMng_c()
Creates a new multiplayer manager.
void setBattleCoin(int plrNo, int value)
Rewards a battle coin to a player.
void addScore(int value, int plrNo)
Adds to the score of a player.
void setClapSE()
Plays the clap sound effect.
int mBattleCoin[PLAYER_COUNT]
int mScore[PLAYER_COUNT]
The score of each player.
virtual ~dMultiMng_c()
Destroys the multiplayer manager.
int mCoin[PLAYER_COUNT]
The coin count for each player.
void setRest(int rest, int plrNo)
Sets the remaining lives for a player.
int mRest[PLAYER_COUNT]
The number of remaining lives for each player.
static dMultiMng_c * mspInstance
The instance of this class.
void setCollectionCoin()
Loads the star coin collection information.
void incCoin(int plrNo)
Increments the coin count for a player.
int mEnemyDown[PLAYER_COUNT]
The enemy kill count for each player.
POPUP_TYPE_e
The different types of the small score popups.
@ POPUP_TYPE_COIN_15
[Coin icon]x15. Used in Coin Battle.
@ POPUP_TYPE_COIN_10
[Coin icon]x10. Used in Coin Battle.
@ POPUP_TYPE_COIN_3
[Coin icon]x3. Used in Coin Battle.
@ POPUP_TYPE_COIN_5
[Coin icon]x5. Used in Coin Battle.
@ POPUP_TYPE_COIN_20
[Coin icon]x20. Used in Coin Battle.
@ POPUP_TYPE_INVALID
Invalid popup type.
@ POPUP_TYPE_COIN_2
[Coin icon]x2. Used in Coin Battle.
A two-dimensional floating point vector.
Definition m_vec.hpp:9
A three-dimensional floating point vector.
Definition m_vec.hpp:100
#define MAX_EXTRA_MODE_SCORE
The maximum possible score in Free Mode and Coin Battle.
#define STAR_COIN_COUNT
The amount of Star Coins per level.