2018-02-01 14:39:31 +00:00
|
|
|
#include "match3field.h"
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
#include "../main_code.h"
|
2013-01-19 22:25:53 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
#define ZLEVEL 0
|
2018-02-01 14:39:31 +00:00
|
|
|
|
2013-01-19 22:25:53 +00:00
|
|
|
void TChipTemplateParams::Serialize(boost::property_tree::ptree& propertyTree)
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string selectedShaderName = propertyTree.get<std::string>("SelectedShaderName");
|
|
|
|
std::string selectedTexName = propertyTree.get<std::string>("SelectedTexName");
|
|
|
|
std::string selectedNormTexName = propertyTree.get<std::string>("SelectedNormTexName");
|
|
|
|
std::string finishingTexName = propertyTree.get<std::string>("FinishingTexName");
|
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
SelectedRenderParams.ShaderName = selectedShaderName;
|
|
|
|
SelectedRenderParams.SamplerMap[SE::CONST_STRING_TEXTURE_UNIFORM] = selectedTexName;
|
|
|
|
SelectedRenderParams.SamplerMap[SE::CONST_STRING_NORMALMAP_UNIFORM] = selectedNormTexName;
|
|
|
|
SelectedRenderParams.transparencyFlag = SE::TRenderParams::opaque;
|
2018-02-01 14:39:31 +00:00
|
|
|
//SelectedRenderParams.Transparency = 1.f;
|
2018-02-02 15:00:17 +00:00
|
|
|
|
|
|
|
FinishingRenderParams.ShaderName = "";
|
|
|
|
FinishingRenderParams.SamplerMap[SE::CONST_STRING_TEXTURE_UNIFORM] = finishingTexName;
|
|
|
|
FinishingRenderParams.SamplerMap[SE::CONST_STRING_NORMALMAP_UNIFORM] = "";
|
|
|
|
SelectedRenderParams.transparencyFlag = SE::TRenderParams::opaque;
|
2018-02-01 14:39:31 +00:00
|
|
|
//FinishingRenderParams.Transparency = 1.f;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
std::string selectedAnimFileName = propertyTree.get<std::string>("SelectedAnimFileName");
|
|
|
|
std::string finishingAnimFileName = propertyTree.get<std::string>("FinishingAnimFileName");
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
auto px = SE::FileToPropertyTree(selectedAnimFileName);
|
2013-01-19 22:25:53 +00:00
|
|
|
SelectedTemplateAnimObject.Serialize(*px);
|
2018-02-01 14:39:31 +00:00
|
|
|
px = SE::FileToPropertyTree(finishingAnimFileName);
|
2013-01-19 22:25:53 +00:00
|
|
|
FinishingTemplateAnimObject.Serialize(*px);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
|
2013-01-19 22:25:53 +00:00
|
|
|
void TMatch3FieldParams::Serialize(boost::property_tree::ptree& propertyTree)
|
|
|
|
{
|
|
|
|
|
|
|
|
TChipTemplateParams chipTemplateParams;
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
FieldWidth = propertyTree.get<size_t>("Match3Params.FieldWidth");
|
|
|
|
FieldHeight = propertyTree.get<size_t>("Match3Params.FieldHeight");
|
2013-01-19 22:25:53 +00:00
|
|
|
CellWidth = propertyTree.get<float>("Match3Params.CellWidth");
|
|
|
|
CellHeight = propertyTree.get<float>("Match3Params.CellHeight");
|
|
|
|
ChipLowestSpeed = propertyTree.get<float>("Match3Params.ChipLowestSpeed");
|
|
|
|
ChipAcceleration = propertyTree.get<float>("Match3Params.ChipAcceleration");
|
|
|
|
ChipPositionEpsilon = propertyTree.get<float>("Match3Params.ChipPositionEpsilon");
|
|
|
|
ChipVelocityEpsilon = propertyTree.get<float>("Match3Params.ChipVelocityEpsilon");
|
|
|
|
ChipK = propertyTree.get<float>("Match3Params.ChipK");
|
2018-02-01 14:39:31 +00:00
|
|
|
ChipMatchTime = propertyTree.get<size_t>("Match3Params.ChipMatchTime");
|
|
|
|
ChipTypeCount = propertyTree.get<size_t>("Match3Params.ChipTypeCount");
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-05 14:53:52 +00:00
|
|
|
for (boost::property_tree::ptree::value_type &v : propertyTree.get_child("Match3Params.ChipList"))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
boost::property_tree::ptree& p = v.second.get_child("");
|
|
|
|
chipTemplateParams.Serialize(p);
|
|
|
|
ChipTemplateParamsArr.push_back(chipTemplateParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int TChip::StaticAnimationIndex = 0;
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
TChip::TChip(int chipType, SE::TRenderPairList::iterator renderPair, size_t vertexListShift, TChipState chipState)
|
2013-01-19 22:25:53 +00:00
|
|
|
: ChipType(chipType)
|
|
|
|
, RenderPair(renderPair)
|
|
|
|
, VertexListShift(vertexListShift)
|
|
|
|
, ChipState(chipState)
|
|
|
|
, Velocity(0)
|
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
AnimName = "test_anim"+SE::tostr(StaticAnimationIndex++);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
|
|
|
|
|
2013-01-19 22:25:53 +00:00
|
|
|
TChip::~TChip()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2f TChip::GetLeftBottomPos()
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-02 08:07:21 +00:00
|
|
|
std::vector<Eigen::Vector3f>::iterator i = RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].begin() + VertexListShift;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
return Eigen::Vector2f((*i)[0], (*i)[1]);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TChip::SetLeftBottomPos(Eigen::Vector2f newPos)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2f shift = newPos - GetLeftBottomPos();
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
MoveLeftBottomPos(shift);
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
void TChip::MoveLeftBottomPos(Eigen::Vector2f shift)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
for (int i=0; i<6; i++)
|
|
|
|
{
|
2018-02-02 08:07:21 +00:00
|
|
|
*(RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].begin() + VertexListShift + i) += Eigen::Vector3f(shift[0], shift[1], 0);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TMatch3Logic::TMatch3Logic()
|
|
|
|
//: TemplateAnimObject(TRenderPairList::iterator(), 0, 1)
|
|
|
|
{
|
|
|
|
//TemplateAnimObject.Serialize(FileToPropertyTree("chip1_xml.xml"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TMatch3Logic::~TMatch3Logic()
|
|
|
|
{
|
|
|
|
|
|
|
|
//Match3FieldParams.ChipTemplateParamsArr.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::FillRandomChipMatrix(std::vector<SE::TRenderPairList::iterator> renderPairIteratorVector, Eigen::Vector2f leftBottomPos)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
RenderPairIteratorVector = renderPairIteratorVector;
|
|
|
|
|
|
|
|
LeftBottomPosField = leftBottomPos;
|
|
|
|
|
|
|
|
ChipTypeCount = Match3FieldParams.ChipTypeCount;
|
|
|
|
|
|
|
|
ChipMatrix.resize(Match3FieldParams.FieldWidth);
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t i = 0; i < Match3FieldParams.FieldWidth; ++i)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t j=0; j < Match3FieldParams.FieldHeight; ++j)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
int chipType = rand() % ChipTypeCount;
|
|
|
|
|
|
|
|
if (i == 0 && j == 6)
|
|
|
|
{
|
|
|
|
//AddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_LOCKED);
|
2018-02-02 15:00:17 +00:00
|
|
|
InnerAddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_STANDBY);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-02 15:00:17 +00:00
|
|
|
InnerAddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_STANDBY);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
|
|
|
|
std::vector<Eigen::Vector2i> chipList;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
do {
|
2013-01-19 22:25:53 +00:00
|
|
|
chipList = GetAvailableMatchingChips();
|
2018-02-02 15:00:17 +00:00
|
|
|
UnmatchChips(chipList);
|
|
|
|
} while (!chipList.empty());
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < ChipMatrix.size(); i++) {
|
|
|
|
for (size_t j = 0; j < ChipMatrix[i].size(); j++) {
|
|
|
|
ReplaceAnimation(Eigen::Vector2i(i, j));
|
|
|
|
}
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
|
|
|
|
Eigen::Vector2f TMatch3Logic::GetExpectedLeftBottomPos(size_t x, size_t y)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
return LeftBottomPosField + Eigen::Vector2f(x*Match3FieldParams.CellWidth, y*Match3FieldParams.CellHeight);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::StartAnimateChip(size_t x, size_t y)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-05 14:53:52 +00:00
|
|
|
//return;
|
2018-02-01 14:39:31 +00:00
|
|
|
SE::ResourceManager->HalibutAnimationManager.StartAnimation(ChipMatrix[x][y].AnimName);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::StopAnimateChip(size_t x, size_t y)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-05 14:53:52 +00:00
|
|
|
//return;
|
2018-02-01 14:39:31 +00:00
|
|
|
SE::ResourceManager->HalibutAnimationManager.StopAnimation(ChipMatrix[x][y].AnimName);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
bool TMatch3Logic::ChipIsLocked(Eigen::Vector2i chip)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
return ChipMatrix[chip[0]][chip[1]].ChipState == TChip::CS_LOCKED;
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
bool TMatch3Logic::ChipIsFinishing(Eigen::Vector2i chip)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
return ChipMatrix[chip[0]][chip[1]].ChipState == TChip::CS_FINISHING;
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
bool TMatch3Logic::ChipIsStable(Eigen::Vector2i chip)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
return ChipMatrix[chip[0]][chip[1]].ChipState == TChip::CS_STANDBY ||
|
|
|
|
ChipMatrix[chip[0]][chip[1]].ChipState == TChip::CS_LOCKED;
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
|
|
|
|
bool TMatch3Logic::ChipCanBeSelected(Eigen::Vector2i chip)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (ChipMatrix[chip[0]][chip[1]].ChipState != TChip::CS_STANDBY)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (chip[1] == 0)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
int i = chip[1] - 1;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
while (i >= 0 && ChipIsStable(Eigen::Vector2i(chip[0], i)) && !ChipIsLocked(Eigen::Vector2i(chip[0], i)))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (i < 0 || ChipIsLocked(Eigen::Vector2i(chip[0], i)))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2018-02-01 14:39:31 +00:00
|
|
|
|
|
|
|
bool TMatch3Logic::ChipsCanBeSwapped(Eigen::Vector2i p1, Eigen::Vector2i p2)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
float distance_x = static_cast<float>(p1[0] - p2[0]);
|
|
|
|
float distance_y = static_cast<float>(p1[1] - p2[1]);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
if ((((fabs(distance_x) == 1) && (fabs(distance_y) == 0))
|
|
|
|
|| ((fabs(distance_x) == 0) && (fabs(distance_y) == 1))) &&
|
|
|
|
ChipCanBeSelected(p1) &&
|
|
|
|
ChipCanBeSelected(p2))
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
bool TMatch3Logic::ChipCanBeMatchedUp(Eigen::Vector2i chip)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (chip[1] <= Match3FieldParams.FieldHeight - 3)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if ((ChipMatrix[chip[0]][chip[1]].ChipType == ChipMatrix[chip[0]][chip[1] + 1].ChipType)
|
|
|
|
&& (ChipMatrix[chip[0]][chip[1]].ChipType == ChipMatrix[chip[0]][chip[1] + 2].ChipType))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (ChipMatrix[chip[0]][chip[1]].ChipState == TChip::CS_STANDBY &&
|
|
|
|
ChipMatrix[chip[0]][chip[1] + 1].ChipState == TChip::CS_STANDBY &&
|
|
|
|
ChipMatrix[chip[0]][chip[1] + 2].ChipState == TChip::CS_STANDBY)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
bool TMatch3Logic::ChipCanBeMatchedDown(Eigen::Vector2i chip)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (chip[1] >= 2)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if ((ChipMatrix[chip[0]][chip[1]].ChipType == ChipMatrix[chip[0]][chip[1] - 1].ChipType)
|
|
|
|
&& (ChipMatrix[chip[0]][chip[1]].ChipType == ChipMatrix[chip[0]][chip[1] - 2].ChipType))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (ChipMatrix[chip[0]][chip[1]].ChipState == TChip::CS_STANDBY &&
|
|
|
|
ChipMatrix[chip[0]][chip[1] - 1].ChipState == TChip::CS_STANDBY &&
|
|
|
|
ChipMatrix[chip[0]][chip[1] - 2].ChipState == TChip::CS_STANDBY)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
bool TMatch3Logic::ChipCanBeMatchedLeft(Eigen::Vector2i chip)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (chip[0] >= 2)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if ((ChipMatrix[chip[0]][chip[1]].ChipType == ChipMatrix[chip[0] - 1][chip[1]].ChipType)
|
|
|
|
&& (ChipMatrix[chip[0]][chip[1]].ChipType == ChipMatrix[chip[0] - 2][chip[1]].ChipType))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (ChipMatrix[chip[0]][chip[1]].ChipState == TChip::CS_STANDBY &&
|
|
|
|
ChipMatrix[chip[0] - 1][chip[1]].ChipState == TChip::CS_STANDBY &&
|
|
|
|
ChipMatrix[chip[0] - 2][chip[1]].ChipState == TChip::CS_STANDBY)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
bool TMatch3Logic::ChipCanBeMatchedRight(Eigen::Vector2i chip)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (chip[0] <= Match3FieldParams.FieldWidth - 3)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if ((ChipMatrix[chip[0]][chip[1]].ChipType == ChipMatrix[chip[0] + 1][chip[1]].ChipType)
|
|
|
|
&& (ChipMatrix[chip[0]][chip[1]].ChipType == ChipMatrix[chip[0] + 2][chip[1]].ChipType))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (ChipMatrix[chip[0]][chip[1]].ChipState == TChip::CS_STANDBY &&
|
|
|
|
ChipMatrix[chip[0] + 1][chip[1]].ChipState == TChip::CS_STANDBY &&
|
|
|
|
ChipMatrix[chip[0] + 2][chip[1]].ChipState == TChip::CS_STANDBY)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::UnmatchChips(std::vector<Eigen::Vector2i> chipList)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<Eigen::Vector2i>::iterator i;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
for (i = chipList.begin(); i != chipList.end(); ++i)
|
|
|
|
{
|
|
|
|
|
|
|
|
ChangeChipType(*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::ReplaceAnimation(Eigen::Vector2i p)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
TChip& chip = ChipMatrix[p[0]][p[1]];
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
if (SE::ResourceManager->HalibutAnimationManager.AnimationExists(chip.AnimName))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-02 08:07:21 +00:00
|
|
|
SE::ResourceManager->HalibutAnimationManager.ReplaceAnimationObject(chip.AnimName, chip.RenderPair, chip.VertexListShift / 6);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
SE::THalibutExternalAnimObject testAnimObject(Match3FieldParams.ChipTemplateParamsArr[chip.ChipType].SelectedTemplateAnimObject);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
testAnimObject.ReplaceAnimObject(chip.RenderPair, chip.VertexListShift / 6);
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
SE::ResourceManager->HalibutAnimationManager.AddAnimationObject(chip.AnimName, testAnimObject);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
SE::ResourceManager->HalibutAnimationManager.StopAnimation(chip.AnimName);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
void TMatch3Logic::MoveVertexListShiftBack(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t i = 0; i < ChipMatrix.size(); i++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t j = 0; j < ChipMatrix[i].size(); j++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
if (ChipMatrix[i][j].RenderPair == renderPairItr)
|
|
|
|
{
|
|
|
|
if (ChipMatrix[i][j].VertexListShift > moveFrom)
|
|
|
|
{
|
|
|
|
ChipMatrix[i][j].VertexListShift -= 6;
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
ReplaceAnimation(Eigen::Vector2i(i, j));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
void TMatch3Logic::MoveVertexListShiftBackWithoutAnimation(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < ChipMatrix.size(); i++)
|
|
|
|
{
|
|
|
|
for (size_t j = 0; j < ChipMatrix[i].size(); j++)
|
|
|
|
{
|
|
|
|
if (ChipMatrix[i][j].RenderPair == renderPairItr)
|
|
|
|
{
|
|
|
|
if (ChipMatrix[i][j].VertexListShift > moveFrom)
|
|
|
|
{
|
|
|
|
ChipMatrix[i][j].VertexListShift -= 6;
|
|
|
|
|
|
|
|
//ReplaceAnimation(Eigen::Vector2i(i, j));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMatch3Logic::InnerAddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2f posFrom = spawnPos;
|
|
|
|
Eigen::Vector2f posTo = posFrom + Eigen::Vector2f(Match3FieldParams.CellWidth, Match3FieldParams.CellHeight);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
size_t renderPairIndex;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
if (chipState == TChip::CS_LOCKED)
|
|
|
|
{
|
|
|
|
renderPairIndex = chipType + Match3FieldParams.ChipTypeCount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
renderPairIndex = chipType;
|
|
|
|
}
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
SE::TTriangleList& triangleList = RenderPairIteratorVector[renderPairIndex]->second;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
std::vector<Eigen::Vector3f> vertexCoordArr = SE::MakeVertexCoordVec(posFrom, posTo, ZLEVEL);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
std::vector<Eigen::Vector2f> texCoordArr = SE::MakeTexCoordVec();
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
triangleList.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].insert(triangleList.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].end(), vertexCoordArr.begin(), vertexCoordArr.end());
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
triangleList.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].insert(triangleList.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].end(), texCoordArr.begin(), texCoordArr.end());
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
size_t vertexListShift = RenderPairIteratorVector[renderPairIndex]->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].size()-6;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
ChipMatrix[colNum].push_back(TChip(chipType, RenderPairIteratorVector[renderPairIndex], vertexListShift, chipState));
|
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
//triangleList.NeedRefreshBuffer = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMatch3Logic::AddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState)
|
|
|
|
{
|
2018-02-05 14:53:52 +00:00
|
|
|
size_t yPos = ChipMatrix[colNum].size();
|
2018-02-02 15:00:17 +00:00
|
|
|
|
2018-02-05 14:53:52 +00:00
|
|
|
InnerAddChipToUp(colNum, chipType, spawnPos, chipState);
|
2018-02-02 15:00:17 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
ReplaceAnimation(Eigen::Vector2i(colNum, yPos));
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::InsertEmptyChip(size_t colNum, size_t rowNum, int chipType)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2f posFrom = GetExpectedLeftBottomPos(colNum, rowNum);
|
|
|
|
Eigen::Vector2f posTo = posFrom + Eigen::Vector2f(Match3FieldParams.CellWidth, Match3FieldParams.CellHeight);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
size_t renderPairIndex = Match3FieldParams.ChipTypeCount * 2 + chipType;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
TChip::TChipState chipState = TChip::CS_X;
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
SE::TTriangleList& triangleList = RenderPairIteratorVector[renderPairIndex]->second;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
std::vector<Eigen::Vector3f> vertexCoordArr = SE::MakeVertexCoordVec(posFrom, posTo, ZLEVEL);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
std::vector<Eigen::Vector2f> texCoordArr = SE::MakeTexCoordVec();
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
triangleList.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].insert(triangleList.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].end(), vertexCoordArr.begin(), vertexCoordArr.end());
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
triangleList.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].insert(triangleList.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].end(), texCoordArr.begin(), texCoordArr.end());
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
size_t vertexListShift = RenderPairIteratorVector[renderPairIndex]->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].size()-6;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
ChipMatrix[colNum].insert(ChipMatrix[colNum].begin() + rowNum, TChip(chipType, RenderPairIteratorVector[renderPairIndex], vertexListShift, chipState));
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
ReplaceAnimation(Eigen::Vector2i(colNum, rowNum));
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
|
2018-02-05 14:53:52 +00:00
|
|
|
//triangleList.NeedRefreshBuffer = true;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2f pos = GetExpectedLeftBottomPos(colNum, rowNum);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
ChipDeletingVector.push_back(TChipDeletingData(Eigen::Vector2i(colNum, rowNum), pos));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::UpdateChipSwapping(size_t dt)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<TChipSwappingPair>::iterator i = ChipSwappingPairVector.begin();
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<std::pair<Eigen::Vector2i, Eigen::Vector2i> > chipsToSwapAgain;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
while (i != ChipSwappingPairVector.end())
|
|
|
|
{
|
|
|
|
|
|
|
|
i->T += dt / static_cast<float>(Match3FieldParams.ChipMatchTime);
|
|
|
|
|
|
|
|
if (i->T >= 1.f)
|
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i chip1pos = i->Chip1;
|
|
|
|
Eigen::Vector2i chip2pos = i->Chip2;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
bool isReturning = i->IsReturning;
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
TChip& chip1 = ChipMatrix[chip1pos[0]][chip1pos[1]];
|
|
|
|
TChip& chip2 = ChipMatrix[chip2pos[0]][chip2pos[1]];
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
TChip c = chip1;
|
|
|
|
chip1 = chip2;
|
|
|
|
chip2 = c;
|
|
|
|
|
|
|
|
|
|
|
|
ResetChipPos(chip1pos);
|
|
|
|
ResetChipPos(chip2pos);
|
|
|
|
|
|
|
|
chip1.ChipState = TChip::CS_STANDBY;
|
|
|
|
chip2.ChipState = TChip::CS_STANDBY;
|
|
|
|
|
|
|
|
|
|
|
|
i = ChipSwappingPairVector.erase(i);
|
|
|
|
|
|
|
|
|
|
|
|
//Check if chips do
|
|
|
|
if (!isReturning)
|
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<Eigen::Vector2i> matchingChipList = GetAvailableMatchingChips();
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
if (matchingChipList.size() == 0)
|
|
|
|
{
|
|
|
|
//SwapChips(chip1pos, chip2pos);
|
2018-02-01 14:39:31 +00:00
|
|
|
chipsToSwapAgain.push_back(std::pair<Eigen::Vector2i, Eigen::Vector2i>(chip1pos, chip2pos));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
TChip& chip1 = ChipMatrix[i->Chip1[0]][i->Chip1[1]];
|
|
|
|
TChip& chip2 = ChipMatrix[i->Chip2[0]][i->Chip2[1]];
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
auto x = i->Chip1RealPosFrom + (i->Chip2RealPosFrom - i->Chip1RealPosFrom) * i->T;
|
|
|
|
auto y = i->Chip2RealPosFrom + (i->Chip1RealPosFrom - i->Chip2RealPosFrom) * i->T;
|
|
|
|
|
|
|
|
Eigen::Vector3f newPosChip1 = Eigen::Vector3f(x[0], x[1], 0);
|
|
|
|
Eigen::Vector3f newPosChip2 = Eigen::Vector3f(y[0], y[1], 0);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
Eigen::Vector3f shiftChip1 = newPosChip1 - chip1.RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB][chip1.VertexListShift];
|
|
|
|
Eigen::Vector3f shiftChip2 = newPosChip2 - chip2.RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB][chip2.VertexListShift];
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
for (int k = 0; k < 6; k++)
|
|
|
|
{
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
chip1.RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB][chip1.VertexListShift + k] += shiftChip1;
|
|
|
|
chip2.RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB][chip2.VertexListShift + k] += shiftChip2;
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-05 14:53:52 +00:00
|
|
|
//chip1.RenderPair->second.NeedRefreshBuffer = true;
|
|
|
|
//chip2.RenderPair->second.NeedRefreshBuffer = true;
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (i != ChipSwappingPairVector.end())
|
|
|
|
{
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<std::pair<Eigen::Vector2i, Eigen::Vector2i> >::iterator pairVecItr;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
for (pairVecItr = chipsToSwapAgain.begin(); pairVecItr != chipsToSwapAgain.end(); ++pairVecItr)
|
|
|
|
{
|
|
|
|
SwapChips(pairVecItr->first, pairVecItr->second, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::UpdateChipPosition(size_t dt)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t i=0; i<ChipMatrix.size(); i++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t j=1; j<ChipMatrix[i].size(); j++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
TChip& chip = ChipMatrix[i][j];
|
|
|
|
|
|
|
|
TChip& chipBelow = ChipMatrix[i][j-1];
|
|
|
|
if (chipBelow.ChipState == TChip::CS_FINISHING)
|
|
|
|
{
|
|
|
|
if (chip.ChipState != TChip::CS_LOCKED && chip.ChipState != TChip::CS_FINISHING && chip.ChipState != TChip::CS_X)
|
|
|
|
{
|
|
|
|
TChip c = chip;
|
|
|
|
chip = chipBelow;
|
|
|
|
chipBelow = c;
|
|
|
|
chipBelow.ChipState = TChip::CS_FALLING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t i=0; i<ChipMatrix.size(); i++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t j=0; j<ChipMatrix[i].size(); j++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
TChip& chip = ChipMatrix[i][j];
|
|
|
|
if (chip.ChipState == TChip::CS_FALLING)
|
|
|
|
{
|
|
|
|
|
|
|
|
chip.Velocity += Match3FieldParams.ChipAcceleration * dt;
|
|
|
|
|
|
|
|
if (chip.Velocity < Match3FieldParams.ChipLowestSpeed)
|
|
|
|
{
|
|
|
|
chip.Velocity = Match3FieldParams.ChipLowestSpeed;
|
|
|
|
}
|
|
|
|
|
|
|
|
float yShift = chip.Velocity * dt;
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
chip.MoveLeftBottomPos(Eigen::Vector2f(0, yShift));
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2f expectedPos = GetExpectedLeftBottomPos(i, j);
|
|
|
|
Eigen::Vector2f realPos = chip.GetLeftBottomPos();
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (realPos[1] < expectedPos[1] && chip.Velocity <= 0 && !(j > 0 && ChipIsFinishing(Eigen::Vector2i(i, j-1))))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
chip.Velocity = -chip.Velocity * Match3FieldParams.ChipK;
|
|
|
|
chip.SetLeftBottomPos(GetExpectedLeftBottomPos(i, j));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fabs(chip.Velocity) <= Match3FieldParams.ChipVelocityEpsilon)
|
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (fabs(expectedPos[0] - realPos[0]) <= Match3FieldParams.ChipPositionEpsilon &&
|
|
|
|
fabs(expectedPos[1] - realPos[1]) <= Match3FieldParams.ChipPositionEpsilon
|
2013-01-19 22:25:53 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
chip.ChipState = TChip::CS_STANDBY;
|
|
|
|
chip.SetLeftBottomPos(GetExpectedLeftBottomPos(i, j));
|
|
|
|
chip.Velocity = 0.f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-05 14:53:52 +00:00
|
|
|
//chip.RenderPair->second.NeedRefreshBuffer = true;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t k = j + 1; k < ChipMatrix[i].size(); k++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
TChip& chipAbove = ChipMatrix[i][k];
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2f posAbove = chipAbove.GetLeftBottomPos();
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (chipAbove.GetLeftBottomPos()[1] - chip.GetLeftBottomPos()[1] < Match3FieldParams.CellHeight)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (!ChipIsLocked(Eigen::Vector2i(i, k)) && !ChipIsFinishing(Eigen::Vector2i(i, k)))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
chipAbove.ChipState = TChip::CS_FALLING;
|
2018-02-01 14:39:31 +00:00
|
|
|
chipAbove.SetLeftBottomPos(chip.GetLeftBottomPos() + Eigen::Vector2f(0, Match3FieldParams.CellHeight));
|
2013-01-19 22:25:53 +00:00
|
|
|
chipAbove.Velocity = chip.Velocity;
|
2018-02-05 14:53:52 +00:00
|
|
|
//chipAbove.RenderPair->second.NeedRefreshBuffer = true;
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TMatch3Logic::RemoveBubbles()
|
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
size_t max_y = ChipMatrix.size()-1;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t i=0; i < ChipMatrix[max_y].size(); i++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
if (ChipMatrix[i][max_y].ChipState == TChip::CS_FINISHING)
|
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
DestroyChip(Eigen::Vector2i(i, max_y));
|
|
|
|
AddChipToUp(i, rand() % ChipTypeCount, GetExpectedLeftBottomPos(i, ChipMatrix[i].size())+Eigen::Vector2f(0, Match3FieldParams.CellHeight));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMatch3Logic::TryMatchAllChips()
|
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<Eigen::Vector2i> matchingChips = GetAvailableMatchingChips();
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<Eigen::Vector2i>::iterator i;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
for (i = matchingChips.begin(); i != matchingChips.end(); ++i)
|
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i p = *i;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
int chipType = ChipMatrix[p[0]][p[1]].ChipType;
|
2013-01-19 22:25:53 +00:00
|
|
|
DestroyChip(p);
|
2018-02-01 14:39:31 +00:00
|
|
|
InsertEmptyChip(p[0], p[1], chipType);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::DestroyChip(Eigen::Vector2i p)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-05 14:53:52 +00:00
|
|
|
//ChipMatrix[p[0]][p[1]].RenderPair->second.NeedRefreshBuffer = true;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
SE::ResourceManager->HalibutAnimationManager.DeleteAnimationObject(ChipMatrix[p[0]][p[1]].AnimName);
|
2018-02-05 14:53:52 +00:00
|
|
|
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].erase(
|
|
|
|
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift,
|
|
|
|
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift + 6);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].erase(
|
|
|
|
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift,
|
|
|
|
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift + 6);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
MoveVertexListShiftBackWithoutAnimation(ChipMatrix[p[0]][p[1]].RenderPair, ChipMatrix[p[0]][p[1]].VertexListShift);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
ChipMatrix[p[0]].erase(ChipMatrix[p[0]].begin() + p[1]);
|
2013-01-19 22:25:53 +00:00
|
|
|
/*
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t i=p[1]; i < ChipMatrix[p[0]].size(); i++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (!ChipIsLocked(Eigen::Vector2i(p[0], i)) && !ChipIsFinishing(Eigen::Vector2i(p[0], i)))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
ChipMatrix[p[0]][i].ChipState = TChip::CS_FALLING;
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::ChangeChipType(Eigen::Vector2i p)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
size_t newChipType = rand() % ChipTypeCount;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
TChip& chip = ChipMatrix[p[0]][p[1]];
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
std::vector<Eigen::Vector3f>::iterator vertexCoordItrBegin = chip.RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].begin() + chip.VertexListShift;
|
|
|
|
std::vector<Eigen::Vector3f>::iterator vertexCoordItrEnd = vertexCoordItrBegin + 6;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
std::vector<Eigen::Vector2f>::iterator texCoordItrBegin = chip.RenderPair->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].begin() + chip.VertexListShift;
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<Eigen::Vector2f>::iterator texCoordItrEnd = texCoordItrBegin + 6;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
std::vector<Eigen::Vector3f> vertexCoordSubVec(vertexCoordItrBegin, vertexCoordItrEnd);
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<Eigen::Vector2f> texCoordSubVec(texCoordItrBegin, texCoordItrEnd);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
chip.RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].erase(vertexCoordItrBegin, vertexCoordItrEnd);
|
|
|
|
chip.RenderPair->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].erase(texCoordItrBegin, texCoordItrEnd);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
MoveVertexListShiftBack(chip.RenderPair, chip.VertexListShift);
|
|
|
|
|
2018-02-05 14:53:52 +00:00
|
|
|
//chip.RenderPair->second.NeedRefreshBuffer = true;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
chip.ChipType = newChipType;
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
RenderPairIteratorVector[newChipType]->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].insert(RenderPairIteratorVector[newChipType]->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].end(), vertexCoordSubVec.begin(), vertexCoordSubVec.end());
|
|
|
|
RenderPairIteratorVector[newChipType]->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].insert(RenderPairIteratorVector[newChipType]->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].end(), texCoordSubVec.begin(), texCoordSubVec.end());
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-05 14:53:52 +00:00
|
|
|
//RenderPairIteratorVector[newChipType]->second.NeedRefreshBuffer = true;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
chip.RenderPair = RenderPairIteratorVector[newChipType];
|
2018-02-02 08:07:21 +00:00
|
|
|
chip.VertexListShift = RenderPairIteratorVector[newChipType]->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].size() - 6;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
//Hack to make sure animation is replaced by new one
|
2018-02-02 08:07:21 +00:00
|
|
|
SE::ResourceManager->HalibutAnimationManager.DeleteAnimationObject(chip.AnimName);
|
2018-02-01 14:39:31 +00:00
|
|
|
ReplaceAnimation(Eigen::Vector2i(p[0], p[1]));
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::SelectChip(Eigen::Vector2i pos)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (!(selectedChip == Eigen::Vector2i(-1, -1)))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
StopAnimateChip(selectedChip[0], selectedChip[1]);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
StartAnimateChip(pos[0], pos[1]);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
selectedChip = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TMatch3Logic::UnselectChip()
|
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (!(selectedChip == Eigen::Vector2i(-1, -1)))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
StopAnimateChip(selectedChip[0], selectedChip[1]);
|
|
|
|
selectedChip = Eigen::Vector2i(-1, -1);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i TMatch3Logic::GetSelectedChip()
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
return selectedChip;
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<Eigen::Vector2i> TMatch3Logic::GetAvailableMatchingChips()
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<Eigen::Vector2i> result;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t x=0; x<Match3FieldParams.FieldWidth; x++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t y=0; y<Match3FieldParams.FieldHeight; y++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i chip = Eigen::Vector2i(x, y);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ChipCanBeMatchedUp(chip))
|
|
|
|
{
|
|
|
|
if (std::find(result.begin(), result.end(), chip) == result.end())
|
|
|
|
{
|
|
|
|
result.push_back(chip);
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (std::find(result.begin(), result.end(), chip + Eigen::Vector2i(0, 1)) == result.end())
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
result.push_back(chip + Eigen::Vector2i(0, 1));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (std::find(result.begin(), result.end(), chip + Eigen::Vector2i(0, 2)) == result.end())
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
result.push_back(chip + Eigen::Vector2i(0, 2));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ChipCanBeMatchedDown(chip))
|
|
|
|
{
|
|
|
|
if (std::find(result.begin(), result.end(), chip) == result.end())
|
|
|
|
{
|
|
|
|
result.push_back(chip);
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (std::find(result.begin(), result.end(), chip - Eigen::Vector2i(0, 1)) == result.end())
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
result.push_back(chip - Eigen::Vector2i(0, 1));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (std::find(result.begin(), result.end(), chip - Eigen::Vector2i(0, 2)) == result.end())
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
result.push_back(chip - Eigen::Vector2i(0, 2));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ChipCanBeMatchedLeft(chip))
|
|
|
|
{
|
|
|
|
if (std::find(result.begin(), result.end(), chip) == result.end())
|
|
|
|
{
|
|
|
|
result.push_back(chip);
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (std::find(result.begin(), result.end(), chip - Eigen::Vector2i(1, 0)) == result.end())
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
result.push_back(chip - Eigen::Vector2i(1, 0));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (std::find(result.begin(), result.end(), chip - Eigen::Vector2i(2, 0)) == result.end())
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
result.push_back(chip - Eigen::Vector2i(2, 0));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ChipCanBeMatchedRight(chip))
|
|
|
|
{
|
|
|
|
if (std::find(result.begin(), result.end(), chip) == result.end())
|
|
|
|
{
|
|
|
|
result.push_back(chip);
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (std::find(result.begin(), result.end(), chip + Eigen::Vector2i(1, 0)) == result.end())
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
result.push_back(chip + Eigen::Vector2i(1, 0));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (std::find(result.begin(), result.end(), chip + Eigen::Vector2i(2, 0)) == result.end())
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
result.push_back(chip + Eigen::Vector2i(2, 0));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::SwapChips(Eigen::Vector2i p1, Eigen::Vector2i p2, bool isReturning)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2f chip1PosFrom(LeftBottomPosField[0] + p1[0]*Match3FieldParams.CellWidth, LeftBottomPosField[1] + p1[1]*Match3FieldParams.CellHeight);
|
|
|
|
Eigen::Vector2f chip2PosFrom(LeftBottomPosField[0] + p2[0]*Match3FieldParams.CellWidth, LeftBottomPosField[1] + p2[1]*Match3FieldParams.CellHeight);
|
2013-01-19 22:25:53 +00:00
|
|
|
ChipSwappingPairVector.push_back(TChipSwappingPair(p1, p2, chip1PosFrom, chip2PosFrom));
|
|
|
|
|
2018-02-05 14:53:52 +00:00
|
|
|
ChipSwappingPairVector.back().IsReturning = isReturning;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
ChipMatrix[p1[0]][p1[1]].ChipState = TChip::CS_SWAPPING;
|
|
|
|
ChipMatrix[p2[0]][p2[1]].ChipState = TChip::CS_SWAPPING;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::ResetChipPos(Eigen::Vector2i p)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2f posFrom(LeftBottomPosField[0] + p[0]*Match3FieldParams.CellWidth, LeftBottomPosField[1] + p[1]*Match3FieldParams.CellHeight);
|
|
|
|
Eigen::Vector2f posTo(LeftBottomPosField[0] + (p[0] + 1)*Match3FieldParams.CellWidth, LeftBottomPosField[1] + (p[1] + 1)*Match3FieldParams.CellHeight);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
std::vector<Eigen::Vector3f> vertexCoordVec = SE::MakeVertexCoordVec(posFrom, posTo, ZLEVEL);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
TChip& chip = ChipMatrix[p[0]][p[1]];
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t i = 0; i<vertexCoordVec.size(); i++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-02 08:07:21 +00:00
|
|
|
chip.RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB][chip.VertexListShift + i] = vertexCoordVec[i];
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-05 14:53:52 +00:00
|
|
|
//chip.RenderPair->second.NeedRefreshBuffer = true;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::UpdateLogic(size_t dt)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if (dt > 1000)
|
|
|
|
{
|
|
|
|
dt = 1000; //To prevent float overflow during looong laaaag
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateChipSwapping(dt);
|
|
|
|
UpdateChipPosition(dt);
|
|
|
|
TryMatchAllChips();
|
|
|
|
|
|
|
|
std::vector<TChipDeletingData>::iterator i;
|
|
|
|
|
|
|
|
bool erased = false;
|
|
|
|
|
|
|
|
for (i = ChipDeletingVector.begin(); i != ChipDeletingVector.end();)
|
|
|
|
{
|
|
|
|
erased = false;
|
|
|
|
|
|
|
|
i->T += dt / 150.f;
|
|
|
|
|
|
|
|
if (i->T > 1.f)
|
|
|
|
{
|
|
|
|
i->T = 1.f;
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i p = i->Chip;
|
|
|
|
Eigen::Vector2f leftBottomPos = i->Pos;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2f halfPos = Eigen::Vector2f(Match3FieldParams.CellWidth / 2.f, Match3FieldParams.CellHeight / 2.f);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2f centerPos = leftBottomPos + halfPos;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
std::vector<Eigen::Vector3f> vertexCoordArr = SE::MakeVertexCoordVec(centerPos - (1.f - i->T)*halfPos, centerPos + (1.f - i->T)*halfPos, ZLEVEL);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-05 14:53:52 +00:00
|
|
|
for (int t = 0; t < 6; t++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-02 08:07:21 +00:00
|
|
|
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB][ChipMatrix[p[0]][p[1]].VertexListShift + t] = vertexCoordArr[t];
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (i->T == 1.f)
|
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
ChipMatrix[p[0]][p[1]].ChipState = TChip::CS_FINISHING;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
i = ChipDeletingVector.erase(i);
|
|
|
|
erased = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i != ChipDeletingVector.end() && !erased)
|
|
|
|
{
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-05 14:53:52 +00:00
|
|
|
|
2013-01-19 22:25:53 +00:00
|
|
|
RemoveBubbles();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Logic::HitFieldWithPattern(Eigen::Vector2i pos, std::vector<std::vector<char> > pattern, std::vector<std::vector<char> > jumpingPattern)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
const float CONST_VELOCITY_TO_ADD = 0.2f;
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t i = 0; i < pattern.size(); i++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
for (int j = static_cast<int>(pattern[i].size()-1); j >=0; j--)
|
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i fieldPos = pos + Eigen::Vector2i(i,j);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (fieldPos[0] >= 0 && fieldPos[0] < static_cast<int>(ChipMatrix.size()) &&
|
|
|
|
fieldPos[1] >= 0 && fieldPos[1] < static_cast<int>(ChipMatrix[fieldPos[0]].size()))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if (ChipIsStable(fieldPos))
|
|
|
|
{
|
|
|
|
if (pattern[i][j] > 0)
|
|
|
|
{
|
|
|
|
DestroyChip(fieldPos);
|
2018-02-01 14:39:31 +00:00
|
|
|
InsertEmptyChip(fieldPos[0], fieldPos[1], 0);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ChipIsLocked(fieldPos))
|
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
ChipMatrix[fieldPos[0]][fieldPos[1]].ChipState = TChip::CS_STANDBY;
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t i = 0; i < jumpingPattern.size(); i++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i abovePos = pos + Eigen::Vector2i(i, jumpingPattern[i].size());
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (abovePos[0] >= 0 && abovePos[0] < static_cast<int>(ChipMatrix.size()) &&
|
|
|
|
abovePos[1] >= 0 && abovePos[1] < static_cast<int>(ChipMatrix[i].size()))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (ChipMatrix[abovePos[0]][abovePos[1]].ChipState == TChip::CS_FALLING ||
|
|
|
|
ChipMatrix[abovePos[0]][abovePos[1]].ChipState == TChip::CS_STANDBY)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
ChipMatrix[abovePos[0]][abovePos[1]].ChipState = TChip::CS_FALLING;
|
|
|
|
ChipMatrix[abovePos[0]][abovePos[1]].Velocity += CONST_VELOCITY_TO_ADD;
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t j = 0; j < jumpingPattern[i].size(); j++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i fieldPos = pos + Eigen::Vector2i(i,j);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (fieldPos[0] >= 0 && fieldPos[0] < static_cast<int>(ChipMatrix.size()) &&
|
|
|
|
fieldPos[1] >= 0 && fieldPos[1] < static_cast<int>(ChipMatrix[fieldPos[0]].size()))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (ChipMatrix[fieldPos[0]][fieldPos[1]].ChipState == TChip::CS_FALLING ||
|
|
|
|
ChipMatrix[fieldPos[0]][fieldPos[1]].ChipState == TChip::CS_STANDBY)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
if (jumpingPattern[i][j] > 0)
|
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
ChipMatrix[fieldPos[0]][fieldPos[1]].ChipState = TChip::CS_FALLING;
|
|
|
|
ChipMatrix[fieldPos[0]][fieldPos[1]].Velocity += CONST_VELOCITY_TO_ADD;
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//================================================
|
|
|
|
//============ TMatch3Field ======================
|
|
|
|
//================================================
|
|
|
|
|
|
|
|
|
|
|
|
TMatch3Field::TMatch3Field()
|
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
LastTappedPos = Eigen::Vector2f(0,0);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TMatch3Field::TMatch3Field(const TMatch3Field& m)
|
|
|
|
{
|
|
|
|
LastTappedPos = m.LastTappedPos;
|
|
|
|
LastMovePos = m.LastMovePos;
|
|
|
|
}
|
|
|
|
|
|
|
|
TMatch3Field& TMatch3Field::operator=(const TMatch3Field& m)
|
|
|
|
{
|
|
|
|
LastTappedPos = m.LastTappedPos;
|
|
|
|
LastMovePos = m.LastMovePos;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
TMatch3Field::TMatch3Field(TMatch3Controller& match3Controller)
|
|
|
|
//: Match3Controller(match3Controller)
|
|
|
|
{
|
|
|
|
//Match3Controller.Match3Field = this;
|
|
|
|
|
|
|
|
FillBasicChipMatrixAndTriangleList();
|
|
|
|
}
|
|
|
|
|
|
|
|
TMatch3Field::~TMatch3Field()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMatch3Field::FillBasicChipMatrixAndTriangleList()
|
|
|
|
{
|
2018-02-02 08:07:21 +00:00
|
|
|
SE::TRenderParams renderParams;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
//renderParams.Transparency = 1.f;
|
|
|
|
renderParams.transparencyFlag = SE::TRenderParams::opaque;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
auto px = SE::FileToPropertyTree("match3params.xml");
|
2013-01-19 22:25:53 +00:00
|
|
|
Match3FieldParams.Serialize(*px);
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t i = 0; i < Match3FieldParams.ChipTypeCount; i++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-02 08:07:21 +00:00
|
|
|
TriangleListVector.push_back(SE::TRenderPair(Match3FieldParams.ChipTemplateParamsArr[i].SelectedRenderParams, SE::TTriangleList()));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
renderParams.SamplerMap[SE::CONST_STRING_TEXTURE_UNIFORM] = "chip1locked";
|
|
|
|
TriangleListVector.push_back(SE::TRenderPair(renderParams, SE::TTriangleList()));
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
renderParams.SamplerMap[SE::CONST_STRING_TEXTURE_UNIFORM] = "chip2locked";
|
|
|
|
TriangleListVector.push_back(SE::TRenderPair(renderParams, SE::TTriangleList()));
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
renderParams.SamplerMap[SE::CONST_STRING_TEXTURE_UNIFORM] = "chip3locked";
|
|
|
|
TriangleListVector.push_back(SE::TRenderPair(renderParams, SE::TTriangleList()));
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
renderParams.SamplerMap[SE::CONST_STRING_TEXTURE_UNIFORM] = "chip4locked";
|
|
|
|
TriangleListVector.push_back(SE::TRenderPair(renderParams, SE::TTriangleList()));
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
for (size_t i = 0; i < Match3FieldParams.ChipTypeCount; i++)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-02 08:07:21 +00:00
|
|
|
TriangleListVector.push_back(SE::TRenderPair(Match3FieldParams.ChipTemplateParamsArr[i].FinishingRenderParams, SE::TTriangleList()));
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
|
|
|
|
std::vector<SE::TRenderPairList::iterator> triangleListVec;
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
for (SE::TRenderPairList::iterator i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
triangleListVec.push_back(i);
|
|
|
|
}
|
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
LeftBottomPos = Eigen::Vector2f(150, 0);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
FillRandomChipMatrix(triangleListVec, LeftBottomPos);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
//Init everything
|
2018-02-01 14:39:31 +00:00
|
|
|
selectedChip = Eigen::Vector2i(-1, -1);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
for (SE::TRenderPairList::iterator i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-05 14:53:52 +00:00
|
|
|
//i->second.NeedRefreshBuffer = false;
|
2013-01-19 22:25:53 +00:00
|
|
|
i->second.RefreshBuffer();
|
|
|
|
}
|
2018-02-02 08:07:21 +00:00
|
|
|
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i TMatch3Field::PosToChip(Eigen::Vector2f pos)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
int x, y;
|
2018-02-02 15:00:17 +00:00
|
|
|
Eigen::Vector2f fieldPos = pos - LeftBottomPos;
|
2018-02-01 14:39:31 +00:00
|
|
|
x = static_cast<int>(fieldPos[0] / Match3FieldParams.CellWidth);
|
|
|
|
y = static_cast<int>(fieldPos[1] / Match3FieldParams.CellHeight);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
return Eigen::Vector2i(x, y);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Field::Update(size_t dt)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
TMatch3Logic::UpdateLogic(dt);
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
SE::TRenderPairList::iterator i;
|
|
|
|
for (i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i)
|
|
|
|
{
|
2018-02-05 14:53:52 +00:00
|
|
|
i->second.RefreshBuffer();
|
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
}
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-02 08:07:21 +00:00
|
|
|
int y = 6;
|
|
|
|
y = 6 + y;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Field::OnTapDown(Eigen::Vector2f pos)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
//See also OnMove
|
|
|
|
|
|
|
|
LastTappedPos = pos;
|
|
|
|
LastMovePos = LastTappedPos;
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i chip = PosToChip(pos);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
To hit field by pattern
|
|
|
|
std::vector<std::vector<char> > pattern;
|
|
|
|
pattern.resize(3);
|
|
|
|
pattern[0].resize(3);
|
|
|
|
pattern[1].resize(3);
|
|
|
|
pattern[2].resize(3);
|
|
|
|
|
|
|
|
pattern[0][0] = 0; pattern[1][0] = 1; pattern[2][0] = 0;
|
|
|
|
pattern[0][1] = 1; pattern[1][1] = 1; pattern[2][1] = 1;
|
|
|
|
pattern[0][2] = 0; pattern[1][2] = 1; pattern[2][2] = 0;
|
|
|
|
|
|
|
|
std::vector<std::vector<char> > jumpingPattern;
|
|
|
|
jumpingPattern.resize(3);
|
|
|
|
jumpingPattern[0].resize(3);
|
|
|
|
jumpingPattern[1].resize(3);
|
|
|
|
jumpingPattern[2].resize(3);
|
|
|
|
|
|
|
|
jumpingPattern[0][0] = 0; jumpingPattern[1][0] = 0; jumpingPattern[2][0] = 0;
|
|
|
|
jumpingPattern[0][1] = 0; jumpingPattern[1][1] = 0; jumpingPattern[2][1] = 0;
|
|
|
|
jumpingPattern[0][2] = 1; jumpingPattern[1][2] = 0; jumpingPattern[2][2] = 1;
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
HitFieldWithPattern(chip - Eigen::Vector2i(1, 1), pattern, jumpingPattern);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
return;*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedChip == chip)
|
|
|
|
{
|
|
|
|
UnselectChip();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ChipsCanBeSwapped(selectedChip, chip))
|
|
|
|
{
|
|
|
|
SwapChips(selectedChip, chip);
|
|
|
|
UnselectChip();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ChipCanBeSelected(chip))
|
|
|
|
{
|
|
|
|
SelectChip(chip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Field::OnTapUp(Eigen::Vector2f pos)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMatch3Field::OnMove(Eigen::Vector2f shift)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (selectedChip == Eigen::Vector2i(-1, -1))
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LastMovePos += shift;
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if ((LastTappedPos - LastMovePos)[0] >= Match3FieldParams.CellWidth * 0.5f)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i newPosChip = selectedChip + Eigen::Vector2i(1, 0);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (selectedChip[0] <= Match3FieldParams.FieldWidth - 2)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
if (ChipsCanBeSwapped(selectedChip, newPosChip))
|
|
|
|
{
|
|
|
|
SwapChips(selectedChip, newPosChip);
|
|
|
|
UnselectChip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-01 14:39:31 +00:00
|
|
|
else if ((LastMovePos - LastTappedPos)[0] >= Match3FieldParams.CellWidth * 0.5f)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i newPosChip = selectedChip - Eigen::Vector2i(1, 0);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (selectedChip[0] >= 1)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
if (ChipsCanBeSwapped(selectedChip, newPosChip))
|
|
|
|
{
|
|
|
|
SwapChips(selectedChip, newPosChip);
|
|
|
|
UnselectChip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-01 14:39:31 +00:00
|
|
|
else if ((LastMovePos - LastTappedPos)[1] >= Match3FieldParams.CellHeight * 0.5f)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i newPosChip = selectedChip + Eigen::Vector2i(0, 1);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (selectedChip[1] <= Match3FieldParams.FieldHeight - 2)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
if (ChipsCanBeSwapped(selectedChip, newPosChip))
|
|
|
|
{
|
|
|
|
SwapChips(selectedChip, newPosChip);
|
|
|
|
UnselectChip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-01 14:39:31 +00:00
|
|
|
else if ((LastTappedPos - LastMovePos)[1] >= Match3FieldParams.CellHeight * 0.5f)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
Eigen::Vector2i newPosChip = selectedChip - Eigen::Vector2i(0, 1);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (selectedChip[1] >= 1)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
if (ChipsCanBeSwapped(selectedChip, newPosChip))
|
|
|
|
{
|
|
|
|
SwapChips(selectedChip, newPosChip);
|
|
|
|
UnselectChip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
bool TMatch3Field::CheckClick(Eigen::Vector2f mousePos)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
Eigen::Vector2f fieldPos = mousePos - LeftBottomPos;
|
2018-02-01 14:39:31 +00:00
|
|
|
if (fieldPos[0] >= 0 && fieldPos[0] <= Match3FieldParams.FieldWidth*Match3FieldParams.CellWidth)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-01 14:39:31 +00:00
|
|
|
if (fieldPos[1] >= 0 && fieldPos[1] <= Match3FieldParams.FieldHeight*Match3FieldParams.CellHeight)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TMatch3Field::HighlightMatch3()
|
|
|
|
{
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<Eigen::Vector2i> chips = GetAvailableMatchingChips();
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
std::vector<Eigen::Vector2i>::iterator i;
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
for (i = chips.begin(); i != chips.end(); ++i)
|
|
|
|
{
|
2018-02-02 08:07:21 +00:00
|
|
|
SE::ResourceManager->HalibutAnimationManager.StartAnimation(ChipMatrix[(*i)[0]][(*i)[1]].AnimName);
|
2013-01-19 22:25:53 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|