优化syncframedata
This commit is contained in:
parent
7dd91deffb
commit
5451528b08
3
.gitignore
vendored
3
.gitignore
vendored
@ -21,4 +21,5 @@ __pycache__
|
|||||||
.user
|
.user
|
||||||
game.py
|
game.py
|
||||||
*.cxx
|
*.cxx
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
t
|
||||||
|
@ -66,7 +66,8 @@ void AndroidAI::Update(int delta_time)
|
|||||||
break;
|
break;
|
||||||
case AS_attack:
|
case AS_attack:
|
||||||
{
|
{
|
||||||
if (state_elapsed_time < 1000) {
|
if ((state_elapsed_time < 3000 && last_target_) ||
|
||||||
|
(state_elapsed_time < 1100)) {
|
||||||
DoAttack();
|
DoAttack();
|
||||||
} else {
|
} else {
|
||||||
int rnd = rand();
|
int rnd = rand();
|
||||||
@ -151,6 +152,7 @@ void AndroidAI::DoAttack()
|
|||||||
sender->Shot(shot_dir);
|
sender->Shot(shot_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
last_target_ = enemy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,4 +28,6 @@ private:
|
|||||||
void DoMove();
|
void DoMove();
|
||||||
void DoAttack();
|
void DoAttack();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Human* last_target_ = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -117,10 +117,7 @@ void Room::Update(int delta_time)
|
|||||||
pair.second->Update(50);
|
pair.second->Update(50);
|
||||||
}
|
}
|
||||||
if (GetFrameNo() % 2 == 0) {
|
if (GetFrameNo() % 2 == 0) {
|
||||||
for (auto& pair : human_hash_) {
|
SyncFrameData();
|
||||||
pair.second->SendUpdateMsg();
|
|
||||||
}
|
|
||||||
frame_event.Clear();
|
|
||||||
}
|
}
|
||||||
++frameno_;
|
++frameno_;
|
||||||
elapsed_time_ -= 50;
|
elapsed_time_ -= 50;
|
||||||
@ -2535,3 +2532,11 @@ bool Room::CanAddToScene(Human* hum)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::SyncFrameData()
|
||||||
|
{
|
||||||
|
for (auto& pair : human_hash_) {
|
||||||
|
pair.second->SendUpdateMsg();
|
||||||
|
}
|
||||||
|
frame_event.Clear();
|
||||||
|
}
|
||||||
|
@ -189,6 +189,7 @@ private:
|
|||||||
void NewBieRoomStart();
|
void NewBieRoomStart();
|
||||||
void CreateLevel0RoomSpecThings();
|
void CreateLevel0RoomSpecThings();
|
||||||
bool CanAddToScene(Human* hum);
|
bool CanAddToScene(Human* hum);
|
||||||
|
void SyncFrameData();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void InitDebugInfo();
|
void InitDebugInfo();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user