1
This commit is contained in:
parent
b586ab8ec9
commit
f9cc27e85c
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <a8/mutable_xobject.h>
|
#include <a8/mutable_xobject.h>
|
||||||
|
|
||||||
|
#include <f8/app.h>
|
||||||
#include <f8/udplog.h>
|
#include <f8/udplog.h>
|
||||||
|
|
||||||
#include "boxdrop.h"
|
#include "boxdrop.h"
|
||||||
@ -22,19 +23,6 @@ BoxDrop::BoxDrop(Room* room):room_(room)
|
|||||||
|
|
||||||
void BoxDrop::Init()
|
void BoxDrop::Init()
|
||||||
{
|
{
|
||||||
if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) {
|
|
||||||
get_box_num_timer_ = room_->xtimer.SetTimeoutWpEx
|
|
||||||
(SERVER_FRAME_RATE * 10,
|
|
||||||
[this] (int event, const a8::Args* args)
|
|
||||||
{
|
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
|
||||||
if (!room_->IsGameOver() && !room_->GetVictoryTeam()) {
|
|
||||||
RequestBoxNum();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
&room_->xtimer_attacher_);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoxDrop::UnInit()
|
void BoxDrop::UnInit()
|
||||||
@ -66,34 +54,30 @@ void BoxDrop::Drop(int num, const glm::vec3& center)
|
|||||||
|
|
||||||
void BoxDrop::OnBattleStart()
|
void BoxDrop::OnBattleStart()
|
||||||
{
|
{
|
||||||
|
if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) {
|
||||||
|
get_box_num_timer_ = room_->xtimer.SetTimeoutWpEx
|
||||||
|
(SERVER_FRAME_RATE * 10,
|
||||||
|
[this] (int event, const a8::Args* args)
|
||||||
|
{
|
||||||
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
|
if (!room_->IsGameOver() && !room_->GetVictoryTeam()) {
|
||||||
|
RequestAllocBoxNum();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&room_->xtimer_attacher_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoxDrop::RequestBoxNum()
|
void BoxDrop::RequestAllocBoxNum()
|
||||||
{
|
{
|
||||||
std::string url;
|
std::string url;
|
||||||
JsonDataMgr::Instance()->GetApiUrl(url);
|
JsonDataMgr::Instance()->GetApiUrl(url);
|
||||||
/*
|
int nowtime = f8::App::Instance()->GetNowTime();
|
||||||
if (custom_room_type == CUSTOM_ROOM_CUSTOM) {
|
|
||||||
if (url.find('?') != std::string::npos) {
|
|
||||||
url += "&c=Battle&a=getCustomBattleDataNew";
|
|
||||||
} else {
|
|
||||||
url += "?&c=Battle&a=getCustomBattleDataNew";
|
|
||||||
}
|
|
||||||
} else if (custom_room_type == CUSTOM_ROOM_NORMAL) {
|
|
||||||
if (url.find('?') != std::string::npos) {
|
|
||||||
url += "&c=Battle&a=getNormalBattleData";
|
|
||||||
} else {
|
|
||||||
url += "?&c=Battle&a=getNormalBattleData";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
A8_ABORT();
|
|
||||||
}*/
|
|
||||||
auto url_params = a8::MutableXObject::CreateObject();
|
auto url_params = a8::MutableXObject::CreateObject();
|
||||||
//url_params->SetVal("account_id", join_msg->account_id());
|
url_params->SetVal("c", "Battle");
|
||||||
//url_params->SetVal("session_id", join_msg->session_id());
|
url_params->SetVal("a", "requestBoxNum");
|
||||||
url_params->SetVal("version", 1);
|
url_params->SetVal("timestamp", a8::XValue(nowtime));
|
||||||
//url_params->SetVal("__POST", join_msg->payload_data());
|
|
||||||
HttpProxy::Instance()->HttpGet
|
HttpProxy::Instance()->HttpGet
|
||||||
(
|
(
|
||||||
[]
|
[]
|
||||||
@ -123,3 +107,8 @@ void BoxDrop::RequestBoxNum()
|
|||||||
*url_params
|
*url_params
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BoxDrop::RequestReturnBoxNum()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -14,14 +14,17 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
|
|||||||
void OnBattleStart();
|
void OnBattleStart();
|
||||||
void OnHeroDeadDrop(Hero* hero);
|
void OnHeroDeadDrop(Hero* hero);
|
||||||
void OnObstacleDeadDrop(Obstacle* ob);
|
void OnObstacleDeadDrop(Obstacle* ob);
|
||||||
|
void RequestReturnBoxNum();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void Drop(int num, const glm::vec3& center);
|
void Drop(int num, const glm::vec3& center);
|
||||||
void RequestBoxNum();
|
void RequestAllocBoxNum();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Room* room_ = nullptr;
|
Room* room_ = nullptr;
|
||||||
a8::XTimerWp get_box_num_timer_;
|
a8::XTimerWp get_box_num_timer_;
|
||||||
int box_num_ = 0;
|
int box_num_ = 0;
|
||||||
|
int alloc_box_num_ = 0;
|
||||||
|
bool returned_ = false;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user