This commit is contained in:
aozhiwei 2024-07-30 19:48:35 +08:00
parent 2884fdc92a
commit 0c9671ac5c
2 changed files with 9 additions and 3 deletions

View File

@ -32,14 +32,14 @@ void BoxDrop::UnInit()
void BoxDrop::OnHeroDeadDrop(Hero* hero)
{
if (box_num_ > 0) {
if (GetRemainNum() > 0) {
Drop(1, hero->GetPos().ToGlmVec3());
}
}
void BoxDrop::OnObstacleDeadDrop(Obstacle* ob)
{
if (box_num_ > 0) {
if (GetRemainNum() > 0) {
Drop(1, ob->GetPos().ToGlmVec3());
}
}
@ -153,3 +153,8 @@ void BoxDrop::RequestReturnBoxNum()
);
}
}
int BoxDrop::GetRemainNum()
{
return std::max(0, alloc_box_num_ - used_num_);
}

View File

@ -20,11 +20,12 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
void Drop(int num, const glm::vec3& center);
void RequestAllocBoxNum();
int GetRemainNum();
private:
Room* room_ = nullptr;
a8::XTimerWp get_box_num_timer_;
int box_num_ = 0;
int used_num_ = 0;
int alloc_box_num_ = 0;
bool returned_ = false;
};