forked from ShortTailLab/ph-open
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXiaKe.h
482 lines (399 loc) · 13.4 KB
/
XiaKe.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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
#pragma once
#include "ContentLayer.h"
#include "PlayerData.h"
#include "UIComponent.h"
#include "ButtonSprite.h"
#include <CCRichLabelTTF.h>
class ZqlScrollView;
class PageScrollView;
namespace PH
{
class HeroIcon;
class LabelX;
class BianDuiJuanZhou : public JuanZhou
{
public:
std::vector<PH::Hero *> team;
CCLabelBMFont* hpLabel;
CCLabelBMFont* attackLabel;
CCLabelBMFont* regenLabel;
CCLabelBMFont* lpLabel;
CCLabelBMFont* lpMaxLabel;
std::vector<CCLabelBMFont*> resistLabels;
bool isUpdate;
BianDuiSwitcher* switcher;
virtual bool init(const std::vector<PH::Hero *>& heroVec2);
virtual void clear();
void updateLabel();
static BianDuiJuanZhou* create(const std::vector<PH::Hero *>& heroVec2)
{
BianDuiJuanZhou* o = new BianDuiJuanZhou();
if(o != NULL && o->init(heroVec2))
{
o->autorelease();
return o;
}
CC_SAFE_DELETE(o);
return NULL;
}
protected:
virtual void updateData();
};
class XiangQingJuanZhou : public JuanZhou
{
public:
XiangQingJuanZhou();
virtual bool init(std::vector<Hero*>* team);
virtual bool addHero(PH::Hero *hero, int id, bool isUpdate = true);
virtual void openDone();
virtual void initHeroRelations();
void updateRelationBoard(const HeroRelation* relation);
void refresh();
virtual void onSingleClick(CCTouch* touch);
virtual void onLongClick(CCTouch* touch);
static XiangQingJuanZhou* create(std::vector<Hero*>* team)
{
XiangQingJuanZhou* o = new XiangQingJuanZhou();
if(o != NULL && o->init(team))
{
o->autorelease();
return o;
}
CC_SAFE_DELETE(o);
return NULL;
}
protected:
std::vector<Hero*> targetTeam;
TeamData teamData;
PageScrollView *relations;
cocos2d::CCSprite *relationBoard;
cocos2d::CCLabelTTF *rName;
cocos2d::CCLabelTTF *rHeroes;
cocos2d::CCLabelTTF *rEffect;
std::vector<HeroRelation> relats;
std::vector<cocos2d::CCSprite*> relationItems;
cocos2d::CCSprite * tempRItem;
CCLabelBMFont* lpLabel;
CCLabelBMFont* hpLabel;
CCLabelBMFont* fightLabel;
CCLabelBMFont* regenLabel;
CCLabelBMFont* redAttackLabel;
CCLabelBMFont* blueAttackLabel;
CCLabelBMFont* greenAttackLabel;
CCLabelBMFont* purpleAttackLabel;
CCLabelBMFont* yellowAttackLabel;
std::vector<CCLabelBMFont*> resistLabels;
bool isShowNormalSkill;
CCLabelTTF* skillLabel;
LabelX* descLabel;
HeroIcon *tempIcon;
void onPressedTimer(float dt);
void switchSkillType();
void updateSkillType();
private:
ScrollRelations* relationsView;
};
class XiangQingLayer :public ContentLayer
{
public:
virtual bool init(std::vector<Hero*>* team);
virtual void onEnterAnimationDone();
XiangQingJuanZhou *juanzhou;
cocos2d::CCSprite *zhou1;
cocos2d::CCSprite *zhou2;
JuanZhouLayer *jz;
static XiangQingLayer* create(std::vector<Hero*>* team = NULL)
{
XiangQingLayer* o = new XiangQingLayer();
if(o != NULL && o->init(team))
{
o->autorelease();
return o;
}
CC_SAFE_DELETE(o);
return NULL;
}
void onBackClick(cocos2d::CCObject *target);
void onTitleClick(cocos2d::CCObject *target);
void onShare(cocos2d::CCObject *target);
};
class BianDuiBoard : public HeroBoard
{
public:
virtual bool init(const std::vector<PH::Hero *>& heroVec);
virtual void refresh(const std::vector<PH::Hero *>& heroVec);
static BianDuiBoard* create(const std::vector<PH::Hero *>& heroVec)
{
BianDuiBoard* o = new BianDuiBoard();
if(o != NULL && o->init(heroVec))
{
o->autorelease();
return o;
}
CC_SAFE_DELETE(o);
return NULL;
}
};
class HeroPoolBoard : public HeroBoard
{
public:
HeroPoolBoard();
virtual void refresh(const std::vector<PH::Hero *>& heroVec);
bool isEnlargeClick(CCTouch* touch);
static HeroPoolBoard* create(const std::vector<PH::Hero *>& heroVec)
{
HeroPoolBoard* o = new HeroPoolBoard();
if(o != NULL && o->init(heroVec, true))
{
o->autorelease();
return o;
}
CC_SAFE_DELETE(o);
return NULL;
}
private:
CCSprite* enlargeBtn;
};
class BianDuiLayer : public ContentLayer
{
protected:
CCMenu *topMenu;
HeroBoard *board;
JuanZhou *juanzhou;
JuanZhouLayer *jz;
ZqlScrollView *scrollView;
CCLabelTTF *title;
HeroIcon *curTouchIcon;
bool isClick;
private:
CCMenuItem* backButton;
CCMenuItem* sortButton;
CCMenuItem* detailButton;
std::vector<std::string> idsOnEnter;
int activeTeamOnEnter;
boost::function<void()> tutInit;
boost::function<void()> tutGroupFirstHero;
boost::function<void()> tutShowLongClick;
boost::function<void()> tutShowBackButton;
public:
virtual bool init();
virtual void onEnter();
virtual void onEnterAnimationDone();
virtual void onExit();
virtual void cleanup();
virtual void putHeroToJz(HeroIcon *icon);
void putBackHeroFJzToBoard(HeroIcon *icon);
virtual void putBackHeroToBoard(Hero *hero);
void pullHeroIconFrBoard(HeroIcon *icon);
void disableOverLPHeroes();
virtual void setTouchEnabled(bool value);
virtual void onSingleClick(CCTouch* touch);
virtual void onLongClick(CCTouch* touch);
void switchActiveTeam(int i);
static BianDuiLayer* create()
{
BianDuiLayer* o = new BianDuiLayer();
if(o != NULL && o->init())
{
o->autorelease();
return o;
}
CC_SAFE_DELETE(o);
return NULL;
};
virtual bool tryExit(int msg = -1);
protected:
virtual void onBackClick(cocos2d::CCObject *target);
void onDetailClick(cocos2d::CCObject *target);
void onBianduiClick(cocos2d::CCObject *target);
};
class HeroPoolLayer : public ContentLayer
{
public:
std::vector<PH::Hero*> storage;
HeroPoolBoard *board;
virtual bool init();
virtual void onEnter();
virtual void onExit();
void initHeroNumTips();
void onBackClick(cocos2d::CCObject *target);
void onTitleClick(cocos2d::CCObject *target);
virtual void onSingleClick(CCTouch* touch);
virtual void onLongClick(CCTouch* touch);
virtual void cleanup();
static HeroPoolLayer* create()
{
HeroPoolLayer* o = new HeroPoolLayer();
if(o != NULL && o->init())
{
o->autorelease();
return o;
}
CC_SAFE_DELETE(o);
return NULL;
}
private:
int currSwitchType;
std::vector<Hero*> heroesOfCurrType;
HeroBoardSwitcher* switcher;
Hero *tempHero;
CCLabelTTF *title;
CCSprite *xian;
ZqlScrollView *scrollView;
CCSprite* addSeatBtn;
CCSprite *heroNumBg;
CCLabelTTF *numLabel;
};
class SoulLayer;
class SoulItem : public ContentLayer
{
public:
HeroProfile hProfile;
SoulLayer* soulLayer;
bool init(HeroProfile hProfile, int num, bool isNew);
void onChange(CCObject* target);
void update();
virtual void onSingleClick(CCTouch* touch);
virtual void onLongClick(CCTouch* touch);
static SoulItem *create(HeroProfile hProfile, int num, bool isNew)
{
SoulItem *o = new SoulItem();
if(o && o->init(hProfile, num, isNew)){
o->autorelease();
return o;
}
return NULL;
};
private:
HeroIcon* heroImg;
int ghostsNum;
CCScale9Sprite* numBar;
CCLabelBMFont* numLabel;
CCSprite* btnSpr;
};
class SoulLayer : public ContentLayer
{
public:
virtual bool init();
virtual void onEnter();
virtual void onExit();
void makeItems(std::vector<std::pair<int , int>> souls);
void initSouls();
void onBack();
void onChangeSortType(cocos2d::CCObject* target);
void reOrder();
std::string getSortStr();
std::vector<std::pair<int , int>> getSoulsBySortType();
CREATE_FUNC(SoulLayer);
private:
ZqlScrollView* scrollView;
std::vector<HeroPtr> heroes;
CCLabelTTF* title;
std::vector<std::pair<int, int>> soulsVec;
std::vector<int> newSouls;
};
ccColor3B getColorOfBonus(int bonus);
std::string getColorStrOfBonus(int bonus);
class JiQiJuanZhou : public JuanZhou
{
public:
virtual bool init();
virtual void onSingleClick(CCTouch* touch);
virtual void onLongClick(CCTouch* touch);
virtual void setTouchEnabled(bool val);
void updateMsg();
void playSuccessAnim();
void playFailAnim();
CREATE_FUNC(JiQiJuanZhou);
private:
CCLabelTTF* skillName;
CCLabelTTF* skillDes;
CCRichLabelTTF* orgGasNum;
CCRichLabelTTF* desGasNum;
CCLabelTTF* gasTotal;
CCLabelTTF* goldTotal;
CCRichLabelTTF* sucProb;
CCLabelBMFont* gasRange;
CCLabelBMFont* gasCost;
CCLabelBMFont* goldCost;
ButtonSprite* gasBtn;
ButtonSprite* goldBtn;
ButtonSprite* btn;
bool isUseGas;
void selectPayChanel(bool isGas);
void swtichSortType();
};
class JiQiBoard : public HeroBoard
{
public:
virtual bool init();
virtual void refresh(const std::vector<PH::Hero *>& heroVec);
virtual void reOrder(const std::vector<PH::Hero *>& heroVec);
CREATE_FUNC(JiQiBoard);
};
class JiQiLayer : public ContentLayer
{
public:
HeroBoard* board;
virtual bool init();
virtual void onEnterAnimationDone();
virtual void onSingleClick(CCTouch* touch);
virtual void onLongClick(CCTouch* touch);
void choose(Hero* h);
CREATE_FUNC(JiQiLayer);
private:
JiQiJuanZhou* juanzhou;
CCLabelTTF* title;
JuanZhouLayer* jz;
ZqlScrollView* scrollView;
Hero* chosenHero;
void onTitleClick();
void onBack();
};
class XiaKe : public ContentLayer
{
public:
virtual bool init();
virtual void setTouchEnabled(bool value);
virtual void onEnter();
virtual void onEnterAnimationDone();
virtual void ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
virtual void ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
virtual void ccTouchesEnded(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
static XiaKe* create()
{
XiaKe* o = new XiaKe();
if(o != NULL && o->init())
{
o->autorelease();
return o;
}
CC_SAFE_DELETE(o);
return NULL;
}
protected:
void disableAllButtons()
{
for(int i=0; i<items.size(); i++)
items[i]->setTag(0);
}
void enableAllButtons()
{
for(int i=0; i<items.size(); i++)
items[i]->setTag(1);
}
private:
std::vector<CCSprite*> items;
bool isClick;
CCLabelBMFont* heroesNum;
ZqlScrollView* scrollView;
CCSprite* biandui;
CCSprite* qianghua;
CCSprite* zhuansheng;
CCSprite* chushou;
CCSprite* xiake;
CCSprite* relChange;
CCSprite* hunpo;
CCSprite* jiqi;
};
}