This commit is contained in:
aozhiwei 2024-07-30 15:48:51 +08:00
parent db1e076e51
commit d4beb8537a
3 changed files with 29 additions and 3 deletions

View File

@ -5,6 +5,8 @@
#include "hero.h"
#include "obstacle.h"
#include "mt/MapMode.h"
const int BOX_ID = 150001;
BoxDrop::BoxDrop(Room* room):room_(room)
@ -14,7 +16,18 @@ BoxDrop::BoxDrop(Room* room):room_(room)
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()) {
}
}
},
&room_->xtimer_attacher_);
}
}
void BoxDrop::UnInit()
@ -24,12 +37,16 @@ void BoxDrop::UnInit()
void BoxDrop::OnHeroDeadDrop(Hero* hero)
{
Drop(1, hero->GetPos().ToGlmVec3());
if (box_num_ > 0) {
Drop(1, hero->GetPos().ToGlmVec3());
}
}
void BoxDrop::OnObstacleDeadDrop(Obstacle* ob)
{
Drop(1, ob->GetPos().ToGlmVec3());
if (box_num_ > 0) {
Drop(1, ob->GetPos().ToGlmVec3());
}
}
void BoxDrop::Drop(int num, const glm::vec3& center)
@ -39,3 +56,8 @@ void BoxDrop::Drop(int num, const glm::vec3& center)
room_->CreateObstacle(BOX_ID, center.x, center.y, center.z);
}
}
void BoxDrop::OnBattleStart()
{
}

View File

@ -11,6 +11,7 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
BoxDrop(Room* room);
void Init();
void UnInit();
void OnBattleStart();
void OnHeroDeadDrop(Hero* hero);
void OnObstacleDeadDrop(Obstacle* ob);
@ -20,4 +21,6 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
private:
Room* room_ = nullptr;
a8::XTimerWp get_box_num_timer_;
int box_num_ = 0;
};

View File

@ -3216,6 +3216,7 @@ void Room::OnBattleStart()
}
battle_starting_ = false;
SendSMTeamFull(nullptr);
GetBoxDrop()->OnBattleStart();
}
bool Room::CanAddObstacle(const glm::vec3& pos, int obstacle_id)