From 186b82c06eeaaf25b63327268bb888cd0cabcb10 Mon Sep 17 00:00:00 2001 From: Samat Agishev Date: Wed, 7 Feb 2018 19:39:29 +0500 Subject: [PATCH] animation works --- jni/match3/match3field.cpp | 31 +++++++++++++++++++++---------- jni/match3/match3field.h | 2 ++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/jni/match3/match3field.cpp b/jni/match3/match3field.cpp index 9ece082..ac6eddf 100644 --- a/jni/match3/match3field.cpp +++ b/jni/match3/match3field.cpp @@ -164,7 +164,7 @@ void TMatch3Logic::FillRandomChipMatrix(std::vector chipList) void TMatch3Logic::ReplaceAnimation(Eigen::Vector2i p) { - TChip& chip = ChipMatrix[p[0]][p[1]]; if (SE::ResourceManager->HalibutAnimationManager.AnimationExists(chip.AnimName)) @@ -360,13 +359,11 @@ void TMatch3Logic::ReplaceAnimation(Eigen::Vector2i p) } else { - SE::THalibutExternalAnimObject testAnimObject(Match3FieldParams.ChipTemplateParamsArr[chip.ChipType].SelectedTemplateAnimObject); testAnimObject.ReplaceAnimObject(chip.RenderPair, chip.VertexListShift / 6); SE::ResourceManager->HalibutAnimationManager.AddAnimationObject(chip.AnimName, testAnimObject); - } SE::ResourceManager->HalibutAnimationManager.StopAnimation(chip.AnimName); @@ -385,7 +382,7 @@ void TMatch3Logic::MoveVertexListShiftBack(SE::TRenderPairList::iterator renderP { ChipMatrix[i][j].VertexListShift -= 6; - ReplaceAnimation(Eigen::Vector2i(i, j)); + //ReplaceAnimation(Eigen::Vector2i(i, j)); } } } @@ -450,7 +447,7 @@ void TMatch3Logic::AddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spaw InnerAddChipToUp(colNum, chipType, spawnPos, chipState); - ReplaceAnimation(Eigen::Vector2i(colNum, yPos)); + //ReplaceAnimation(Eigen::Vector2i(colNum, yPos)); } @@ -479,7 +476,7 @@ void TMatch3Logic::InsertEmptyChip(size_t colNum, size_t rowNum, int chipType) ChipMatrix[colNum].insert(ChipMatrix[colNum].begin() + rowNum, TChip(chipType, RenderPairIteratorVector[renderPairIndex], vertexListShift, chipState)); - ReplaceAnimation(Eigen::Vector2i(colNum, rowNum)); + //ReplaceAnimation(Eigen::Vector2i(colNum, rowNum)); //triangleList.NeedRefreshBuffer = true; @@ -774,12 +771,26 @@ void TMatch3Logic::ChangeChipType(Eigen::Vector2i p) //Hack to make sure animation is replaced by new one SE::ResourceManager->HalibutAnimationManager.DeleteAnimationObject(chip.AnimName); - ReplaceAnimation(Eigen::Vector2i(p[0], p[1])); + //ReplaceAnimation(Eigen::Vector2i(p[0], p[1])); } +void TMatch3Logic::innerUpdateAnimation(size_t dt) { + for (int i = 0; i < ChipMatrix[0].size(); ++i) { + for (int j = 0; j < ChipMatrix[i].size(); ++j) { + if (Eigen::Vector2i(i, j) != selectedChip) { + ReplaceAnimation(Eigen::Vector2i(i, j)); + } + } + } + + SE::ResourceManager->HalibutAnimationManager.Update(dt); + +} + + void TMatch3Logic::SelectChip(Eigen::Vector2i pos) { if (!(selectedChip == Eigen::Vector2i(-1, -1))) @@ -1199,9 +1210,9 @@ void TMatch3Field::Update(size_t dt) i->second.RefreshBuffer(); } + innerUpdateAnimation(dt); - SE::ResourceManager->HalibutAnimationManager.Update(dt); - + } void TMatch3Field::OnTapDown(Eigen::Vector2f pos) diff --git a/jni/match3/match3field.h b/jni/match3/match3field.h index 9b70ec8..9517e78 100644 --- a/jni/match3/match3field.h +++ b/jni/match3/match3field.h @@ -214,6 +214,8 @@ protected: void ChangeChipType(Eigen::Vector2i p); + void innerUpdateAnimation(size_t dt); + public: TMatch3Logic();