From 03543264f99392834e63ff1c23bc0b7ebaa4ce51 Mon Sep 17 00:00:00 2001 From: Colin Noga Date: Sun, 18 Nov 2012 23:16:04 -0600 Subject: more shop fixes --- src/koopatlas/shop.cpp | 29 ++++++++++++++++++++--------- src/koopatlas/shop.h | 3 ++- 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'src/koopatlas') 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; -- cgit v1.2.3