优化syncframedata

This commit is contained in:
aozhiwei 2020-06-02 15:11:35 +08:00
parent 7dd91deffb
commit 5451528b08
5 changed files with 17 additions and 6 deletions

3
.gitignore vendored
View File

@ -21,4 +21,5 @@ __pycache__
.user
game.py
*.cxx
compile_commands.json
compile_commands.json
t

View File

@ -66,7 +66,8 @@ void AndroidAI::Update(int delta_time)
break;
case AS_attack:
{
if (state_elapsed_time < 1000) {
if ((state_elapsed_time < 3000 && last_target_) ||
(state_elapsed_time < 1100)) {
DoAttack();
} else {
int rnd = rand();
@ -151,6 +152,7 @@ void AndroidAI::DoAttack()
sender->Shot(shot_dir);
}
}
last_target_ = enemy;
}
}

View File

@ -28,4 +28,6 @@ private:
void DoMove();
void DoAttack();
private:
Human* last_target_ = nullptr;
};

View File

@ -117,10 +117,7 @@ void Room::Update(int delta_time)
pair.second->Update(50);
}
if (GetFrameNo() % 2 == 0) {
for (auto& pair : human_hash_) {
pair.second->SendUpdateMsg();
}
frame_event.Clear();
SyncFrameData();
}
++frameno_;
elapsed_time_ -= 50;
@ -2535,3 +2532,11 @@ bool Room::CanAddToScene(Human* hum)
}
return true;
}
void Room::SyncFrameData()
{
for (auto& pair : human_hash_) {
pair.second->SendUpdateMsg();
}
frame_event.Clear();
}

View File

@ -189,6 +189,7 @@ private:
void NewBieRoomStart();
void CreateLevel0RoomSpecThings();
bool CanAddToScene(Human* hum);
void SyncFrameData();
#ifdef DEBUG
void InitDebugInfo();