Revisión | f48dd7814a1416b5dbc6b025c4e8d527c7012615 (tree) |
---|---|
Tiempo | 2012-10-10 19:42:19 |
Autor | h2so5 <h2so5@git....> |
Commiter | h2so5 |
チャンネル機能を仮実装
@@ -26,7 +26,7 @@ inline bool NearlyEqualRelative(const T& lhs, const T& rhs, const U& ratio) | ||
26 | 26 | |
27 | 27 | } // namespace |
28 | 28 | |
29 | -FieldPlayer::FieldPlayer(CharacterDataProvider& data_provider, const StagePtr& stage, const TimerPtr& timer) | |
29 | +FieldPlayer::FieldPlayer(CharacterDataProvider& data_provider, const std::shared_ptr<const StagePtr>& stage, const TimerPtr& timer) | |
30 | 30 | : prev_stat_(), |
31 | 31 | current_stat_(PlayerStatus( VGet(0, 0, 0), VGet(0, 0, 0), VGet(0, 0, 0), |
32 | 32 | 0.0f, 0.0f, 0, 0, 1.0f, false)), |
@@ -55,8 +55,8 @@ void FieldPlayer::Chara_ShadowRender() const | ||
55 | 55 | MV1_COLL_RESULT_POLY *HitRes ; |
56 | 56 | VERTEX3D Vertex[ 3 ] ; |
57 | 57 | VECTOR SlideVec ; |
58 | - auto shadow_height = model_height_*stage_->map_scale(); | |
59 | - auto shadow_size = shadow_size_ * stage_->map_scale(); | |
58 | + auto shadow_height = model_height_ * (*stage_)->map_scale(); | |
59 | + auto shadow_size = shadow_size_ * (*stage_)->map_scale(); | |
60 | 60 | |
61 | 61 | // ライティングを無効にする |
62 | 62 | SetUseLighting( FALSE ) ; |
@@ -68,7 +68,7 @@ void FieldPlayer::Chara_ShadowRender() const | ||
68 | 68 | SetTextureAddressMode( DX_TEXADDRESS_CLAMP ) ; |
69 | 69 | |
70 | 70 | // キャラクターの直下に存在する地面のポリゴンを取得 |
71 | - HitResDim = MV1CollCheck_Capsule( stage_->map_handle().handle() , -1, VAdd( current_stat_.pos, VGet( 0, 0.5f * shadow_height, 0 ) ), VAdd( current_stat_.pos, VGet( 0.0f,-shadow_height, 0.0f ) ), shadow_size ) ; | |
71 | + HitResDim = MV1CollCheck_Capsule( (*stage_)->map_handle().handle() , -1, VAdd( current_stat_.pos, VGet( 0, 0.5f * shadow_height, 0 ) ), VAdd( current_stat_.pos, VGet( 0.0f,-shadow_height, 0.0f ) ), shadow_size ) ; | |
72 | 72 | |
73 | 73 | // 頂点データで変化が無い部分をセット |
74 | 74 | Vertex[ 0 ].dif = GetColorU8( 255,255,255,255 ) ; |
@@ -137,9 +137,9 @@ void FieldPlayer::Draw() const | ||
137 | 137 | MV1DrawModel(model_handle_.handle()); |
138 | 138 | Chara_ShadowRender(); |
139 | 139 | |
140 | - // DrawLine3D(current_stat_.pos, current_stat_.pos + VGet(2 * stage_->map_scale(), 0, 0), GetColor(255, 0, 0)); | |
141 | - // DrawLine3D(current_stat_.pos, current_stat_.pos + VGet(0, 2 * stage_->map_scale(), 0), GetColor(0, 255, 0)); | |
142 | - // DrawLine3D(current_stat_.pos, current_stat_.pos + VGet(0, 0, 2 * stage_->map_scale()), GetColor(0, 0, 255)); | |
140 | + // DrawLine3D(current_stat_.pos, current_stat_.pos + VGet(2 * (*stage_)->map_scale(), 0, 0), GetColor(255, 0, 0)); | |
141 | + // DrawLine3D(current_stat_.pos, current_stat_.pos + VGet(0, 2 * (*stage_)->map_scale(), 0), GetColor(0, 255, 0)); | |
142 | + // DrawLine3D(current_stat_.pos, current_stat_.pos + VGet(0, 0, 2 * (*stage_)->map_scale()), GetColor(0, 0, 255)); | |
143 | 143 | } |
144 | 144 | |
145 | 145 | void FieldPlayer::Init(tstring model_name) |
@@ -150,17 +150,17 @@ void FieldPlayer::Init(tstring model_name) | ||
150 | 150 | |
151 | 151 | void FieldPlayer::ResetPosition() |
152 | 152 | { |
153 | - const auto& points = stage_->start_points(); | |
153 | + const auto& points = (*stage_)->start_points(); | |
154 | 154 | std::mt19937 engine(time(nullptr)); |
155 | 155 | std::uniform_int_distribution<int> distribution(0, points.size() - 1); |
156 | 156 | |
157 | 157 | current_stat_.pos = points[distribution(engine)]; |
158 | - current_stat_.pos.y = stage_->GetFloorY(current_stat_.pos + VGet(0, 20, 0), current_stat_.pos - VGet(0, 20, 0)); | |
158 | + current_stat_.pos.y = (*stage_)->GetFloorY(current_stat_.pos + VGet(0, 20, 0), current_stat_.pos - VGet(0, 20, 0)); | |
159 | 159 | } |
160 | 160 | |
161 | 161 | void FieldPlayer::RescuePosition() |
162 | 162 | { |
163 | - const auto& points = stage_->start_points(); | |
163 | + const auto& points = (*stage_)->start_points(); | |
164 | 164 | const auto& new_pos = |
165 | 165 | std::min_element(points.begin(), points.end(), |
166 | 166 | [this](const VECTOR& a, const VECTOR& b){ |
@@ -173,7 +173,7 @@ void FieldPlayer::RescuePosition() | ||
173 | 173 | }); |
174 | 174 | |
175 | 175 | current_stat_.pos = *new_pos; |
176 | - current_stat_.pos.y = stage_->GetFloorY(current_stat_.pos - VGet(0, 100, 0), current_stat_.pos + VGet(0, 100, 0)); | |
176 | + current_stat_.pos.y = (*stage_)->GetFloorY(current_stat_.pos - VGet(0, 100, 0), current_stat_.pos + VGet(0, 100, 0)); | |
177 | 177 | current_stat_.acc.y = 0; |
178 | 178 | current_stat_.vel.y = 0; |
179 | 179 | } |
@@ -226,7 +226,7 @@ void FieldPlayer::Update() | ||
226 | 226 | } |
227 | 227 | |
228 | 228 | // 落ちた時に強制復帰 |
229 | - if (prev_stat_.pos.y < stage_->min_height()) { | |
229 | + if (prev_stat_.pos.y < (*stage_)->min_height()) { | |
230 | 230 | RescuePosition(); |
231 | 231 | } |
232 | 232 | /* |
@@ -267,7 +267,7 @@ void FieldPlayer::Update() | ||
267 | 267 | data_provider_.set_motion(current_stat_.motion); |
268 | 268 | data_provider_.set_vy(current_stat_.vel.y); |
269 | 269 | |
270 | - stage_->UpdateSkymapPosition(GetCameraTarget()); | |
270 | + (*stage_)->UpdateSkymapPosition(GetCameraTarget()); | |
271 | 271 | } |
272 | 272 | |
273 | 273 | void FieldPlayer::Move() |
@@ -306,8 +306,8 @@ void FieldPlayer::Move() | ||
306 | 306 | |
307 | 307 | |
308 | 308 | // 移動方向に障害物があるか、または床がない場合は移動不可能 |
309 | - auto front_collides = stage_->FrontCollides( | |
310 | - 0.4, current_stat_.pos, prev_stat_.pos,1.0 * stage_->map_scale(), (model_height_ - 0.1) * stage_->map_scale() ,128); | |
309 | + auto front_collides = (*stage_)->FrontCollides( | |
310 | + 0.4, current_stat_.pos, prev_stat_.pos,1.0 * (*stage_)->map_scale(), (model_height_ - 0.1) * (*stage_)->map_scale() ,128); | |
311 | 311 | |
312 | 312 | if(front_collides.first && current_stat_.acc.y == 0) |
313 | 313 | { |
@@ -320,7 +320,7 @@ void FieldPlayer::Move() | ||
320 | 320 | current_stat_.vel.x = current_stat_.vel.z = 0; |
321 | 321 | } |
322 | 322 | // 50mの深さまで床検出 |
323 | - auto floor_exists = stage_->FloorExists(current_stat_.pos, model_height_, 50); | |
323 | + auto floor_exists = (*stage_)->FloorExists(current_stat_.pos, model_height_, 50); | |
324 | 324 | if(!floor_exists.first) |
325 | 325 | { |
326 | 326 | current_stat_.pos.x = front_collides.second.x; |
@@ -329,7 +329,7 @@ void FieldPlayer::Move() | ||
329 | 329 | } |
330 | 330 | |
331 | 331 | // 足が地面にめり込んでいるか |
332 | - auto foot_floor_exists = stage_->FloorExists(current_stat_.pos, model_height_, 0); | |
332 | + auto foot_floor_exists = (*stage_)->FloorExists(current_stat_.pos, model_height_, 0); | |
333 | 333 | |
334 | 334 | const auto pos_diff = current_stat_.pos - prev_stat_.pos; |
335 | 335 | const auto pos_diff_length = VSize(pos_diff); |
@@ -352,7 +352,7 @@ void FieldPlayer::Move() | ||
352 | 352 | // 接地点計算 |
353 | 353 | //std::cout << " ground collision check: current pos = " << current_stat_.pos << std::endl; |
354 | 354 | |
355 | - auto coll_info = MV1CollCheck_Line(stage_->map_handle().handle(), -1, | |
355 | + auto coll_info = MV1CollCheck_Line((*stage_)->map_handle().handle(), -1, | |
356 | 356 | current_stat_.pos + VGet(0, y_max_limit, 0), |
357 | 357 | current_stat_.pos + VGet(0, y_min_limit, 0)); |
358 | 358 | if (coll_info.HitFlag && NearlyEqualRelative(coll_info.HitPosition.y, floor_exists.second.y, 0.001)) |
@@ -372,9 +372,9 @@ void FieldPlayer::Move() | ||
372 | 372 | if (floor_exists.second.y < current_stat_.pos.y) |
373 | 373 | { |
374 | 374 | // 床はあるし、自分より低い位置なので落ちる |
375 | - current_stat_.acc.y = -9.8 * stage_->map_scale(); | |
375 | + current_stat_.acc.y = -9.8 * (*stage_)->map_scale(); | |
376 | 376 | } |
377 | - else if (floor_exists.second.y < current_stat_.pos.y + 0.6 * stage_->map_scale()) | |
377 | + else if (floor_exists.second.y < current_stat_.pos.y + 0.6 * (*stage_)->map_scale()) | |
378 | 378 | { |
379 | 379 | // 床があり、平らなので登る |
380 | 380 | auto delta = prev_stat_.pos - current_stat_.pos; |
@@ -432,8 +432,8 @@ void FieldPlayer::Move() | ||
432 | 432 | // 上昇している |
433 | 433 | // std::cout << " previous rising" << std::endl; |
434 | 434 | |
435 | - const auto player_top = VGet(0, model_height_ * stage_->map_scale(), 0); | |
436 | - auto coll_info = MV1CollCheck_Line(stage_->map_handle().handle(), -1, | |
435 | + const auto player_top = VGet(0, model_height_ * (*stage_)->map_scale(), 0); | |
436 | + auto coll_info = MV1CollCheck_Line((*stage_)->map_handle().handle(), -1, | |
437 | 437 | prev_stat_.pos + player_top, |
438 | 438 | current_stat_.pos + player_top); |
439 | 439 | if (coll_info.HitFlag) |
@@ -477,10 +477,10 @@ void FieldPlayer::InputFromUser() | ||
477 | 477 | : 90.0f) * DX_PI_F / 180; |
478 | 478 | |
479 | 479 | /* |
480 | - auto warp_chk = stage_->CheckWarpPoint(current_stat_.pos); | |
480 | + auto warp_chk = (*stage_)->CheckWarpPoint(current_stat_.pos); | |
481 | 481 | if (warp_chk && input.GetKeyCount(InputManager::KEYBIND_ENTER) > 0 ) |
482 | 482 | { |
483 | - stage_->SetHostChangeFlag(warp_chk); | |
483 | + (*stage_)->SetHostChangeFlag(warp_chk); | |
484 | 484 | } |
485 | 485 | */ |
486 | 486 |
@@ -534,7 +534,7 @@ void FieldPlayer::InputFromUser() | ||
534 | 534 | { |
535 | 535 | // 接地しており、かつ移動する |
536 | 536 | any_move_ = true; |
537 | - current_stat_.vel = VGet(sin(roty), 0, cos(roty)) * (-move_dir * move_speed * stage_->map_scale()); | |
537 | + current_stat_.vel = VGet(sin(roty), 0, cos(roty)) * (-move_dir * move_speed * (*stage_)->map_scale()); | |
538 | 538 | current_stat_.motion = |
539 | 539 | current_stat_.is_walking ? motion.walk_ : motion.run_; |
540 | 540 | } |
@@ -543,19 +543,19 @@ void FieldPlayer::InputFromUser() | ||
543 | 543 | // 空中にいる |
544 | 544 | any_move_ = true; |
545 | 545 | auto acc = 5.0f; |
546 | - auto vel = current_stat_.vel + VGet(sin(roty), 0, cos(roty)) * (-move_dir * acc * stage_->map_scale());// * timer_->DeltaSec());// * ((6.0f-current_stat_.vel.y)/(stage_->map_scale()*12.0f)) | |
546 | + auto vel = current_stat_.vel + VGet(sin(roty), 0, cos(roty)) * (-move_dir * acc * (*stage_)->map_scale());// * timer_->DeltaSec());// * ((6.0f-current_stat_.vel.y)/((*stage_)->map_scale()*12.0f)) | |
547 | 547 | vel.y = 0; |
548 | 548 | |
549 | - if (VSize(vel) > std::max(move_speed, 1.0f) * stage_->map_scale()) | |
549 | + if (VSize(vel) > std::max(move_speed, 1.0f) * (*stage_)->map_scale()) | |
550 | 550 | { |
551 | - vel = vel * (std::max(move_speed, 1.0f) * stage_->map_scale() / VSize(vel)); | |
551 | + vel = vel * (std::max(move_speed, 1.0f) * (*stage_)->map_scale() / VSize(vel)); | |
552 | 552 | } |
553 | 553 | vel.y = current_stat_.vel.y; |
554 | 554 | current_stat_.vel = vel; |
555 | 555 | current_stat_.acc.y = |
556 | - (current_stat_.acc.y + (0.2f * chg_acc * stage_->map_scale())) > -6.5f * stage_->map_scale() ? -6.5f * stage_->map_scale() : | |
557 | - current_stat_.acc.y + (0.2f * chg_acc * stage_->map_scale()) < -11.0f * stage_->map_scale() ? -11.0f * stage_->map_scale() : | |
558 | - current_stat_.acc.y + (0.2f * chg_acc * stage_->map_scale()); | |
556 | + (current_stat_.acc.y + (0.2f * chg_acc * (*stage_)->map_scale())) > -6.5f * (*stage_)->map_scale() ? -6.5f * (*stage_)->map_scale() : | |
557 | + current_stat_.acc.y + (0.2f * chg_acc * (*stage_)->map_scale()) < -11.0f * (*stage_)->map_scale() ? -11.0f * (*stage_)->map_scale() : | |
558 | + current_stat_.acc.y + (0.2f * chg_acc * (*stage_)->map_scale()); | |
559 | 559 | } |
560 | 560 | else |
561 | 561 | { |
@@ -596,8 +596,8 @@ void FieldPlayer::InputFromUser() | ||
596 | 596 | input.GetGamepadCount(InputManager::PADBIND_JUMP) > 0)) |
597 | 597 | { |
598 | 598 | any_move_ = true; |
599 | - current_stat_.acc.y = -9.8 * stage_->map_scale(); | |
600 | - current_stat_.vel += VGet(0, jump_height_ * stage_->map_scale(), 0); | |
599 | + current_stat_.acc.y = -9.8 * (*stage_)->map_scale(); | |
600 | + current_stat_.vel += VGet(0, jump_height_ * (*stage_)->map_scale(), 0); | |
601 | 601 | } |
602 | 602 | } |
603 | 603 |
@@ -24,7 +24,7 @@ inline bool NearlyEqualRelative(const T& lhs, const T& rhs, const U& ratio) | ||
24 | 24 | class PlayerCharacter::Impl |
25 | 25 | { |
26 | 26 | public: |
27 | - Impl(CharacterDataProvider& data_provider, const StagePtr& stage, const TimerPtr& timer) | |
27 | + Impl(CharacterDataProvider& data_provider, const std::shared_ptr<const StagePtr>& stage, const TimerPtr& timer) | |
28 | 28 | : data_provider_(data_provider), |
29 | 29 | model_handle_(-1), |
30 | 30 | current_target_pos_(VGet(0, 1000, 0)), |
@@ -67,8 +67,8 @@ public: | ||
67 | 67 | MV1_COLL_RESULT_POLY *HitRes ; |
68 | 68 | VERTEX3D Vertex[ 3 ] ; |
69 | 69 | VECTOR SlideVec ; |
70 | - auto shadow_height = model_height_*stage_->map_scale(); | |
71 | - auto shadow_size = shadow_size_ * stage_->map_scale(); | |
70 | + auto shadow_height = model_height_ * (*stage_)->map_scale(); | |
71 | + auto shadow_size = shadow_size_ * (*stage_)->map_scale(); | |
72 | 72 | |
73 | 73 | // ライティングを無効にする |
74 | 74 | SetUseLighting( FALSE ) ; |
@@ -80,7 +80,7 @@ public: | ||
80 | 80 | SetTextureAddressMode( DX_TEXADDRESS_CLAMP ) ; |
81 | 81 | |
82 | 82 | // キャラクターの直下に存在する地面のポリゴンを取得 |
83 | - HitResDim = MV1CollCheck_Capsule( stage_->map_handle().handle(), -1, VAdd( current_pos_, VGet( 0.0f, 0.5f * shadow_height, 0.0f ) ), VAdd( current_pos_, VGet( 0.0f, -shadow_height, 0.0f ) ), shadow_size ) ; | |
83 | + HitResDim = MV1CollCheck_Capsule((*stage_)->map_handle().handle(), -1, VAdd( current_pos_, VGet( 0.0f, 0.5f * shadow_height, 0.0f ) ), VAdd( current_pos_, VGet( 0.0f, -shadow_height, 0.0f ) ), shadow_size ) ; | |
84 | 84 | |
85 | 85 | // 頂点データで変化が無い部分をセット |
86 | 86 | Vertex[ 0 ].dif = GetColorU8( 255,255,255,255 ) ; |
@@ -206,7 +206,7 @@ public: | ||
206 | 206 | |
207 | 207 | /* |
208 | 208 | const auto jump_result_y = |
209 | - jump_height_ * stage_->map_scale() * (time_entire - time_now) * (jump_height_ / 5.0f) * 1.019952f + | |
209 | + jump_height_ * (*stage_)->map_scale() * (time_entire - time_now) * (jump_height_ / 5.0f) * 1.019952f + | |
210 | 210 | 0.5f * -9.8f * (time_entire - time_now) * (time_entire - time_now) * (1.0f / flight_duration_ideal_) * (jump_height_ / 5.0f) * (jump_height_ / 5.0f); // 今からジャンプした際の最終的な位置 |
211 | 211 | */ |
212 | 212 | static auto st_acc = -9.8f; |
@@ -215,12 +215,12 @@ public: | ||
215 | 215 | |
216 | 216 | if(jump_flag_ == false && current_target_vec_y_ != 0){ |
217 | 217 | for(acc;acc < -6.5f;acc+=0.1f){ |
218 | - prediction_vector = jump_height_ * stage_->map_scale() + (acc) * (time_entire - time_now) * (jump_height_ / 5.0f) * (1.0f / flight_duration_ideal_ ); | |
218 | + prediction_vector = jump_height_ * (*stage_)->map_scale() + (acc) * (time_entire - time_now) * (jump_height_ / 5.0f) * (1.0f / flight_duration_ideal_ ); | |
219 | 219 | // ターゲット座標ではジャンプを始めている |
220 | 220 | if( prediction_vector > current_target_vec_y_ - 1 && prediction_vector < current_target_vec_y_ + 1) |
221 | 221 | { |
222 | 222 | // 目標座標でベクトルが上向きなら一致、ジャンプを始める |
223 | - move_vec_y_ = jump_height_ * stage_->map_scale(); | |
223 | + move_vec_y_ = jump_height_ * (*stage_)->map_scale(); | |
224 | 224 | jump_flag_ = true; |
225 | 225 | }// それ以外はそのまま |
226 | 226 | } |
@@ -231,7 +231,7 @@ public: | ||
231 | 231 | moved_pos = current_pos_ + diff_pos; |
232 | 232 | if( jump_flag_ == true ) |
233 | 233 | { |
234 | - move_vec_y_ += (st_acc * stage_->map_scale() * timer_->DeltaSec() * (1.0f/flight_duration_ideal_) * (jump_height_ / 5.0f)); | |
234 | + move_vec_y_ += (st_acc * (*stage_)->map_scale() * timer_->DeltaSec() * (1.0f/flight_duration_ideal_) * (jump_height_ / 5.0f)); | |
235 | 235 | moved_pos.y = current_pos_.y + move_vec_y_ * timer_->DeltaSec() * (jump_height_ / 5.0f); |
236 | 236 | } |
237 | 237 |
@@ -239,7 +239,7 @@ public: | ||
239 | 239 | float floor_y; |
240 | 240 | std::pair<bool, VECTOR> floor_coll; |
241 | 241 | // 足で接地検査 |
242 | - floor_coll = stage_->FloorExists(moved_pos,model_height_,0); | |
242 | + floor_coll = (*stage_)->FloorExists(moved_pos,model_height_,0); | |
243 | 243 | //moved_pos.y = std::max(moved_pos.y, floor_y); // 床にあたっているときは床の方がyが高くなる |
244 | 244 | if(!jump_flag_){ |
245 | 245 | // 登ったり下ったりできる段差の大きさの制限を求める |
@@ -251,7 +251,7 @@ public: | ||
251 | 251 | // 接地点計算 |
252 | 252 | //std::cout << " ground collision check: current pos = " << current_stat_.pos << std::endl; |
253 | 253 | |
254 | - auto coll_info = MV1CollCheck_Line(stage_->map_handle().handle(), -1, | |
254 | + auto coll_info = MV1CollCheck_Line((*stage_)->map_handle().handle(), -1, | |
255 | 255 | moved_pos + VGet(0, y_max_limit, 0), |
256 | 256 | moved_pos + VGet(0, y_min_limit, 0)); |
257 | 257 | if(coll_info.HitFlag && NearlyEqualRelative(coll_info.HitPosition.y, floor_coll.second.y, 0.001)){ |
@@ -264,7 +264,7 @@ public: | ||
264 | 264 | moved_pos = current_pos_ + VSize(diff_pos) * VNorm(diff); |
265 | 265 | } |
266 | 266 | } |
267 | - auto floor_exists = stage_->FloorExists(moved_pos, model_height_, 50); | |
267 | + auto floor_exists = (*stage_)->FloorExists(moved_pos, model_height_, 50); | |
268 | 268 | if( floor_exists.first ) |
269 | 269 | { |
270 | 270 | if( floor_exists.second.y < moved_pos.y && current_target_pos.y < moved_pos.y) |
@@ -290,8 +290,8 @@ public: | ||
290 | 290 | }else{ |
291 | 291 | // 上昇している |
292 | 292 | |
293 | - const auto player_top = VGet(0, model_height_ * stage_->map_scale(), 0); | |
294 | - auto coll_info = MV1CollCheck_Line(stage_->map_handle().handle(), -1, | |
293 | + const auto player_top = VGet(0, model_height_ * (*stage_)->map_scale(), 0); | |
294 | + auto coll_info = MV1CollCheck_Line((*stage_)->map_handle().handle(), -1, | |
295 | 295 | current_pos_ + player_top, |
296 | 296 | moved_pos + player_top); |
297 | 297 | if (coll_info.HitFlag) |
@@ -300,7 +300,7 @@ public: | ||
300 | 300 | // std::cout << " current collided to ceiling" << std::endl; |
301 | 301 | |
302 | 302 | moved_pos = coll_info.HitPosition - player_top; |
303 | - move_vec_y_ = -(move_vec_y_ - (st_acc * stage_->map_scale() * timer_->DeltaSec() * (1.0f/flight_duration_ideal_) * (jump_height_ / 5.0f))) * 1.0; // 反射 | |
303 | + move_vec_y_ = -(move_vec_y_ - (st_acc * (*stage_)->map_scale() * timer_->DeltaSec() * (1.0f/flight_duration_ideal_) * (jump_height_ / 5.0f))) * 1.0; // 反射 | |
304 | 304 | } |
305 | 305 | } |
306 | 306 | } |
@@ -373,7 +373,7 @@ private: | ||
373 | 373 | std::unique_ptr<MotionPlayer> motion_player_; |
374 | 374 | std::pair<bool, int> additional_motion_; |
375 | 375 | TimerPtr timer_; |
376 | - StagePtr stage_; | |
376 | + std::shared_ptr<const StagePtr> stage_; | |
377 | 377 | int shadow_handle_; |
378 | 378 | float shadow_size_; |
379 | 379 | bool jump_end_; |
@@ -383,7 +383,8 @@ private: | ||
383 | 383 | } motion; |
384 | 384 | }; |
385 | 385 | |
386 | -PlayerCharacter::PlayerCharacter(CharacterDataProvider& data_provider, const StagePtr& stage, const TimerPtr& timer) | |
386 | +PlayerCharacter::PlayerCharacter(CharacterDataProvider& data_provider, | |
387 | + const std::shared_ptr<const StagePtr>& stage, const TimerPtr& timer) | |
387 | 388 | : impl_(new Impl(data_provider, stage, timer)) |
388 | 389 | {} |
389 | 390 |
@@ -10,7 +10,7 @@ | ||
10 | 10 | class PlayerCharacter : public Character |
11 | 11 | { |
12 | 12 | public: |
13 | - PlayerCharacter(CharacterDataProvider& data_provider, const StagePtr& stage, const TimerPtr& timer); | |
13 | + PlayerCharacter(CharacterDataProvider& data_provider, const std::shared_ptr<const StagePtr>& stage, const TimerPtr& timer); | |
14 | 14 | virtual ~PlayerCharacter(); |
15 | 15 | |
16 | 16 | void Draw() const; |
@@ -5,13 +5,15 @@ | ||
5 | 5 | #include "Stage.hpp" |
6 | 6 | #include "../../common/Logger.hpp" |
7 | 7 | #include "../Profiler.hpp" |
8 | +#include "../CommandManager.hpp" | |
8 | 9 | #include <string> |
9 | 10 | |
10 | -Stage::Stage(const tstring& model_name) : | |
11 | - map_handle_(ResourceManager::LoadModelFromName(model_name)), | |
11 | +Stage::Stage(const ChannelPtr& channel) : | |
12 | + map_handle_(ResourceManager::LoadModelFromName(unicode::ToTString(channel->stage))), | |
12 | 13 | map_scale_(map_handle_.property().get<float>("scale", 20.0)), |
13 | 14 | min_height_(map_handle_.property().get<float>("min_height", -200.0)), |
14 | - host_change_flag_(false) | |
15 | + host_change_flag_(false), | |
16 | + channel_(channel) | |
15 | 17 | { |
16 | 18 | MV1SetScale(map_handle_.handle(), VGet(map_scale_, map_scale_, map_scale_)); |
17 | 19 | MV1SetupCollInfo(map_handle_.handle(), -1, 128, 64, 128);// 元の数値は256,256,256 |
@@ -34,6 +36,15 @@ Stage::Stage(const tstring& model_name) : | ||
34 | 36 | draw_after_meshes_.insert(i); |
35 | 37 | } |
36 | 38 | } |
39 | + | |
40 | + BOOST_FOREACH(const auto& warp_point, channel_->warp_points) { | |
41 | + auto handle = ResourceManager::LoadModelFromName(_T("warpobj:ワープオブジェクト")); | |
42 | + float scale = handle.property().get<float>("scale", 80.0); | |
43 | + MV1SetPosition(handle.handle(), VGet(warp_point.x, warp_point.y, warp_point.z)); | |
44 | + MV1SetScale(handle.handle(), VGet(scale, scale, scale)); | |
45 | + warpobj_handles_.push_back(handle); | |
46 | + } | |
47 | + | |
37 | 48 | /* |
38 | 49 | auto warp_points_array = map_handle_.property().get_child("stage.warp_points", ptree()); |
39 | 50 | for (auto it = warp_points_array.begin(); it != warp_points_array.end(); ++it) { |
@@ -85,6 +96,10 @@ void Stage::Draw() | ||
85 | 96 | |
86 | 97 | MV1DrawModel(skymap_handle_.handle()); |
87 | 98 | |
99 | + BOOST_FOREACH(const auto& warp_point_handle, warpobj_handles_) { | |
100 | + MV1DrawModel(warp_point_handle.handle()); | |
101 | + } | |
102 | + | |
88 | 103 | /* |
89 | 104 | BOOST_FOREACH(auto warp_handle,warpobj_array_) |
90 | 105 | { |
@@ -11,9 +11,12 @@ | ||
11 | 11 | #include "../ResourceManager.hpp" |
12 | 12 | #include "../ui/InputBox.hpp" |
13 | 13 | |
14 | +struct Channel; | |
15 | +typedef std::shared_ptr<Channel> ChannelPtr; | |
16 | + | |
14 | 17 | class Stage { |
15 | 18 | public: |
16 | - Stage(const tstring& model_path); | |
19 | + Stage(const ChannelPtr& channel); | |
17 | 20 | ~Stage(); |
18 | 21 | void Draw(); |
19 | 22 | void DrawAfter(); |
@@ -50,13 +53,13 @@ class Stage { | ||
50 | 53 | std::unordered_set<int> draw_after_meshes_; |
51 | 54 | |
52 | 55 | ModelHandle skymap_handle_; |
53 | - ModelHandle warpobj_handle_; | |
54 | - std::vector<ModelHandle> warpobj_array_; | |
56 | + std::vector<ModelHandle> warpobj_handles_; | |
55 | 57 | |
56 | 58 | std::vector<VECTOR> start_points_; |
57 | 59 | std::vector<VECTOR> warp_points_; |
58 | 60 | |
59 | 61 | bool host_change_flag_; |
62 | + ChannelPtr channel_; | |
60 | 63 | }; |
61 | 64 | |
62 | 65 | typedef std::shared_ptr<Stage> StagePtr; |
@@ -76,12 +76,12 @@ void CommandManager::FetchCommand(const network::Command& command) | ||
76 | 76 | // サーバーデータ受信 |
77 | 77 | case ClientReceiveServerInfo: |
78 | 78 | { |
79 | - network::Utils::Deserialize(command.body(), & stage_); | |
80 | - if (ResourceManager::NameToFullPath(unicode::ToTString(stage_)).empty()) { | |
81 | - status_ = STATUS_ERROR_NOSTAGE; | |
82 | - } else { | |
83 | - status_ = STATUS_READY; | |
84 | - } | |
79 | + //network::Utils::Deserialize(command.body(), & stage_); | |
80 | + //if (ResourceManager::NameToFullPath(unicode::ToTString(stage_)).empty()) { | |
81 | + // status_ = STATUS_ERROR_NOSTAGE; | |
82 | + //} else { | |
83 | + // status_ = STATUS_READY; | |
84 | + //} | |
85 | 85 | } |
86 | 86 | break; |
87 | 87 |
@@ -101,6 +101,47 @@ void CommandManager::FetchCommand(const network::Command& command) | ||
101 | 101 | } |
102 | 102 | |
103 | 103 | auto channels = pt.get_child("channels", ptree()); |
104 | + BOOST_FOREACH(const auto& channel, channels) { | |
105 | + auto ptr = std::make_shared<Channel>(); | |
106 | + auto id = boost::lexical_cast<int>(channel.first.substr(2)); | |
107 | + ptr->name = channel.second.get<std::string>("name"); | |
108 | + ptr->stage = channel.second.get<std::string>("stage"); | |
109 | + | |
110 | + auto warp_points = channel.second.get_child("warp_points", ptree()); | |
111 | + BOOST_FOREACH(const auto& warp_point, warp_points) { | |
112 | + auto channel = warp_point.second.get<unsigned char>("channel", 0); | |
113 | + auto x = warp_point.second.get<float>("position.x", 0); | |
114 | + auto y = warp_point.second.get<float>("position.y", 0); | |
115 | + auto z = warp_point.second.get<float>("position.z", 0); | |
116 | + Channel::WarpPoint point = {x, y, z, channel, ""}; | |
117 | + ptr->warp_points.push_back(point); | |
118 | + } | |
119 | + channels_[id] = ptr; | |
120 | + } | |
121 | + | |
122 | + // 存在しないチャンネルへのワープポイントを削除 | |
123 | + BOOST_FOREACH(const auto& channel, channels_) { | |
124 | + auto& warp_points = channel.second->warp_points; | |
125 | + auto end_it = std::remove_if(warp_points.begin(), | |
126 | + warp_points.end(), | |
127 | + [this](Channel::WarpPoint& point) -> bool { | |
128 | + auto it = channels_.find(point.channel); | |
129 | + if (it != channels_.end()) { | |
130 | + point.name = it->second->name; | |
131 | + return false; | |
132 | + } else { | |
133 | + return true; | |
134 | + } | |
135 | + }); | |
136 | + warp_points.erase(end_it, warp_points.end()); | |
137 | + } | |
138 | + | |
139 | + if (ResourceManager::NameToFullPath( | |
140 | + unicode::ToTString(channels_[0]->stage)).empty()) { | |
141 | + status_ = STATUS_ERROR_NOSTAGE; | |
142 | + } else { | |
143 | + status_ = STATUS_READY; | |
144 | + } | |
104 | 145 | } |
105 | 146 | break; |
106 | 147 |
@@ -210,11 +251,22 @@ CommandManager::Status CommandManager::status() const | ||
210 | 251 | return status_; |
211 | 252 | } |
212 | 253 | |
213 | -std::string CommandManager::stage() const | |
254 | +const std::map<unsigned char, ChannelPtr>& CommandManager::channels() const | |
214 | 255 | { |
215 | - return stage_; | |
256 | + return channels_; | |
216 | 257 | } |
217 | 258 | |
259 | +ChannelPtr CommandManager::current_channel() const | |
260 | +{ | |
261 | + PlayerManagerPtr player_manager = manager_accessor_->player_manager().lock(); | |
262 | + if (auto myself = player_manager->GetMyself()) { | |
263 | + return channels_.at(myself->channel()); | |
264 | + } else { | |
265 | + return ChannelPtr(); | |
266 | + } | |
267 | +} | |
268 | + | |
269 | + | |
218 | 270 | double CommandManager::GetReadByteAverage() const |
219 | 271 | { |
220 | 272 | if (client_) { |
@@ -12,6 +12,21 @@ namespace network { | ||
12 | 12 | class Command; |
13 | 13 | } |
14 | 14 | |
15 | +struct Channel { | |
16 | + public: | |
17 | + struct WarpPoint { | |
18 | + float x, y, z; | |
19 | + unsigned int channel; | |
20 | + std::string name; | |
21 | + }; | |
22 | + | |
23 | + public: | |
24 | + std::string name, stage; | |
25 | + std::vector<WarpPoint> warp_points; | |
26 | +}; | |
27 | + | |
28 | +typedef std::shared_ptr<Channel> ChannelPtr; | |
29 | + | |
15 | 30 | typedef std::unique_ptr<network::Client> ClientUniqPtr; |
16 | 31 | |
17 | 32 | class CommandManager { |
@@ -38,7 +53,8 @@ class CommandManager { | ||
38 | 53 | |
39 | 54 | void set_client(ClientUniqPtr client); |
40 | 55 | unsigned int user_id(); |
41 | - std::string stage() const; | |
56 | + const std::map<unsigned char, ChannelPtr>& channels() const; | |
57 | + ChannelPtr current_channel() const; | |
42 | 58 | |
43 | 59 | void FetchCommand(const network::Command& command); |
44 | 60 |
@@ -48,7 +64,8 @@ class CommandManager { | ||
48 | 64 | ManagerAccessorPtr manager_accessor_; |
49 | 65 | ClientUniqPtr client_; |
50 | 66 | Status status_; |
51 | - std::string stage_; | |
67 | + | |
68 | + std::map<unsigned char, ChannelPtr> channels_; | |
52 | 69 | }; |
53 | 70 | |
54 | 71 | typedef std::shared_ptr<CommandManager> CommandManagerPtr; |
@@ -15,6 +15,9 @@ class CharacterDataProvider; | ||
15 | 15 | class Timer; |
16 | 16 | typedef std::shared_ptr<Timer> TimerPtr; |
17 | 17 | |
18 | +class Stage; | |
19 | +typedef std::shared_ptr<Stage> StagePtr; | |
20 | + | |
18 | 21 | class InputManager; |
19 | 22 | |
20 | 23 | class PlayerManager : public std::enable_shared_from_this<PlayerManager> { |
@@ -51,6 +54,8 @@ class PlayerManager : public std::enable_shared_from_this<PlayerManager> { | ||
51 | 54 | std::shared_ptr<CharacterManager> charmgr_; |
52 | 55 | std::map<unsigned int, std::unique_ptr<CharacterDataProvider>> char_data_providers_; |
53 | 56 | |
57 | + const std::shared_ptr<StagePtr> stage_ptr_holder_; | |
58 | + | |
54 | 59 | int font_handle_; |
55 | 60 | std::array<int, 4> name_tip_image_handle_; |
56 | 61 |
@@ -9,12 +9,9 @@ | ||
9 | 9 | |
10 | 10 | class InputManager; |
11 | 11 | |
12 | -class Stage; | |
13 | -typedef std::shared_ptr<Stage> StagePtr; | |
14 | - | |
15 | 12 | class WorldManager { |
16 | 13 | public: |
17 | - WorldManager(const ManagerAccessorPtr& manager_accessor = ManagerAccessorPtr()); | |
14 | + WorldManager(const StagePtr& stage, const ManagerAccessorPtr& manager_accessor = ManagerAccessorPtr()); | |
18 | 15 | void Init(); |
19 | 16 | void ProcessInput(InputManager* input); |
20 | 17 | void Update(); |
@@ -0,0 +1,12 @@ | ||
1 | +{ | |
2 | + "name": "ケロリン町チャンネル", | |
3 | + "stage": "stage:ケロリン町", | |
4 | + "capacity": 20, | |
5 | + "warp_points": | |
6 | + [ | |
7 | + { | |
8 | + "position": {"x": 0, "y": 0, "z": 0}, | |
9 | + "channel": 1 | |
10 | + } | |
11 | + ] | |
12 | +} | |
\ No newline at end of file |
@@ -0,0 +1,12 @@ | ||
1 | +{ | |
2 | + "name": "ゲキド街チャンネル", | |
3 | + "stage": "stage:ゲキド街", | |
4 | + "capacity": 25, | |
5 | + "warp_points": | |
6 | + [ | |
7 | + { | |
8 | + "position": {"x": 0, "y": 0, "z": 0}, | |
9 | + "channel": 0 | |
10 | + } | |
11 | + ] | |
12 | +} | |
\ No newline at end of file |
@@ -0,0 +1,61 @@ | ||
1 | +// | |
2 | +// ChannelChange.cpp | |
3 | +// | |
4 | + | |
5 | +#include "MainLoop.hpp" | |
6 | +#include "ChannelChange.hpp" | |
7 | +#include "../../common/Logger.hpp" | |
8 | +#include "../../common/network/Utils.hpp" | |
9 | +#include "../3d/Stage.hpp" | |
10 | + | |
11 | +namespace scene { | |
12 | +ChannelChange::ChannelChange(unsigned char channel, const ManagerAccessorPtr& manager_accessor) : | |
13 | + manager_accessor_(manager_accessor), | |
14 | + card_manager_(manager_accessor->card_manager().lock()), | |
15 | + command_manager_(manager_accessor->command_manager().lock()), | |
16 | + account_manager_(manager_accessor->account_manager().lock()), | |
17 | + config_manager_(manager_accessor->config_manager().lock()), | |
18 | + player_manager_(manager_accessor->player_manager().lock()) | |
19 | +{ | |
20 | + | |
21 | + auto channel_str = (unsigned char)channel; | |
22 | + command_manager_->Write(network::ServerUpdateAccountProperty(CHANNEL, network::Utils::Serialize(channel_str))); | |
23 | + | |
24 | + auto channel_ptr = command_manager_->channels().at(channel); | |
25 | + StagePtr stage = std::make_shared<Stage>(channel_ptr); | |
26 | + world_manager_ = std::make_shared<WorldManager>(stage, manager_accessor); | |
27 | + manager_accessor_->set_world_manager(world_manager_); | |
28 | +} | |
29 | + | |
30 | +ChannelChange::~ChannelChange() | |
31 | +{ | |
32 | +} | |
33 | + | |
34 | +void ChannelChange::Begin() | |
35 | +{ | |
36 | + | |
37 | +} | |
38 | + | |
39 | +void ChannelChange::End() | |
40 | +{ | |
41 | +} | |
42 | + | |
43 | +void ChannelChange::Update() | |
44 | +{ | |
45 | + //if(world_manager_->stage()->host_change_flag()) | |
46 | + //{ | |
47 | + //account_manager_->set_host(world_manager_->stage()->host_change_flag().second); | |
48 | + next_scene_ = std::make_shared<scene::MainLoop>(manager_accessor_); | |
49 | + //} | |
50 | +} | |
51 | + | |
52 | +void ChannelChange::ProcessInput(InputManager* input) | |
53 | +{ | |
54 | + | |
55 | +} | |
56 | + | |
57 | +void ChannelChange::Draw() | |
58 | +{ | |
59 | +} | |
60 | + | |
61 | +} | |
\ No newline at end of file |
@@ -0,0 +1,34 @@ | ||
1 | +// | |
2 | +// ChannelChange.h | |
3 | +// | |
4 | + | |
5 | +#pragma once | |
6 | + | |
7 | +#include <memory> | |
8 | +#include "Base.hpp" | |
9 | +#include "../ManagerAccessor.hpp" | |
10 | + | |
11 | +namespace scene { | |
12 | + | |
13 | +class ChannelChange : public Base{ | |
14 | + | |
15 | + public: | |
16 | + ChannelChange(unsigned char channel, const ManagerAccessorPtr&); | |
17 | + ~ChannelChange(); | |
18 | + void Begin(); | |
19 | + void Update(); | |
20 | + void ProcessInput(InputManager*); | |
21 | + void Draw(); | |
22 | + void End(); | |
23 | + | |
24 | + private: | |
25 | + ManagerAccessorPtr manager_accessor_; | |
26 | + CardManagerPtr card_manager_; | |
27 | + CommandManagerPtr command_manager_; | |
28 | + AccountManagerPtr account_manager_; | |
29 | + ConfigManagerPtr config_manager_; | |
30 | + WorldManagerPtr world_manager_; | |
31 | + PlayerManagerPtr player_manager_; | |
32 | +}; | |
33 | + | |
34 | +} | |
\ No newline at end of file |
@@ -5,9 +5,11 @@ | ||
5 | 5 | #include "MainLoop.hpp" |
6 | 6 | #include "Title.hpp" |
7 | 7 | #include "Connect.hpp" |
8 | +#include "ChannelChange.hpp" | |
8 | 9 | #include <vector> |
9 | 10 | #include <algorithm> |
10 | 11 | #include "../ResourceManager.hpp" |
12 | +#include "../PlayerManager.hpp" | |
11 | 13 | #include "../../common/Logger.hpp" |
12 | 14 | |
13 | 15 | namespace scene { |
@@ -17,9 +19,11 @@ Connect::Connect(const ManagerAccessorPtr& manager_accessor) : | ||
17 | 19 | account_manager_(manager_accessor->account_manager().lock()), |
18 | 20 | config_manager_(manager_accessor->config_manager().lock()), |
19 | 21 | command_manager_(std::make_shared<CommandManager>(manager_accessor_)), |
22 | + player_manager_(std::make_shared<PlayerManager>(manager_accessor_)), | |
20 | 23 | return_flag_(false) |
21 | 24 | { |
22 | 25 | manager_accessor_->set_command_manager(command_manager_); |
26 | + manager_accessor_->set_player_manager(player_manager_); | |
23 | 27 | } |
24 | 28 | |
25 | 29 | Connect::~Connect() |
@@ -87,11 +91,11 @@ void Connect::Update() | ||
87 | 91 | message_.set_text(_T("エラー:サーバーとクライアントのバージョンが対応していません")); |
88 | 92 | command_manager_->set_client(ClientUniqPtr()); |
89 | 93 | break; |
90 | - case CommandManager::STATUS_ERROR_NOSTAGE: | |
91 | - message_.set_text((tformat(_T("エラー:接続するにはステージデータ「%s」が必要です")) % | |
92 | - unicode::ToTString(command_manager_->stage())).str()); | |
93 | - command_manager_->set_client(ClientUniqPtr()); | |
94 | - break; | |
94 | + //case CommandManager::STATUS_ERROR_NOSTAGE: | |
95 | + // message_.set_text((tformat(_T("エラー:接続するにはステージデータ「%s」が必要です")) % | |
96 | + // unicode::ToTString(command_manager_->stage())).str()); | |
97 | + // command_manager_->set_client(ClientUniqPtr()); | |
98 | + // break; | |
95 | 99 | } |
96 | 100 | |
97 | 101 | button_.Update(); |
@@ -99,7 +103,7 @@ void Connect::Update() | ||
99 | 103 | message_.Update(); |
100 | 104 | |
101 | 105 | if (command_manager_->status() == CommandManager::STATUS_READY) { |
102 | - next_scene_= std::make_shared<scene::MainLoop>(manager_accessor_); | |
106 | + next_scene_= std::make_shared<scene::ChannelChange>(0, manager_accessor_); | |
103 | 107 | } else if (return_flag_) { |
104 | 108 | next_scene_= std::make_shared<scene::Title>(manager_accessor_); |
105 | 109 | } |
@@ -32,6 +32,7 @@ class Connect : public Base { | ||
32 | 32 | AccountManagerPtr account_manager_; |
33 | 33 | ConfigManagerPtr config_manager_; |
34 | 34 | CommandManagerPtr command_manager_; |
35 | + PlayerManagerPtr player_manager_; | |
35 | 36 | |
36 | 37 | UILabel message_; |
37 | 38 | UILabel button_label_; |
@@ -7,3 +7,4 @@ | ||
7 | 7 | #include "Init.hpp" |
8 | 8 | #include "Title.hpp" |
9 | 9 | #include "MainLoop.hpp" |
10 | +#include "ChannelChange.hpp" |
@@ -5,6 +5,7 @@ | ||
5 | 5 | #include "MainLoop.hpp" |
6 | 6 | #include "Option.hpp" |
7 | 7 | #include "Dashboard.hpp" |
8 | +#include "ChannelChange.hpp" | |
8 | 9 | #include <vector> |
9 | 10 | #include <algorithm> |
10 | 11 | #include "../ResourceManager.hpp" |
@@ -17,10 +18,10 @@ | ||
17 | 18 | namespace scene { |
18 | 19 | MainLoop::MainLoop(const ManagerAccessorPtr& manager_accessor) : |
19 | 20 | manager_accessor_(manager_accessor), |
20 | - player_manager_(std::make_shared<PlayerManager>(manager_accessor_)), | |
21 | + player_manager_(manager_accessor->player_manager().lock()), | |
21 | 22 | card_manager_(manager_accessor->card_manager().lock()), |
22 | 23 | command_manager_(manager_accessor->command_manager().lock()), |
23 | - world_manager_(std::make_shared<WorldManager>(manager_accessor_)), | |
24 | + world_manager_(manager_accessor->world_manager().lock()), | |
24 | 25 | account_manager_(manager_accessor->account_manager().lock()), |
25 | 26 | config_manager_(manager_accessor->config_manager().lock()), |
26 | 27 | window_manager_(std::make_shared<WindowManager>(manager_accessor_)), |
@@ -29,8 +30,6 @@ MainLoop::MainLoop(const ManagerAccessorPtr& manager_accessor) : | ||
29 | 30 | snapshot_number_(0), |
30 | 31 | snapshot_(false) |
31 | 32 | { |
32 | - manager_accessor_->set_player_manager(player_manager_); | |
33 | - manager_accessor_->set_world_manager(world_manager_); | |
34 | 33 | manager_accessor_->set_window_manager(window_manager_); |
35 | 34 | |
36 | 35 | inputbox_->ReloadTabs(); |
@@ -98,6 +97,18 @@ void MainLoop::ProcessInput(InputManager* input) | ||
98 | 97 | snapshot_ = true; |
99 | 98 | } |
100 | 99 | |
100 | + if (const auto& channel = command_manager_->current_channel()) { | |
101 | + BOOST_FOREACH(const auto& warp_point, channel->warp_points) { | |
102 | + auto point = VGet(warp_point.x, warp_point.y + 30, warp_point.z); | |
103 | + const auto& pos = player_manager_->GetMyself()->position(); | |
104 | + | |
105 | + auto distance = VSize(VGet(warp_point.x - pos.x, warp_point.y - pos.y, warp_point.z - pos.z)); | |
106 | + if (distance < 50 && input->GetKeyCount(KEY_INPUT_M) == 1) { | |
107 | + next_scene_ = std::make_shared<scene::ChannelChange>(warp_point.channel, manager_accessor_); | |
108 | + } | |
109 | + } | |
110 | + } | |
111 | + | |
101 | 112 | } |
102 | 113 | |
103 | 114 | void MainLoop::Draw() |
@@ -129,6 +140,38 @@ void MainLoop::Draw() | ||
129 | 140 | snapshot_number_++; |
130 | 141 | snapshot_ = false; |
131 | 142 | } |
143 | + | |
144 | + if (const auto& channel = command_manager_->current_channel()) { | |
145 | + BOOST_FOREACH(const auto& warp_point, channel->warp_points) { | |
146 | + auto point = VGet(warp_point.x, warp_point.y + 30, warp_point.z); | |
147 | + const auto& pos = player_manager_->GetMyself()->position(); | |
148 | + | |
149 | + auto distance = VSize(VGet(warp_point.x - pos.x, warp_point.y - pos.y, warp_point.z - pos.z)); | |
150 | + | |
151 | + if (world_manager_->stage()->IsVisiblePoint(point)) { | |
152 | + auto screen_pos = ConvWorldPosToScreenPos(point); | |
153 | + int x = (screen_pos.x / 2) * 2; | |
154 | + int y = (screen_pos.y / 2) * 2 - 16; | |
155 | + | |
156 | + UILabel label_; | |
157 | + label_.set_width(160); | |
158 | + if (distance < 50) { | |
159 | + label_.set_text(unicode::ToTString(warp_point.name) + _T("\nMキーで転送します")); | |
160 | + label_.set_bgcolor(UIBase::Color(255,0,0,150)); | |
161 | + } else { | |
162 | + label_.set_text(unicode::ToTString(warp_point.name)); | |
163 | + label_.set_bgcolor(UIBase::Color(0,0,0,150)); | |
164 | + } | |
165 | + label_.set_textcolor(UIBase::Color(255,255,255,255)); | |
166 | + | |
167 | + label_.set_left(x - 60); | |
168 | + label_.set_top(y + 10); | |
169 | + | |
170 | + label_.Update(); | |
171 | + label_.Draw(); | |
172 | + } | |
173 | + } | |
174 | + } | |
132 | 175 | } |
133 | 176 | |
134 | 177 | void MainLoop::End() |
@@ -290,8 +290,10 @@ StatusTab::StatusTab(const ManagerAccessorPtr& manager_accessor) : | ||
290 | 290 | |
291 | 291 | items_.push_back(std::make_shared<TextItem>(_LT("option.status.channel"), |
292 | 292 | std::make_shared<std::function<tstring(void)>>( |
293 | - [player_manager](){ | |
294 | - return (tformat(_T("%d")) % static_cast<int>(player_manager->GetMyself()->channel())).str(); | |
293 | + [player_manager, command_manager]() -> tstring { | |
294 | + auto channel = player_manager->GetMyself()->channel(); | |
295 | + auto name = command_manager->channels().at(channel)->name; | |
296 | + return (tformat(_T("%s (%d)")) % unicode::ToTString(name) % static_cast<int>(channel)).str(); | |
295 | 297 | }), manager_accessor_)); |
296 | 298 | |
297 | 299 | items_.push_back(std::make_shared<TextItem>(_LT("option.status.user_id"), |
@@ -302,8 +304,10 @@ StatusTab::StatusTab(const ManagerAccessorPtr& manager_accessor) : | ||
302 | 304 | |
303 | 305 | items_.push_back(std::make_shared<TextItem>(_LT("option.status.stage"), |
304 | 306 | std::make_shared<std::function<tstring(void)>>( |
305 | - [command_manager](){ | |
306 | - return unicode::ToTString(command_manager->stage()); | |
307 | + [player_manager, command_manager]() -> tstring { | |
308 | + auto channel = player_manager->GetMyself()->channel(); | |
309 | + auto stage = command_manager->channels().at(channel)->stage; | |
310 | + return unicode::ToTString(stage); | |
307 | 311 | }), manager_accessor_)); |
308 | 312 | |
309 | 313 | items_.push_back(std::make_shared<TextItem>(_LT("option.status.position"), |