This commit is contained in:
aozhiwei 2024-01-30 11:44:38 +08:00
parent 397ad07d32
commit 7c3102e52f

View File

@ -165,18 +165,36 @@ void Room::Init()
} }
}, },
&xtimer_attacher_); &xtimer_attacher_);
if (mt::Param::s().moba_towers.size() != 2) {
xtimer.SetIntervalWpEx xtimer.SetIntervalWpEx
(SERVER_FRAME_RATE * mt::Param::s().moba_tower_interval, (SERVER_FRAME_RATE * mt::Param::s().moba_tower_interval,
[this] (int event, const a8::Args* args) [this] (int event, const a8::Args* args)
{ {
if (a8::TIMER_EXEC_EVENT == event) { if (a8::TIMER_EXEC_EVENT == event) {
if (!IsGameOver() && !GetVictoryTeam()) { if (!IsGameOver() && !GetVictoryTeam()) {
for (size_t i = 0; i < 2; ++i) {
Team* team = GetMobaTeamA();
if (i == 1) {
team = GetMobaTeamB();
}
auto tuple = mt::Param::s().moba_towers.at(i);
team->TraverseMembers
(
[&tuple] (Human* hum) -> bool
{
float distance = hum->GetPos().Distance2D2(std::get<0>(tuple));
if (distance < std::get<1>(tuple)) {
} }
return true;
});
}
}
} }
}, },
&xtimer_attacher_); &xtimer_attacher_);
} }
}
ob_ = std::make_shared<RoomOb>(this); ob_ = std::make_shared<RoomOb>(this);
ob_->Init(); ob_->Init();
} }