1
This commit is contained in:
parent
2884fdc92a
commit
0c9671ac5c
@ -32,14 +32,14 @@ void BoxDrop::UnInit()
|
|||||||
|
|
||||||
void BoxDrop::OnHeroDeadDrop(Hero* hero)
|
void BoxDrop::OnHeroDeadDrop(Hero* hero)
|
||||||
{
|
{
|
||||||
if (box_num_ > 0) {
|
if (GetRemainNum() > 0) {
|
||||||
Drop(1, hero->GetPos().ToGlmVec3());
|
Drop(1, hero->GetPos().ToGlmVec3());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoxDrop::OnObstacleDeadDrop(Obstacle* ob)
|
void BoxDrop::OnObstacleDeadDrop(Obstacle* ob)
|
||||||
{
|
{
|
||||||
if (box_num_ > 0) {
|
if (GetRemainNum() > 0) {
|
||||||
Drop(1, ob->GetPos().ToGlmVec3());
|
Drop(1, ob->GetPos().ToGlmVec3());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,3 +153,8 @@ void BoxDrop::RequestReturnBoxNum()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BoxDrop::GetRemainNum()
|
||||||
|
{
|
||||||
|
return std::max(0, alloc_box_num_ - used_num_);
|
||||||
|
}
|
||||||
|
@ -20,11 +20,12 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
|
|||||||
|
|
||||||
void Drop(int num, const glm::vec3& center);
|
void Drop(int num, const glm::vec3& center);
|
||||||
void RequestAllocBoxNum();
|
void RequestAllocBoxNum();
|
||||||
|
int GetRemainNum();
|
||||||
|
|
||||||
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 used_num_ = 0;
|
||||||
int alloc_box_num_ = 0;
|
int alloc_box_num_ = 0;
|
||||||
bool returned_ = false;
|
bool returned_ = false;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user