summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/koopatlas/shop.cpp29
-rw-r--r--src/koopatlas/shop.h3
2 files changed, 22 insertions, 10 deletions
diff --git a/src/koopatlas/shop.cpp b/src/koopatlas/shop.cpp
index 4852d81..a323bce 100644
--- a/src/koopatlas/shop.cpp
+++ b/src/koopatlas/shop.cpp
@@ -25,6 +25,7 @@ void dWMShop_c::ShopModel_c::setupItem(float x, float y, ItemTypes type) {
scaleFactor = 2.3f;
int id = (int)type;
+ isLakitu = false;
allocator.link(-1, GameHeaps[0], 0, 0x20);
@@ -41,7 +42,7 @@ void dWMShop_c::ShopModel_c::setupItem(float x, float y, ItemTypes type) {
nw4r::g3d::ResAnmChr anmChr = res.GetResAnmChr(Produce[id][3]);
animation.setup(mdlRes, anmChr, &allocator, 0);
- playAnim(Produce[id][3], 1.0f);
+ playAnim(Produce[id][3], 1.0f, 0);
allocator.unlink();
}
@@ -54,6 +55,7 @@ void dWMShop_c::ShopModel_c::setupLakitu(int id) {
scaleFactor = 1.0f;
scaleEase = 0.0f;
+ this->isLakitu = true;
allocator.link(-1, GameHeaps[0], 0, 0x20);
@@ -65,20 +67,29 @@ void dWMShop_c::ShopModel_c::setupLakitu(int id) {
nw4r::g3d::ResAnmChr anmChr = res.GetResAnmChr("idle");
animation.setup(mdlRes, anmChr, &allocator, 0);
- playAnim("idle", 1.0f);
+ playAnim("idle", 1.0f, 0);
allocator.unlink();
}
-void dWMShop_c::ShopModel_c::playAnim(const char *name, float rate) {
+void dWMShop_c::ShopModel_c::playAnim(const char *name, float rate, char loop) {
nw4r::g3d::ResAnmChr anmChr = res.GetResAnmChr(name);
- animation.bind(&model, anmChr, 0);
+ animation.bind(&model, anmChr, loop);
model.bindAnim(&animation, 0.0f);
animation.setUpdateRate(rate);
}
void dWMShop_c::ShopModel_c::execute() {
model._vf1C();
+
+ if(this->animation.isAnimationDone()) {
+ OSReport("Animaiton Complete");
+ if (this->isLakitu) {
+ OSReport("Setting animation to idle");
+ playAnim("idle", 1.0f, 0);
+ this->animation.setCurrentFrame(0.0);
+ }
+ }
}
void dWMShop_c::ShopModel_c::draw() {
@@ -295,10 +306,10 @@ void dWMShop_c::endState_ButtonActivateWait() { OSReport("Wait"); }
// Wait
void dWMShop_c::beginState_Wait() { timer = 0; MapSoundPlayer(SoundRelatedClass, SE_OBJ_CLOUD_BLOCK_TO_JUGEM, 1); }
void dWMShop_c::executeState_Wait() {
- if (timer < 90)
+ if (timer < 90) {
scaleEase = -((cos(timer * 3.14 /20)-0.9)/timer*10)+1;
timer++;
- OSReport("Scale Ease @ %f, timer %d", scaleEase, timer);
+ }
int nowPressed = Remocon_GetPressed(GetActiveRemocon());
@@ -359,10 +370,10 @@ void dWMShop_c::beginState_HideWait() {
MapSoundPlayer(SoundRelatedClass, SE_OBJ_CS_KINOHOUSE_DISAPP, 1);
}
void dWMShop_c::executeState_HideWait() {
- if (timer > 0)
+ if (timer > 0) {
scaleEase = -((cos(timer * 3.14 /13.5)-0.9)/timer*10)+1;
- OSReport("Scale Ease @ %f, timer %d", scaleEase, timer);
timer--;
+ }
if (!layout.isAnimOn(HIDE_ALL))
state.setState(&StateID_Hidden);
@@ -524,7 +535,7 @@ void dWMShop_c::buyItem(int item) {
int cost = itemDefs[item][0], cash = getStarCoinCount();
if (cost > cash) {
- lakituModel->playAnim("notenough", 1.0f);
+ lakituModel->playAnim("notenough", 1.0f, 1);
MapSoundPlayer(SoundRelatedClass, SE_SYS_INVALID, 1);
return;
}
diff --git a/src/koopatlas/shop.h b/src/koopatlas/shop.h
index 2381b29..fb948a9 100644
--- a/src/koopatlas/shop.h
+++ b/src/koopatlas/shop.h
@@ -73,12 +73,13 @@ class dWMShop_c : public dActor_c {
m3d::anmChr_c animation;
float x, y, scaleFactor, scaleEase;
+ bool isLakitu;
void setupItem(float x, float y, ItemTypes type);
void setupLakitu(int id);
void execute();
void draw();
- void playAnim(const char *name, float rate);
+ void playAnim(const char *name, float rate, char loop);
};
ShopModel_c *itemModels;