This commit is contained in:
aozhiwei 2020-07-24 14:08:19 +08:00
parent 44d5a9d6f3
commit 9e775fd0c1
4 changed files with 85 additions and 1 deletions

View File

@ -1888,6 +1888,57 @@ void Human::ChangeToRaceAndNotify(RaceType_e race, int level)
room->frame_event.AddLevelChg(this);
}
void Human::WinExp(Human* sender, int exp)
{
if (race_ != kHumanRace &&
race_ != kZombieRace) {
abort();
}
if (race_ == kHumanRace) {
exp_ += exp;
MetaData::Player* old_meta = meta;
do {
MetaData::Player* tmp_meta = MetaMgr::Instance()->GetPlayer
(
HUMAN_RACE_META_START_ID + level_
);
if (!tmp_meta) {
break;
}
if (exp_ >= tmp_meta->i->exp()) {
meta = tmp_meta;
++level_;
} else {
break;
}
} while(true);
if (old_meta != meta) {
room->frame_event.AddRaceChg(this);
}
} else if (race_ == kZombieRace) {
exp_ += exp;
MetaData::Player* old_meta = meta;
do {
MetaData::Player* tmp_meta = MetaMgr::Instance()->GetPlayer
(
ZOMBIE_RACE_META_START_ID + level_
);
if (!tmp_meta) {
break;
}
if (exp_ >= tmp_meta->i->exp()) {
meta = tmp_meta;
++level_;
} else {
break;
}
} while(true);
if (old_meta != meta) {
room->frame_event.AddRaceChg(this);
}
}
}
void Human::_InternalUpdateMove(float speed)
{
float nx = move_dir.x * speed;

View File

@ -282,6 +282,7 @@ class Human : public MoveableEntity
RaceType_e GetRace() { return race_; }
void ChangeToRace(RaceType_e race, int level);
void ChangeToRaceAndNotify(RaceType_e race, int level);
void WinExp(Human* sender, int exp);
protected:
void _InternalUpdateMove(float speed);

View File

@ -567,6 +567,17 @@ void Room::OnHumanDie(Human* hum)
} else {
abort();
}
for (auto& pair : human_hash_) {
if (pair.second != hum) {
pair.second->WinExp(hum, hum->meta->i->dead_exp());
}
}
{
Human* killer = GetPlayerByUniId(hum->stats.killer_id);
if (killer && killer != hum) {
killer->WinExp(hum, hum->meta->i->killer_exp());
}
}
NotifyUiUpdate();
} else {
--alive_count_;
@ -1807,15 +1818,25 @@ void Room::SecondRandPoint()
#ifdef DEBUG
if (GetRoomMode() == kZombieMode) {
BornPoint* born_point = nullptr;
int i = 0;
for (auto& pair : human_hash_) {
if (!born_point) {
born_point = pair.second->born_point;
} else {
++i;
pair.second->born_point = born_point;
pair.second->SetPos(pair.second->born_point->RandPoint());
a8::Vec2 pos = pair.second->born_point->RandPoint();
pos.x += i * 60;
pair.second->SetPos(pos);
pair.second->FindLocation();
pair.second->RefreshView();
grid_service->MoveHuman(pair.second);
#if 0
if (++i > 5) {
i = 0;
born_point = nullptr;
}
#endif
}
}
}
@ -1879,7 +1900,11 @@ ObstacleData* Room::GetPermanentObstacleData(int obstacle_uniid)
long long Room::GetGasInactiveTime()
{
if (room_mode_ == kZombieMode) {
#if DEBUG
return 5;
#else
return MetaMgr::Instance()->zbmode_gas_inactive_time;
#endif
} else {
if (room_type_ == RT_NewBrid) {
if (creator_game_times_ <= 0) {

View File

@ -196,12 +196,16 @@ void ZombieAI::UpdateAttack()
//站桩
ChangeToState(ZSE_Thinking);
} else {
#if 1
ChangeToState(ZSE_Pursuit);
#else
if (distance < node_->ai_meta->i->pursuit_radius()) {
//追击
ChangeToState(ZSE_Pursuit);
} else {
ChangeToState(ZSE_Thinking);
}
#endif
}
return;
}
@ -393,9 +397,12 @@ Human* ZombieAI::GetTarget()
node_->nearest_human = target;
node_->last_check_nearest_human_frameno = myself->room->GetFrameNo();
float distance = myself->GetPos().Distance(target->GetPos());
#if 1
#else
if (distance > GetAttackRange()) {
target = nullptr;
}
#endif
}
return target;
}