AniTutorialMapControl.h
7.86 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//
// AniTutorialMapControl.h
// SteveMaggieCpp
//
// Created by Katarzyna Kalinowska-Górska on 17.05.2017.
//
//
#ifndef AniTutorialMapControl_h
#define AniTutorialMapControl_h
#include "AniTouchRecognizerMapControl.h"
#include "AniMapUtils.h"
#include "MapAdventureObjectSlide.h"
class TutorialDataSource;
class TutorialDelegate;
class AniTutorialMapControl : public AniTouchRecognizerMapControl {
public:
virtual void install(AniMapLayer* p_AniMapLayer, IMapCharacter* p_controlledCharacter, std::vector<IMapControlInterface*> p_observers) override;
AniTutorialMapControl(TutorialDataSource* p_tutorialDataSource, TutorialDelegate* p_tutorialDelegate) : m_tutorialDataSource(p_tutorialDataSource), m_tutorialDelegate(p_tutorialDelegate) {};
virtual ~AniTutorialMapControl();
void startTutorial();
void forceFinishTutorial();
enum class TutorialPhase {
INIT,
MOVE_STEVE,
TAP_OBJECT,
APPROACHING_SLIDE,
SLIDE,
MOVE_TO_JUMP_SPOT,
JUMP_UP,
JUMP_LEFT,
JUMP_DOWN,
JUMP_RIGHT,
TICKLE,
PRE_ZOOM,
ZOOM,
POST_ZOOM,
FINISHING,
FINISHED
};
struct CharacterEvent : IMapEvent {
cocos2d::Vec2 characterPosition;
AniMapUtils::TileData characterTile;
};
struct CharacterChangeTileEvent : CharacterEvent {
CharacterChangeTileEvent(cocos2d::Vec2 p_position, AniMapUtils::TileData p_tile){
type = "CharacterChangeTileEvent";
characterPosition = p_position;
characterTile = p_tile;
}
};
struct CharacterStopEvent : CharacterEvent {
CharacterStopEvent(cocos2d::Vec2 p_position, AniMapUtils::TileData p_tile){
type = "CharacterStopEvent";
characterPosition = p_position;
characterTile = p_tile;
}
};
struct TappedSlideEvent : IMapEvent {
MapAdventureObjectSlide* slide { nullptr};
AniMapUtils::TileData tappedTile;
TappedSlideEvent(MapAdventureObjectSlide* p_slide, AniMapUtils::TileData p_tile){
type = "TappedSlideEvent";
slide = p_slide;
tappedTile = p_tile;
}
};
struct CharacterStartedSlidingEvent : CharacterEvent {
CharacterStartedSlidingEvent(){//cocos2d::Vec2 p_position, cocos2d::Vec2 p_tile){
type = "CharacterStartedSlidingEvent";
// characterPosition = p_position;
// characterTile = p_tile;
}
};
struct CharacterFinishedSlidingEvent : CharacterEvent {
CharacterFinishedSlidingEvent(){//cocos2d::Vec2 p_position, cocos2d::Vec2 p_tile){
type = "CharacterFinishedSlidingEvent";
// characterPosition = p_position;
// characterTile = p_tile;
}
};
struct CharacterStartedJumpingEvent : CharacterEvent {
CharacterStartedJumpingEvent(cocos2d::Vec2 p_position, AniMapUtils::TileData p_tile){
type = "CharacterStartedJumpingEvent";
characterPosition = p_position;
characterTile = p_tile;
}
};
struct CharacterFinishedJumpingEvent : CharacterEvent {
CharacterFinishedJumpingEvent(cocos2d::Vec2 p_position, AniMapUtils::TileData p_tile){
type = "CharacterFinishedJumpingEvent";
characterPosition = p_position;
characterTile = p_tile;
}
};
struct CharacterFinishedLaughingEvent : CharacterEvent {
CharacterFinishedLaughingEvent(){
type = "CharacterFinishedLaughingEvent";
}
};
struct MapFinishedMovingEvent : IMapEvent {
MapFinishedMovingEvent(){
type = "MapFinishedMovingEvent";
}
};
struct MapTappedToFinishMovingEvent : IMapEvent {
MapTappedToFinishMovingEvent(){
type = "MapTappedToFinishMovingEvent";
}
};
virtual void mapEvent(IMapControlInterface* p_controlInterface, IMapEvent* p_mapEvent) override;
protected:
TutorialDataSource* m_tutorialDataSource {nullptr};
TutorialDelegate* m_tutorialDelegate {nullptr};
AniMapLayer* m_AniMapLayer;
IMapCharacter* m_mapCharacter;
cocos2d::Sprite* m_finger {nullptr};
TutorialPhase m_tutorialPhase {TutorialPhase::INIT};
bool m_tutorialJumpSubPhaseJumping {false};
// struct {
// cocos2d::Vec2 fingerLocationPhaseMove;
// cocos2d::Vec2 targetTilePhaseMove;
// cocos2d::Vec2 fingerLocationPhaseTapObject;
// cocos2d::Vec2 targetTilePhaseTapObject;
// } m_tutorialData;
virtual void configureTouchAniGestureRecognizer(AniMapLayer* p_AniMapLayer) override;
virtual void configureAniTickleGestureRecognizer(IMapCharacter* p_controlledCharacter) override;
virtual void configureAniFastSwipeGestureRecognizer(cocos2d::Node* p_controlledCharacter) override;
virtual void configureAniTapGestureRecognizer(AniMapLayer* p_AniMapLayer) override;
virtual void configureAniLongPressGestureRecognizer(IMapCharacter* p_controlledCharacter) override;
void startTapObjectPhase();
void moveToJumpingSpot();
void startJumpUpPhase();
void startJumpDownPhase();
void startJumpLeftPhase();
void startJumpRightPhase();
void startTicklePhase();
void startMapMovePhase();
void startMapTapToCancelMovePhase();
void finishTutorial(bool silent = false);
void praiseAndNextPhase(std::function<void()> nextPhaseFunction);
void blinkFingerAtMapLocation(cocos2d::Vec2 p_mapLocation);
void blinkFingerAtScreenLocation(cocos2d::Vec2 p_mapLocation);
void swipeFingerAtMapLocations(cocos2d::Vec2 p_mapLocationFrom, cocos2d::Vec2 p_mapLocationTo, float moveTime, float pauseTime);
void moveFingerBackAndForthAtMapLocations(cocos2d::Vec2 p_mapLocationFrom, cocos2d::Vec2 p_mapLocationTo, float moveTime, float pauseTime);
void hideFinger();
void setDarknessRevealParams(cocos2d::Vec2 p_revealCircleMiddle, float p_revealCircleRadius);
};
class TutorialDataSource {
public:
virtual std::string soundPathForPhaseMove(AniTutorialMapControl* p_mapControl, int& soundDurationSecs) = 0;
virtual cocos2d::Point mapPointForMoveSteveFinger(AniTutorialMapControl* p_mapControl) = 0;
virtual std::vector<AniMapUtils::TileData> mapTilesForMoveSteveEnd(AniTutorialMapControl* p_mapControl) = 0;
virtual cocos2d::Vec2 cancelZoomButtonPosition(AniTutorialMapControl* p_mapControl) = 0;
virtual std::string soundPathForPhaseTapObject(AniTutorialMapControl* p_mapControl, int& soundDurationSecs) = 0;
virtual cocos2d::Point mapPointForTapObjectFinger(AniTutorialMapControl* p_mapControl) = 0;
virtual std::string soundPathForPhaseJumpUp(AniTutorialMapControl* p_mapControl, int& soundDurationSecs) = 0;
virtual std::string soundPathForPhaseJumpDown(AniTutorialMapControl* p_mapControl, int& soundDurationSecs) = 0;
virtual std::string soundPathForPhaseJumpLeft(AniTutorialMapControl* p_mapControl, int& soundDurationSecs) = 0;
virtual std::string soundPathForPhaseJumpRight(AniTutorialMapControl* p_mapControl, int& soundDurationSecs) = 0;
virtual std::string soundPathForPhaseTickle(AniTutorialMapControl* p_mapControl, int& soundDurationSecs) = 0;
virtual std::string soundPathForPhaseMoveMap(AniTutorialMapControl* p_mapControl, int& soundDurationSecs) = 0;
virtual std::string soundPathForPhaseTapToFinishMovingMap(AniTutorialMapControl* p_mapControl, int& soundDurationSecs) = 0;
virtual std::string soundPathForTutorialFinished(AniTutorialMapControl* p_mapControl, int& soundDurationSecs) = 0;
};
class TutorialDelegate {
public:
virtual void tutorialFinished(AniTutorialMapControl* p_mapControl) = 0;
};
#endif /* AniTutorialMapControl_h */