This commit is contained in:
aozhiwei 2020-07-23 15:07:33 +08:00
parent 6ff76243b9
commit f55179f4b2
4 changed files with 35 additions and 0 deletions

View File

@ -1824,6 +1824,18 @@ void Human::_UpdateMove(int speed)
#endif #endif
} }
void Human::ChangeToRace(RaceType_e race, int level)
{
if (race != kHumanRace ||
race != kZombieRace) {
abort();
}
race_ = race;
level_ = level;
room->frame_event.AddRaceChg(this);
room->frame_event.AddLevelChg(this);
}
void Human::_InternalUpdateMove(float speed) void Human::_InternalUpdateMove(float speed)
{ {
float nx = move_dir.x * speed; float nx = move_dir.x * speed;

View File

@ -280,6 +280,7 @@ class Human : public MoveableEntity
ObjectSyncFlags* GetObjectSyncFlags(int obj_uniid); ObjectSyncFlags* GetObjectSyncFlags(int obj_uniid);
void _UpdateMove(int speed); void _UpdateMove(int speed);
RaceType_e GetRace() { return race_; } RaceType_e GetRace() { return race_; }
void ChangeToRace(RaceType_e race, int level);
protected: protected:
void _InternalUpdateMove(float speed); void _InternalUpdateMove(float speed);

View File

@ -1780,6 +1780,9 @@ void Room::NotifyGameStart()
if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) { if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) {
NewBieRoomStart(); NewBieRoomStart();
} }
if (GetRoomMode() == kZombieMode) {
ZombieModeStart();
}
InitAndroidAI(); InitAndroidAI();
} }
@ -2644,6 +2647,24 @@ void Room::NewBieRoomStart()
} }
} }
void Room::ZombieModeStart()
{
if (GetRoomMode() != kZombieMode) {
if (human_hash_.size() != GetRoomMaxPlayerNum()) {
abort();
}
std::vector<Human*> human_list;
for (auto& pair : human_hash_) {
human_list.push_back(pair.second);
}
std::random_shuffle(human_list.begin(), human_list.end());
for (size_t i = 0; i < 2; ++i) {
Human* hum = human_list[i];
hum->ChangeToRace(kZombieRace, 1);
}
}
}
Human* Room::GetOneCanEnableAndroid() Human* Room::GetOneCanEnableAndroid()
{ {
std::vector<Human*> humans; std::vector<Human*> humans;

View File

@ -195,6 +195,7 @@ private:
void CombineTeamBornPoint(); void CombineTeamBornPoint();
void ForceSetBornPoint(Human* hum, BornPoint* born_point); void ForceSetBornPoint(Human* hum, BornPoint* born_point);
void NewBieRoomStart(); void NewBieRoomStart();
void ZombieModeStart();
void CreateLevel0RoomSpecThings(); void CreateLevel0RoomSpecThings();
bool CanAddToScene(Human* hum); bool CanAddToScene(Human* hum);
void SyncFrameData(); void SyncFrameData();