• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修訂55583373d66028d4627aeee5ed5b41d066963fa9 (tree)
時間2012-10-29 23:25:10
作者h2so5 <h2so5@git....>
Commiterh2so5

Log Message

ワープ先座標の指定機能を追加
同じチャンネルネル内でのワープに対応

Change Summary

差異

--- a/client/3d/FieldPlayer.cpp
+++ b/client/3d/FieldPlayer.cpp
@@ -142,19 +142,23 @@ void FieldPlayer::Draw() const
142142 // DrawLine3D(current_stat_.pos, current_stat_.pos + VGet(0, 0, 2 * (*stage_)->map_scale()), GetColor(0, 0, 255));
143143 }
144144
145-void FieldPlayer::Init(tstring model_name)
145+void FieldPlayer::Init(tstring model_name, const std::shared_ptr<VECTOR>& init_position)
146146 {
147147 LoadModel(model_name);
148- ResetPosition();
148+ ResetPosition(init_position);
149149 }
150150
151-void FieldPlayer::ResetPosition()
151+void FieldPlayer::ResetPosition(const std::shared_ptr<VECTOR>& init_position)
152152 {
153- const auto& points = (*stage_)->start_points();
154- std::mt19937 engine(time(nullptr));
155- std::uniform_int_distribution<int> distribution(0, points.size() - 1);
153+ if (init_position) {
154+ current_stat_.pos = *init_position;
155+ } else {
156+ const auto& points = (*stage_)->start_points();
157+ std::mt19937 engine(time(nullptr));
158+ std::uniform_int_distribution<int> distribution(0, points.size() - 1);
159+ current_stat_.pos = points[distribution(engine)];
160+ }
156161
157- current_stat_.pos = points[distribution(engine)];
158162 current_stat_.pos.y = (*stage_)->GetFloorY(current_stat_.pos + VGet(0, 20, 0), current_stat_.pos - VGet(0, 20, 0));
159163 }
160164
--- a/client/3d/FieldPlayer.hpp
+++ b/client/3d/FieldPlayer.hpp
@@ -53,8 +53,8 @@ public:
5353
5454 void Draw() const;
5555 void Update();
56- void Init(tstring model_path);
57- void ResetPosition();
56+ void Init(tstring model_path, const std::shared_ptr<VECTOR>& init_position);
57+ void ResetPosition(const std::shared_ptr<VECTOR>& init_position);
5858 void RescuePosition();
5959
6060 void LoadModel(const tstring& name);
--- a/client/3d/Stage.cpp
+++ b/client/3d/Stage.cpp
@@ -41,7 +41,7 @@ Stage::Stage(const ChannelPtr& channel,const ConfigManagerPtr &config_manager) :
4141 BOOST_FOREACH(const auto& warp_point, channel_->warp_points) {
4242 auto handle = ResourceManager::LoadModelFromName(_T("warpobj:ワープオブジェクト"));
4343 float scale = handle.property().get<float>("scale", 80.0);
44- MV1SetPosition(handle.handle(), VGet(warp_point.x, warp_point.y, warp_point.z));
44+ MV1SetPosition(handle.handle(), warp_point.position);
4545 MV1SetScale(handle.handle(), VGet(scale, scale, scale));
4646 warpobj_handles_.push_back(handle);
4747 }
--- a/client/CommandManager.cpp
+++ b/client/CommandManager.cpp
@@ -113,7 +113,16 @@ void CommandManager::FetchCommand(const network::Command& command)
113113 auto x = warp_point.second.get<float>("position.x", 0);
114114 auto y = warp_point.second.get<float>("position.y", 0);
115115 auto z = warp_point.second.get<float>("position.z", 0);
116- Channel::WarpPoint point = {x, y, z, channel, ""};
116+
117+ std::shared_ptr<VECTOR> destination;
118+ if (!warp_point.second.get_child("destination", ptree()).empty()) {
119+ auto dest_x = warp_point.second.get<float>("destination.x", 0);
120+ auto dest_y = warp_point.second.get<float>("destination.y", 0);
121+ auto dest_z = warp_point.second.get<float>("destination.z", 0);
122+ destination = std::make_shared<VECTOR>(VGet(dest_x, dest_y, dest_z));
123+ }
124+ Channel::WarpPoint point = {VGet(x, y, z), channel, "", destination};
125+
117126 ptr->warp_points.push_back(point);
118127 }
119128 channels_[id] = ptr;
--- a/client/CommandManager.hpp
+++ b/client/CommandManager.hpp
@@ -15,9 +15,10 @@ namespace network {
1515 struct Channel {
1616 public:
1717 struct WarpPoint {
18- float x, y, z;
18+ VECTOR position;
1919 unsigned int channel;
2020 std::string name;
21+ std::shared_ptr<VECTOR> destination;
2122 };
2223
2324 public:
--- a/client/scene/ChannelChange.cpp
+++ b/client/scene/ChannelChange.cpp
@@ -5,12 +5,16 @@
55 #include "MainLoop.hpp"
66 #include "ChannelChange.hpp"
77 #include "../CommandManager.hpp"
8+#include "../AccountManager.hpp"
89 #include "../../common/Logger.hpp"
910 #include "../../common/network/Utils.hpp"
1011 #include "../3d/Stage.hpp"
1112
1213 namespace scene {
13-ChannelChange::ChannelChange(unsigned char channel, const ManagerAccessorPtr& manager_accessor) :
14+ChannelChange::ChannelChange(
15+ unsigned char channel,
16+ const std::shared_ptr<VECTOR>& init_position,
17+ const ManagerAccessorPtr& manager_accessor) :
1418 manager_accessor_(manager_accessor),
1519 card_manager_(manager_accessor->card_manager().lock()),
1620 command_manager_(manager_accessor->command_manager().lock()),
@@ -18,7 +22,8 @@ ChannelChange::ChannelChange(unsigned char channel, const ManagerAccessorPtr& ma
1822 config_manager_(manager_accessor->config_manager().lock()),
1923 player_manager_(manager_accessor->player_manager().lock()),
2024 channel_(channel),
21- fade_counter_(0)
25+ fade_counter_(0),
26+ init_position_(init_position)
2227 {
2328
2429 }
@@ -54,6 +59,10 @@ void ChannelChange::Update()
5459 world_manager_ = std::make_shared<WorldManager>(stage, manager_accessor_);
5560 manager_accessor_->set_world_manager(world_manager_);
5661
62+ player_manager_->Init();
63+ world_manager_->Init();
64+ world_manager_->myself()->Init(unicode::ToTString(account_manager_->model_name()), init_position_);
65+
5766 next_scene_ = std::make_shared<scene::MainLoop>(manager_accessor_);
5867 }
5968 }
--- a/client/scene/ChannelChange.hpp
+++ b/client/scene/ChannelChange.hpp
@@ -13,7 +13,10 @@ namespace scene {
1313 class ChannelChange : public Base{
1414
1515 public:
16- ChannelChange(unsigned char channel, const ManagerAccessorPtr&);
16+ ChannelChange(
17+ unsigned char channel,
18+ const std::shared_ptr<VECTOR>& destination,
19+ const ManagerAccessorPtr&);
1720 ~ChannelChange();
1821 void Begin();
1922 void Update();
@@ -32,6 +35,7 @@ class ChannelChange : public Base{
3235
3336 unsigned char channel_;
3437 int fade_counter_;
38+ std::shared_ptr<VECTOR> init_position_;
3539 };
3640
3741 }
\ No newline at end of file
--- a/client/scene/Connect.cpp
+++ b/client/scene/Connect.cpp
@@ -104,7 +104,7 @@ void Connect::Update()
104104 message_.Update();
105105
106106 if (command_manager_->status() == CommandManager::STATUS_READY) {
107- next_scene_= std::make_shared<scene::ChannelChange>(0, manager_accessor_);
107+ next_scene_= std::make_shared<scene::ChannelChange>(0, std::shared_ptr<VECTOR>(), manager_accessor_);
108108 } else if (return_flag_) {
109109 next_scene_= std::make_shared<scene::Title>(manager_accessor_);
110110 }
--- a/client/scene/MainLoop.cpp
+++ b/client/scene/MainLoop.cpp
@@ -50,11 +50,6 @@ MainLoop::MainLoop(const ManagerAccessorPtr& manager_accessor) :
5050
5151 window_manager_->RestorePosition();
5252
53- player_manager_->Init();
54- world_manager_->Init();
55-
56- world_manager_->myself()->Init(unicode::ToTString(account_manager_->model_name()));
57-
5853 socket_server_manager_->Start();
5954
6055 }
@@ -120,12 +115,24 @@ void MainLoop::ProcessInput(InputManager* input)
120115
121116 if (const auto& channel = command_manager_->current_channel()) {
122117 BOOST_FOREACH(const auto& warp_point, channel->warp_points) {
123- auto point = VGet(warp_point.x, warp_point.y + 30, warp_point.z);
118+ auto point = warp_point.position;
119+ point.y += 30;
124120 const auto& pos = player_manager_->GetMyself()->position();
125121
126- auto distance = VSize(VGet(warp_point.x - pos.x, warp_point.y - pos.y, warp_point.z - pos.z));
122+ auto distance = VSize(warp_point.position - VGet(pos.x, pos.y, pos.z));
127123 if (distance < 50 && input->GetKeyCount(KEY_INPUT_M) == 1) {
128- next_scene_ = std::make_shared<scene::ChannelChange>(warp_point.channel, manager_accessor_);
124+
125+ // 同一チャンネルの場合は移動するだけ
126+ if (player_manager_->GetMyself()->channel() == warp_point.channel) {
127+ if (warp_point.destination) {
128+ world_manager_->myself()->ResetPosition(warp_point.destination);
129+ }
130+ } else {
131+ next_scene_ = std::make_shared<scene::ChannelChange>(
132+ warp_point.channel,
133+ warp_point.destination,
134+ manager_accessor_);
135+ }
129136 }
130137 }
131138 }
@@ -164,10 +171,11 @@ void MainLoop::Draw()
164171
165172 if (const auto& channel = command_manager_->current_channel()) {
166173 BOOST_FOREACH(const auto& warp_point, channel->warp_points) {
167- auto point = VGet(warp_point.x, warp_point.y + 30, warp_point.z);
174+ auto point = warp_point.position;
175+ point.y += 30;
168176 const auto& pos = player_manager_->GetMyself()->position();
169-
170- auto distance = VSize(VGet(warp_point.x - pos.x, warp_point.y - pos.y, warp_point.z - pos.z));
177+
178+ auto distance = VSize(warp_point.position - VGet(pos.x, pos.y, pos.z));
171179
172180 if (world_manager_->stage()->IsVisiblePoint(point)) {
173181 auto screen_pos = ConvWorldPosToScreenPos(point);