11#pragma once
2- #include " BattleScene.h"
3- #include " Font.h"
2+ #include " BattleSceneAct.h"
43#include " Head.h"
5- #include " TextureManager.h"
64#include " UIKeyConfig.h"
75#include < deque>
86#include < unordered_map>
119// 每场战斗可以选择从4种武学中选择轻重
1210// 硬直,判定范围,威力,消耗体力,在不攻击的时候可以回复体力
1311
14- class BattleSceneHades : public BattleScene
12+ class BattleSceneHades : public BattleSceneAct
1513{
16- struct AttackEffect
17- {
18- Pointf Pos;
19- Pointf Velocity, Acceleration;
20- Role* Attacker = nullptr ; // 攻击者
21- std::map<Role*, int > Defender; // 每人只能被一个特效击中一次
22- Magic* UsingMagic = nullptr ;
23- Item* UsingHiddenWeapon = nullptr ;
24- int Frame = 0 ; // 当前帧数
25- int TotalFrame = 1 ; // 总帧数,当前帧数超过此值就移除此效果
26- int TotalEffectFrame = 1 ; // 效果总帧数
27- int OperationType = -1 ; // 攻击类型
28- std::string Path; // 效果贴图路径
29- Role* FollowRole = nullptr ; // 一直保持在角色身上
30- int Weaken = 0 ; // 弱化程度,减掉
31- double Strengthen = 1 ; // 强化程度,相乘
32- int Track = 0 ; // 是否追踪
33- int Through = 0 ; // 是否贯穿,即击中敌人后可以不消失
34- int NoHurt = 0 ; // 是否无伤害
35- void setEft (int num)
36- {
37- setPath (fmt1::format (" eft/eft{:03}" , num));
38- }
39- void setPath (const std::string& p)
40- {
41- Path = p;
42- TotalEffectFrame = TextureManager::getInstance ()->getTextureGroupCount (Path);
43- }
44- };
45-
46- struct TextEffect
47- {
48- Pointf Pos;
49- std::string Text;
50- int Size = 15 ;
51- int Frame = 0 ;
52- BP_Color Color;
53- int Type = 0 ; // 0-缓缓向上, 1-原地不动
54- void set (const std::string& text, BP_Color c, Role* r)
55- {
56- Text = text;
57- Color = c;
58- if (r)
59- {
60- Pos = r->Pos ;
61- Pos.x -= 7.5 * Font::getTextDrawSize (Text);
62- Pos.y -= 50 ;
63- }
64- }
65- };
66-
6714public:
6815 BattleSceneHades ();
6916 BattleSceneHades (int id);
7017 virtual ~BattleSceneHades ();
71- void setID (int id);
7218
7319 // 继承自基类的函数
7420 virtual void draw () override ;
7521 virtual void dealEvent (BP_Event& e) override ; // 战场主循环
7622 virtual void dealEvent2 (BP_Event& e) override ; // 用于停止自动
7723 virtual void onEntrance () override ;
7824 virtual void onExit () override ;
25+
7926 virtual void backRun () override {}
27+
8028 virtual void backRun1 ();
8129 void Action (Role* r);
8230 void AI (Role* r);
8331 virtual void onPressedCancel () override ;
8432
8533protected:
86- Pointf pos_; // 坐标为俯视,而非在画面的位置,其中y需除以2画在上面
87- double gravity_ = -4 ;
88- double friction_ = 0.1 ;
89-
90- UIKeyConfig::Keys keys_;
91-
92- std::deque<AttackEffect> attack_effects_;
93- std::deque<TextEffect> text_effects_;
94-
95- std::deque<Role*> enemies_;
96- std::deque<Role> enemies_obj_;
97-
98- std::vector<std::shared_ptr<Head>> heads_;
99- std::vector<std::shared_ptr<Head>> head_boss_;
100-
101- bool is_running_ = false ; // 主角是否在跑动
102- Role* role_ = nullptr ; // 主角
103- Role* dying_ = nullptr ;
104- int weapon_ = 1 ;
105- int frozen_ = 0 ;
106- int slow_ = 0 ;
107- int shake_ = 0 ;
108- int close_up_ = 0 ;
109-
11034 std::shared_ptr<Menu> menu_;
11135 std::vector<std::shared_ptr<Button>> button_magics_;
11236 std::shared_ptr<Button> button_item_;
11337 std::shared_ptr<TextBox> show_auto_;
11438
115- std::unordered_map<std::string, std::function<void (Role* r)>> special_magic_effect_every_frame_; // 每帧
116- std::unordered_map<std::string, std::function<void (Role* r)>> special_magic_effect_attack_; // 发动攻击
117- std::unordered_map<std::string, std::function<void (AttackEffect&, Role* r)>> special_magic_effect_beat_; // 被打中
118-
119- bool canWalk45 (int x, int y)
120- {
121- if (isOutLine (x, y) || isBuilding (x, y) || isWater (x, y))
122- {
123- return false ;
124- }
125- else
126- {
127- return true ;
128- }
129- }
130-
131- bool canWalk90 (int x, int y)
132- {
133- auto p = pos90To45 (x, y);
134- return canWalk45 (p.x , p.y );
135- }
136- bool canWalk90 (Pointf p, Role* r, int dis = -1 )
137- {
138- if (r->Pos .z > 1 ) { return true ; }
139- if (dis == -1 ) { dis = TILE_W; }
140- for (auto r1 : battle_roles_)
141- {
142- if (r1 == r || r1->Dead ) { continue ; }
143- double dis1 = EuclidDis (p, r1->Pos );
144- if (dis1 < dis)
145- {
146- double dis0 = EuclidDis (r->Pos , r1->Pos );
147- if (dis0 >= dis1) { return false ; }
148- }
149- }
150- auto p45 = pos90To45 (p.x , p.y );
151- return canWalk45 (p45.x , p45.y );
152- }
153- virtual bool canWalk (int x, int y) override { return canWalk45 (x, y); }
154-
15539 void renderExtraRoleInfo (Role* r, double x, double y);
15640 // int calHurt(Role* r0, Role* r1);
15741 virtual int checkResult () override ;
@@ -160,10 +44,7 @@ class BattleSceneHades : public BattleScene
16044 Role* findFarthestEnemy (int team, Pointf p);
16145 int calCast (int act_type, int operation_type, Role* r);
16246 int calCoolDown (int act_type, int operation_type, Role* r);
163- void decreaseToZero (int & i)
164- {
165- if (i > 0 ) { i--; }
166- }
47+
16748 void defaultMagicEffect (AttackEffect& ae, Role* r);
16849 virtual int calRolePic (Role* r, int style, int frame) override ;
16950
0 commit comments