1
This commit is contained in:
parent
6525b795f5
commit
d24f428df0
@ -37,15 +37,17 @@ void BoxDrop::UnInit()
|
||||
|
||||
void BoxDrop::OnHeroDeadDrop(Hero* hero)
|
||||
{
|
||||
if (GetRemainNum() > 0) {
|
||||
Drop(1, hero->GetPos().ToGlmVec3());
|
||||
int box_num = GetAndDecObjBoxNum(hero->GetUniId());
|
||||
if (box_num > 0) {
|
||||
Drop(box_num, hero->GetPos().ToGlmVec3());
|
||||
}
|
||||
}
|
||||
|
||||
void BoxDrop::OnObstacleDeadDrop(Obstacle* ob)
|
||||
{
|
||||
if (GetRemainNum() > 0) {
|
||||
Drop(1, ob->GetPos().ToGlmVec3());
|
||||
int box_num = GetAndDecObjBoxNum(ob->GetUniId());
|
||||
if (box_num > 0) {
|
||||
Drop(box_num, ob->GetPos().ToGlmVec3());
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +154,7 @@ void BoxDrop::RequestReturnBoxNum()
|
||||
url_params->SetVal("a", "requestReturnBoxNum");
|
||||
url_params->SetVal("account_id", account_id);
|
||||
url_params->SetVal("session_id", session_id);
|
||||
url_params->SetVal("used_num", used_num_);
|
||||
url_params->SetVal("used_num", GetUsedBoxNum());
|
||||
url_params->SetVal("alloc_box_num", alloc_box_num_);
|
||||
HttpProxy::Instance()->HttpGet
|
||||
(
|
||||
@ -184,11 +186,6 @@ void BoxDrop::RequestReturnBoxNum()
|
||||
}
|
||||
}
|
||||
|
||||
int BoxDrop::GetRemainNum()
|
||||
{
|
||||
return std::max(0, alloc_box_num_ - used_num_);
|
||||
}
|
||||
|
||||
bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session_id)
|
||||
{
|
||||
bool ok = false;
|
||||
@ -269,4 +266,25 @@ void BoxDrop::AllocBoxToRoom()
|
||||
box_list.size()
|
||||
});
|
||||
#endif
|
||||
for (int i = 0; i < alloc_box_num_; ++i) {
|
||||
if (drop_hash_.size() < all_list.size()) {
|
||||
drop_hash_[all_list.at(i)->GetUniId()] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BoxDrop::GetAndDecObjBoxNum(int uniid)
|
||||
{
|
||||
auto itr = drop_hash_.find(uniid);
|
||||
if (itr != drop_hash_.end()) {
|
||||
int num = itr->second;
|
||||
itr->second = 0;
|
||||
return num;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BoxDrop::GetUsedBoxNum()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -20,16 +20,16 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
|
||||
|
||||
void Drop(int num, const glm::vec3& center);
|
||||
void RequestAllocBoxNum();
|
||||
int GetRemainNum();
|
||||
bool FillAccountIdSessionId(std::string account_id, std::string session_id);
|
||||
void OnAllocOk(int box_num);
|
||||
void OnAllocFail();
|
||||
void AllocBoxToRoom();
|
||||
int GetAndDecObjBoxNum(int uniid);
|
||||
int GetUsedBoxNum();
|
||||
|
||||
private:
|
||||
Room* room_ = nullptr;
|
||||
a8::XTimerWp get_box_num_timer_;
|
||||
int used_num_ = 0;
|
||||
int alloc_box_num_ = 0;
|
||||
bool alloced_ = false;
|
||||
bool returned_ = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user