migrate to TES-engine
This commit is contained in:
1 parent
b4c58abee4
commit
d97dab0ecc
8 files changed
+569
-381
No files matched your search
+277
-266
File diff suppressed because it is too large.
Load diff
+76
-78
@@ -2,11 +2,12 @@
|
||||
#define MATCH3FIELD_H_INCLUDED
|
||||
|
||||
#include "include/Engine.h"
|
||||
#include <Eigen/src/Core/Matrix.h>
|
||||
|
||||
|
||||
|
||||
const cardinal CONST_MAX_FIELD_WIDTH = 11;
|
||||
const cardinal CONST_MAX_FIELD_HEIGHT = 11;
|
||||
const size_t CONST_MAX_FIELD_WIDTH = 11;
|
||||
const size_t CONST_MAX_FIELD_HEIGHT = 11;
|
||||
|
||||
|
||||
const float CONST_MATCH3_CELL_WIDTH = 42.f;
|
||||
@@ -20,7 +21,7 @@ const float CONST_MATCH3_CELL_HEIGHT = 32.f;
|
||||
const float CONST_CHIP_LOWEST_SPEED = -0.3f;
|
||||
const float CONST_CHIP_ACCELERATION = -0.001f;
|
||||
*/
|
||||
const cardinal CONST_MATCH_TIME = 150;
|
||||
const size_t CONST_MATCH_TIME = 150;
|
||||
|
||||
const float CONST_CHIP_POSITION_EPSILON = 1.f;
|
||||
const float CONST_CHIP_VELOCITY_EPSILON = 0.3f;
|
||||
@@ -28,25 +29,24 @@ const float CONST_CHIP_VELOCITY_EPSILON = 0.3f;
|
||||
|
||||
const float CONST_CHIP_K = 0.4f;
|
||||
|
||||
const cardinal CONST_CHIP_TYPE_COUNT = 4;
|
||||
const size_t CONST_CHIP_TYPE_COUNT = 4;
|
||||
|
||||
|
||||
struct TChipTemplateParams : public TSerializeInterface
|
||||
struct TChipTemplateParams : public SE::TSerializeInterface
|
||||
{
|
||||
THalibutExternalAnimObject SelectedTemplateAnimObject;
|
||||
THalibutExternalAnimObject FinishingTemplateAnimObject;
|
||||
TRenderParams SelectedRenderParams;
|
||||
TRenderParams FinishingRenderParams;
|
||||
SE::THalibutExternalAnimObject SelectedTemplateAnimObject;
|
||||
SE::THalibutExternalAnimObject FinishingTemplateAnimObject;
|
||||
SE::TRenderParams SelectedRenderParams;
|
||||
SE::TRenderParams FinishingRenderParams;
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct TMatch3FieldParams : public TSerializeInterface
|
||||
struct TMatch3FieldParams : public SE::TSerializeInterface
|
||||
{
|
||||
cardinal FieldWidth;
|
||||
cardinal FieldHeight;
|
||||
size_t FieldWidth;
|
||||
size_t FieldHeight;
|
||||
float CellWidth;
|
||||
float CellHeight;
|
||||
float ChipLowestSpeed;
|
||||
@@ -55,9 +55,9 @@ struct TMatch3FieldParams : public TSerializeInterface
|
||||
float ChipPositionEpsilon;
|
||||
float ChipVelocityEpsilon;
|
||||
float ChipK;
|
||||
cardinal ChipMatchTime;
|
||||
size_t ChipMatchTime;
|
||||
|
||||
cardinal ChipTypeCount;
|
||||
size_t ChipTypeCount;
|
||||
|
||||
std::vector<TChipTemplateParams> ChipTemplateParamsArr;
|
||||
|
||||
@@ -82,15 +82,14 @@ struct TMatch3FieldParams : public TSerializeInterface
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct TChip
|
||||
{
|
||||
int ChipType; // -1 means empty field
|
||||
std::string AnimName; //Generated automatically
|
||||
|
||||
TRenderPairList::iterator RenderPair;
|
||||
SE::TRenderPairList::iterator RenderPair;
|
||||
|
||||
cardinal VertexListShift;
|
||||
size_t VertexListShift;
|
||||
|
||||
float Velocity;
|
||||
|
||||
@@ -104,31 +103,32 @@ struct TChip
|
||||
CS_X,
|
||||
} ChipState;
|
||||
|
||||
TChip(int chipType, TRenderPairList::iterator renderPair, cardinal vertexListShift, TChipState chipState = CS_FALLING);
|
||||
TChip(int chipType, SE::TRenderPairList::iterator renderPair, size_t vertexListShift, TChipState chipState = CS_FALLING);
|
||||
|
||||
~TChip();
|
||||
|
||||
vec2 GetLeftBottomPos();
|
||||
void SetLeftBottomPos(vec2 newPos);
|
||||
void MoveLeftBottomPos(vec2 shift);
|
||||
Eigen::Vector2f GetLeftBottomPos();
|
||||
void SetLeftBottomPos(Eigen::Vector2f newPos);
|
||||
void MoveLeftBottomPos(Eigen::Vector2f shift);
|
||||
|
||||
static int StaticAnimationIndex;
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct TChipSwappingPair
|
||||
{
|
||||
float T;
|
||||
ivec2 Chip1;
|
||||
ivec2 Chip2;
|
||||
Eigen::Vector2i Chip1;
|
||||
Eigen::Vector2i Chip2;
|
||||
|
||||
vec2 Chip1RealPosFrom;
|
||||
vec2 Chip2RealPosFrom;
|
||||
Eigen::Vector2f Chip1RealPosFrom;
|
||||
Eigen::Vector2f Chip2RealPosFrom;
|
||||
|
||||
bool IsReturning;
|
||||
|
||||
|
||||
TChipSwappingPair(ivec2 chip1, ivec2 chip2, vec2 chip1PosFrom, vec2 chip2PosFrom)
|
||||
TChipSwappingPair(Eigen::Vector2i chip1, Eigen::Vector2i chip2, Eigen::Vector2f chip1PosFrom, Eigen::Vector2f chip2PosFrom)
|
||||
: Chip1(chip1)
|
||||
, Chip2(chip2)
|
||||
, T(0)
|
||||
@@ -143,10 +143,10 @@ struct TChipSwappingPair
|
||||
struct TChipDeletingData
|
||||
{
|
||||
float T;
|
||||
ivec2 Chip;
|
||||
vec2 Pos;
|
||||
Eigen::Vector2i Chip;
|
||||
Eigen::Vector2f Pos;
|
||||
|
||||
TChipDeletingData(ivec2 chip, vec2 pos)
|
||||
TChipDeletingData(Eigen::Vector2i chip, Eigen::Vector2f pos)
|
||||
: T(0.f)
|
||||
, Chip(chip)
|
||||
, Pos(pos)
|
||||
@@ -154,97 +154,100 @@ struct TChipDeletingData
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TMatch3Logic
|
||||
{
|
||||
protected:
|
||||
|
||||
cardinal ChipTypeCount;
|
||||
size_t ChipTypeCount;
|
||||
|
||||
std::vector<std::vector<TChip> > ChipMatrix;
|
||||
std::vector<TChipSwappingPair> ChipSwappingPairVector;
|
||||
std::vector<TChipDeletingData> ChipDeletingVector;
|
||||
|
||||
std::vector<TRenderPairList::iterator> RenderPairIteratorVector;
|
||||
std::vector<SE::TRenderPairList::iterator> RenderPairIteratorVector;
|
||||
|
||||
ivec2 selectedChip;
|
||||
Eigen::Vector2i selectedChip;
|
||||
|
||||
vec2 LeftBottomPosField;
|
||||
Eigen::Vector2f LeftBottomPosField;
|
||||
|
||||
TMatch3FieldParams Match3FieldParams;
|
||||
|
||||
void FillRandomChipMatrix(std::vector<TRenderPairList::iterator> renderPairIteratorVector, vec2 leftBottomPos);
|
||||
void FillRandomChipMatrix(std::vector<SE::TRenderPairList::iterator> renderPairIteratorVector, Eigen::Vector2f leftBottomPos);
|
||||
|
||||
vec2 GetExpectedLeftBottomPos(cardinal x, cardinal y);
|
||||
Eigen::Vector2f GetExpectedLeftBottomPos(size_t x, size_t y);
|
||||
|
||||
void StartAnimateChip(cardinal x, cardinal y);
|
||||
void StopAnimateChip(cardinal x, cardinal y);
|
||||
void StartAnimateChip(size_t x, size_t y);
|
||||
void StopAnimateChip(size_t x, size_t y);
|
||||
|
||||
bool ChipIsLocked(ivec2 chip);
|
||||
bool ChipIsFinishing(ivec2 chip);
|
||||
bool ChipIsStable(ivec2 chip);
|
||||
bool ChipCanBeSelected(ivec2 chip);
|
||||
bool ChipsCanBeSwapped(ivec2 p1, ivec2 p2);
|
||||
bool ChipIsLocked(Eigen::Vector2i chip);
|
||||
bool ChipIsFinishing(Eigen::Vector2i chip);
|
||||
bool ChipIsStable(Eigen::Vector2i chip);
|
||||
bool ChipCanBeSelected(Eigen::Vector2i chip);
|
||||
bool ChipsCanBeSwapped(Eigen::Vector2i p1, Eigen::Vector2i p2);
|
||||
|
||||
bool ChipCanBeMatchedUp(ivec2 chip);
|
||||
bool ChipCanBeMatchedDown(ivec2 chip);
|
||||
bool ChipCanBeMatchedLeft(ivec2 chip);
|
||||
bool ChipCanBeMatchedRight(ivec2 chip);
|
||||
bool ChipCanBeMatchedUp(Eigen::Vector2i chip);
|
||||
bool ChipCanBeMatchedDown(Eigen::Vector2i chip);
|
||||
bool ChipCanBeMatchedLeft(Eigen::Vector2i chip);
|
||||
bool ChipCanBeMatchedRight(Eigen::Vector2i chip);
|
||||
|
||||
void UnmatchChips(std::vector<ivec2> chipList);
|
||||
void UpdateChipPosition(cardinal dt);
|
||||
void UnmatchChips(std::vector<Eigen::Vector2i> chipList);
|
||||
void UpdateChipPosition(size_t dt);
|
||||
void RemoveBubbles();
|
||||
|
||||
void ReplaceAnimation(ivec2 p);
|
||||
void ReplaceAnimation(Eigen::Vector2i p);
|
||||
|
||||
void MoveVertexListShiftBack(TRenderPairList::iterator renderPairItr, cardinal moveFrom);
|
||||
void MoveVertexCoordDown(TRenderPairList::iterator renderPairItr, cardinal moveFrom, float value);
|
||||
void MoveVertexListShiftBack(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom);
|
||||
void MoveVertexCoordDown(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom, float value);
|
||||
|
||||
void AddChipToUp(cardinal colNum, int chipType, vec2 spawnPos, TChip::TChipState chipState = TChip::CS_FALLING);
|
||||
void InsertEmptyChip(cardinal colNum, cardinal rowNum, int chipType);
|
||||
void AddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState = TChip::CS_FALLING);
|
||||
void InsertEmptyChip(size_t colNum, size_t rowNum, int chipType);
|
||||
|
||||
void UpdateChipSwapping(cardinal dt);
|
||||
void UpdateChipSwapping(size_t dt);
|
||||
void TryMatchAllChips();
|
||||
|
||||
void DestroyChip(ivec2 p);
|
||||
void DestroyChip(Eigen::Vector2i p);
|
||||
|
||||
void ChangeChipType(ivec2 p);
|
||||
void ChangeChipType(Eigen::Vector2i p);
|
||||
|
||||
public:
|
||||
|
||||
TMatch3Logic();
|
||||
virtual ~TMatch3Logic();
|
||||
|
||||
void SelectChip(ivec2 pos);
|
||||
void SelectChip(Eigen::Vector2i pos);
|
||||
void UnselectChip();
|
||||
ivec2 GetSelectedChip();
|
||||
Eigen::Vector2i GetSelectedChip();
|
||||
|
||||
std::vector<ivec2> GetAvailableMatchingChips();
|
||||
std::vector<Eigen::Vector2i> GetAvailableMatchingChips();
|
||||
|
||||
void SwapChips(ivec2 p1, ivec2 p2, bool isReturning = false);
|
||||
void SwapChips(Eigen::Vector2i p1, Eigen::Vector2i p2, bool isReturning = false);
|
||||
|
||||
void ResetChipPos(ivec2 p);
|
||||
void ResetChipPos(Eigen::Vector2i p);
|
||||
|
||||
void UpdateLogic(cardinal dt);
|
||||
void UpdateLogic(size_t dt);
|
||||
|
||||
void HitFieldWithPattern(ivec2 pos, std::vector<std::vector<char> > pattern, std::vector<std::vector<char> > jumpingPattern);
|
||||
void HitFieldWithPattern(Eigen::Vector2i pos, std::vector<std::vector<char> > pattern, std::vector<std::vector<char> > jumpingPattern);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TMatch3Controller;
|
||||
|
||||
class TMatch3Field : public TMatch3Logic, public TInstancingWidgetAncestor
|
||||
class TMatch3Field : public TMatch3Logic
|
||||
{
|
||||
protected:
|
||||
void FillBasicChipMatrixAndTriangleList();
|
||||
|
||||
//TMatch3Controller& Match3Controller;
|
||||
|
||||
vec2 LastTappedPos;
|
||||
vec2 LastMovePos;
|
||||
Eigen::Vector2f LastTappedPos;
|
||||
Eigen::Vector2f LastMovePos;
|
||||
|
||||
ivec2 PosToChip(vec2 pos);
|
||||
Eigen::Vector2i PosToChip(Eigen::Vector2f pos);
|
||||
|
||||
public:
|
||||
TMatch3Field();
|
||||
@@ -254,11 +257,11 @@ public:
|
||||
TMatch3Field(TMatch3Controller& match3Controller);
|
||||
~TMatch3Field();
|
||||
|
||||
virtual void Update(cardinal dt);
|
||||
virtual void OnTapDown(vec2 pos);
|
||||
virtual void OnTapUp(vec2 pos);
|
||||
virtual void OnMove(vec2 shift);
|
||||
virtual bool CheckClick(vec2 mousePos);
|
||||
virtual void Update(size_t dt);
|
||||
virtual void OnTapDown(Eigen::Vector2f pos);
|
||||
virtual void OnTapUp(Eigen::Vector2f pos);
|
||||
virtual void OnMove(Eigen::Vector2f shift);
|
||||
virtual bool CheckClick(Eigen::Vector2f mousePos);
|
||||
|
||||
void HighlightMatch3();
|
||||
|
||||
@@ -268,9 +271,4 @@ public:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user