添加开始游戏两秒等待

This commit is contained in:
aozhiwei 2020-02-28 16:44:20 +08:00
parent f1997b657a
commit 537cd919f6
4 changed files with 21 additions and 1 deletions

View File

@ -90,6 +90,9 @@ void AndroidAI::ChangeToState(AndroidState_e to_state)
void AndroidAI::DoMove() void AndroidAI::DoMove()
{ {
Human* hum = (Human*)owner; Human* hum = (Human*)owner;
if (hum->room->waiting_start) {
return;
}
if (a8::HasBitFlag(hum->status, HS_Fly)) { if (a8::HasBitFlag(hum->status, HS_Fly)) {
return; return;
} }
@ -114,6 +117,9 @@ void AndroidAI::DoMove()
void AndroidAI::DoAttack() void AndroidAI::DoAttack()
{ {
Human* hum = (Human*)owner; Human* hum = (Human*)owner;
if (hum->room->waiting_start) {
return;
}
if (a8::HasBitFlag(hum->status, HS_Fly) || if (a8::HasBitFlag(hum->status, HS_Fly) ||
a8::HasBitFlag(hum->status, HS_Jump)) { a8::HasBitFlag(hum->status, HS_Jump)) {
return; return;

View File

@ -101,7 +101,9 @@ void Player::UpdateMove()
if (action_type == AT_Relive) { if (action_type == AT_Relive) {
CancelAction(); CancelAction();
} }
if (dead || a8::HasBitFlag(status, HS_Fly)) { if (dead ||
room->waiting_start ||
a8::HasBitFlag(status, HS_Fly)) {
moving = false; moving = false;
moved_frames = 0; moved_frames = 0;
last_collision_door = nullptr; last_collision_door = nullptr;
@ -131,6 +133,7 @@ void Player::UpdateMove()
void Player::UpdateShot() void Player::UpdateShot()
{ {
if (dead || if (dead ||
room->waiting_start ||
a8::HasBitFlag(status, HS_Fly) || a8::HasBitFlag(status, HS_Fly) ||
a8::HasBitFlag(status, HS_Jump) ) { a8::HasBitFlag(status, HS_Jump) ) {
shot_start = false; shot_start = false;

View File

@ -1610,4 +1610,14 @@ void Room::NotifyGameStart()
for (auto& pair : accountid_hash_) { for (auto& pair : accountid_hash_) {
pair.second->SendNotifyMsg(msg); pair.second->SendNotifyMsg(msg);
} }
waiting_start = true;
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 2,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
room->waiting_start = false;
},
&xtimer_attacher.timer_list_);
} }

View File

@ -49,6 +49,7 @@ public:
long long pending_request = 0; long long pending_request = 0;
long long last_debugout_tick = 0; long long last_debugout_tick = 0;
a8::Vec2 last_player_jump_pos; a8::Vec2 last_player_jump_pos;
bool waiting_start = false;
~Room(); ~Room();
void Init(); void Init();