| 1 | #include "Layout/RaceCountDownLayout.h" |
| 2 | |
| 3 | #include "Library/Base/StringUtil.h" |
| 4 | #include "Library/Layout/LayoutActionFunction.h" |
| 5 | #include "Library/Layout/LayoutInitInfo.h" |
| 6 | #include "Library/Nerve/NerveSetupUtil.h" |
| 7 | #include "Library/Nerve/NerveUtil.h" |
| 8 | #include "Library/Se/SeFunction.h" |
| 9 | |
| 10 | namespace { |
| 11 | NERVE_IMPL(RaceCountDownLayout, Wait); |
| 12 | NERVE_IMPL(RaceCountDownLayout, CountDown); |
| 13 | NERVE_IMPL(RaceCountDownLayout, CountDownEnd); |
| 14 | NERVE_IMPL(RaceCountDownLayout, Finish); |
| 15 | NERVE_IMPL(RaceCountDownLayout, FinishEnd); |
| 16 | |
| 17 | NERVES_MAKE_NOSTRUCT(RaceCountDownLayout, Wait, CountDown, CountDownEnd, Finish, FinishEnd); |
| 18 | } // namespace |
| 19 | |
| 20 | RaceCountDownLayout::RaceCountDownLayout(const al::LayoutInitInfo& info) |
| 21 | : al::LayoutActor("[レース]カウントダウン" ) { |
| 22 | mCountLayout = new al::LayoutActor("[レース]カウントダウン数字" ); |
| 23 | al::initLayoutActor(this, info, "MiniGameCue" , nullptr); |
| 24 | al::initLayoutActor(mCountLayout, info, "MiniGameCount" , nullptr); |
| 25 | initNerve(&Wait, 0); |
| 26 | } |
| 27 | |
| 28 | void RaceCountDownLayout::startCountDown(s32 count) { |
| 29 | mCount = count; |
| 30 | al::startAction(layout: this, actionName: "Hide" , paneName: nullptr); |
| 31 | al::setNerve(user: this, nerve: &CountDown); |
| 32 | appear(); |
| 33 | } |
| 34 | |
| 35 | void RaceCountDownLayout::startFinish() { |
| 36 | al::setNerve(user: this, nerve: &Finish); |
| 37 | appear(); |
| 38 | } |
| 39 | |
| 40 | bool RaceCountDownLayout::isEndCountDown() const { |
| 41 | return al::isNerve(user: this, nerve: &CountDownEnd); |
| 42 | } |
| 43 | |
| 44 | bool RaceCountDownLayout::isEndFinish() const { |
| 45 | return al::isNerve(user: this, nerve: &FinishEnd); |
| 46 | } |
| 47 | |
| 48 | void RaceCountDownLayout::reset() { |
| 49 | al::setNerve(user: this, nerve: &Wait); |
| 50 | } |
| 51 | |
| 52 | void RaceCountDownLayout::exeWait() {} |
| 53 | |
| 54 | inline void toggleNumberLayouts(al::LayoutActor* countLayout, s32 count) { |
| 55 | for (s32 i = 0; i < 11; i++) { |
| 56 | al::startAction(layout: countLayout, actionName: (count == i) ? "On" : "Off" , |
| 57 | paneName: al::StringTmp<32>("Number%02d" , i).cstr()); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | void RaceCountDownLayout::exeCountDown() { |
| 62 | if (al::isFirstStep(user: this)) { |
| 63 | al::startSe(this, "Count1" ); |
| 64 | |
| 65 | toggleNumberLayouts(countLayout: mCountLayout, count: mCount); |
| 66 | |
| 67 | al::startAction(layout: mCountLayout, actionName: "Count" , paneName: nullptr); |
| 68 | mCountLayout->appear(); |
| 69 | } |
| 70 | |
| 71 | if (al::isFirstStep(user: this) || al::getNerveStep(user: this) % 60 != 0) |
| 72 | return; |
| 73 | |
| 74 | mCount--; |
| 75 | |
| 76 | al::startAction(layout: mCountLayout, actionName: "Count" , paneName: nullptr); |
| 77 | toggleNumberLayouts(countLayout: mCountLayout, count: mCount); |
| 78 | |
| 79 | if (mCount != 0) { |
| 80 | al::startSe(this, "Count1" ); |
| 81 | } else { |
| 82 | al::startSe(this, "Count2" ); |
| 83 | mCountLayout->kill(); |
| 84 | al::startAction(layout: this, actionName: "Go" , paneName: nullptr); |
| 85 | al::setNerve(user: this, nerve: &CountDownEnd); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | void RaceCountDownLayout::exeCountDownEnd() { |
| 90 | if (al::isActionEnd(layout: this, paneName: nullptr)) |
| 91 | kill(); |
| 92 | } |
| 93 | |
| 94 | void RaceCountDownLayout::exeFinish() { |
| 95 | if (al::isFirstStep(user: this)) |
| 96 | al::startAction(layout: this, actionName: "Finish" , paneName: nullptr); |
| 97 | if (al::isActionEnd(layout: this, paneName: nullptr) && al::isGreaterEqualStep(user: this, step: 120)) { |
| 98 | al::setNerve(user: this, nerve: &FinishEnd); |
| 99 | kill(); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | void RaceCountDownLayout::exeFinishEnd() {} |
| 104 | |