forked from lfeng1420/BrickGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatchGame.h
68 lines (52 loc) · 1.27 KB
/
MatchGame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once
#include "GameBase.h"
class CMatchGame : public CGameBase
{
// Start
virtual void Start();
// Update
// param: dt, millisecond
virtual void Update(float dt);
// Get game id
virtual EnGameID GetGameID();
// Button event
virtual void OnButtonEvent(const SEventContextButton* pButtonEvent);
private:
// Init src / dest shapes
void __InitSrcDestShapes();
// Random shape
void __RandomShapes(int* arrShapes);
// Update all bricks state
void __UpdateAllBricksState();
// Update shapes position
bool __UpdateShapes(float dt, bool bSelfOnlyFlag = false);
// Get shape move interval
int __GetShapeMoveInterval(bool bDestShapeFlag);
// Get dismatch shape index
int __GetDismatchShapeIdx();
// Handle match result
void __HandleMatchResult();
private:
enum
{
SHAPE_COUNT_MAX = 3,
DEST_SHAPE_MOVE_INTERVAL = 1000,
SRC_SHAPE_MOVE_INTERVAL = 30,
SHAPE_UPDATE_INTERVAL = 60,
SHAPE_MATCH_ADD_SCORE = 10,
REQUIRE_MATCH_SUCC_COUNT = 10,
};
struct _TShapeData
{
int arrShapeID[SHAPE_COUNT_MAX];
int nRowIdx;
int nInterval;
};
private:
// Dest shapes
_TShapeData m_stDestShape;
// Self shapes
_TShapeData m_stSrcShape;
// Match succ count
int m_nMatchSuccCount;
};