MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / playRewardEffect

Method playRewardEffect

Source/RewardUnlockLayer.cpp:179–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179void RewardUnlockLayer::playRewardEffect(GetGJRewards* rewards)
180{
181 std::map<int, int> array;
182 if (rewards->orbs > 0) array[1] = rewards->orbs;
183 if (rewards->diamonds > 0) array[3] = rewards->diamonds;
184 if (rewards->key) array[9] = rewards->key;
185 const auto& winSize = Director::getInstance()->getWinSize();
186
187 _chestObj->switchState(4, false);
188
189 _rewardBtn->runAction(Sequence::createWithTwoActions(DelayTime::create(1.5f), FadeIn::create(1.0)));
190
191 Vec2 position = {winSize.width / 2, winSize.height / 2 + 68.0f};
192 Vec2 position1;
193 Vec2 position2;
194 Vec2 position3;
195 Vec2 position4;
196 Vec2 position5;
197
198 switch (array.size())
199 {
200 case 1:
201 position1 = position;
202 break;
203 case 2:
204 position1 = position;
205 position1.x -= 45;
206 position2 = {position1.x + 90.f, position1.y};
207 break;
208 case 3:
209 position1 = position;
210 position1 = {position.x - 75.f, position.y - 10.f};
211 position2 = {position.x, position.y + 10.f};
212 position3 = {position.x + 75.f, position.y - 10.f};
213 break;
214 }
215
216 int index = 1;
217 for (const auto& entry : array)
218 {
219 int currencyID = entry.first;
220 int currencyCount = entry.second;
221
222 if (currencyCount != 0)
223 {
224 float delay = static_cast<float>(index) * 0.2f + 0.5f;
225 switch (index)
226 {
227 case 1:
228 showEarnedCurrency(currencyID, currencyCount, delay, position1);
229 break;
230 case 2:
231 showEarnedCurrency(currencyID, currencyCount, delay, position2);
232 break;
233 case 3:
234 showEarnedCurrency(currencyID, currencyCount, delay, position3);
235 break;
236 }

Callers

nothing calls this directly

Calls 3

createFunction · 0.85
switchStateMethod · 0.80
sizeMethod · 0.80

Tested by

no test coverage detected