添加状态判断
This commit is contained in:
parent
316a0dfc71
commit
993cc6285e
@ -12,6 +12,9 @@ namespace MetaData
|
||||
enum HumanStatus
|
||||
{
|
||||
HS_PainKiller = 1,
|
||||
HS_Fly = 2,
|
||||
HS_Jump = 3,
|
||||
HS_End
|
||||
};
|
||||
|
||||
struct xtimer_list;
|
||||
|
@ -64,6 +64,12 @@ public:
|
||||
f8::ReadCsvMetaFile(res_path + "airdrop@airdrop.csv", airdrop_meta_list);
|
||||
f8::ReadJsonMetaFile(res_path + "maps.json", building_meta_list);
|
||||
BindToMetaData();
|
||||
#if 1
|
||||
{
|
||||
MetaMgr::Instance()->gas_inactive_time = MetaMgr::Instance()->GetSysParamAsInt("gas_inactive_time");
|
||||
MetaMgr::Instance()->plane_speed = MetaMgr::Instance()->GetSysParamAsFloat("plane_speed") / SERVER_FRAME_RATE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -31,7 +31,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
||||
std::list<MetaData::AirDrop>& GetAirDrops();
|
||||
|
||||
int gas_inactive_time = 10;
|
||||
int gas_jump_time = 0;
|
||||
float plane_speed = 5.0f;
|
||||
|
||||
private:
|
||||
MetaDataLoader* loader_ = nullptr;
|
||||
|
@ -85,6 +85,12 @@ void Player::UpdateMove()
|
||||
if (action_type == AT_Relive) {
|
||||
CancelAction();
|
||||
}
|
||||
if (a8::HasBitFlag(status, HS_Fly)) {
|
||||
moving = false;
|
||||
moved_frames = 0;
|
||||
last_collision_door = nullptr;
|
||||
return;
|
||||
}
|
||||
++moved_frames;
|
||||
if (moved_frames > 4) {
|
||||
moving = false;
|
||||
@ -110,6 +116,12 @@ void Player::UpdateMove()
|
||||
|
||||
void Player::UpdateShot()
|
||||
{
|
||||
if (a8::HasBitFlag(status, HS_Fly)) {
|
||||
shot_start = false;
|
||||
shot_hold = false;
|
||||
series_shot_frames = 0;
|
||||
return;
|
||||
}
|
||||
if (shot_start) {
|
||||
shot_start = false;
|
||||
Shot();
|
||||
@ -133,6 +145,11 @@ void Player::UpdateShot()
|
||||
|
||||
void Player::UpdateSelectWeapon()
|
||||
{
|
||||
if (a8::HasBitFlag(status, HS_Fly)) {
|
||||
select_weapon = false;
|
||||
selected_weapon_idx = 0;
|
||||
return;
|
||||
}
|
||||
if (selected_weapon_idx >= 0 && selected_weapon_idx < weapons.size()) {
|
||||
Weapon* weapon = &weapons[selected_weapon_idx];
|
||||
if (weapon->weapon_id != 0) {
|
||||
@ -331,6 +348,10 @@ void Player::UpdateUseItemIdx()
|
||||
|
||||
void Player::UpdateSpectate()
|
||||
{
|
||||
if (a8::HasBitFlag(status, HS_Fly)) {
|
||||
spectate = false;
|
||||
return;
|
||||
}
|
||||
BeKill(entity_uniid, name);
|
||||
spectate = false;
|
||||
}
|
||||
@ -345,6 +366,11 @@ void Player::UpdateGameOver()
|
||||
|
||||
void Player::UpdateEmote()
|
||||
{
|
||||
if (a8::HasBitFlag(status, HS_Fly)) {
|
||||
emote = false;
|
||||
emote_id = 0;
|
||||
return;
|
||||
}
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFEmote>* emotes = nullptr;
|
||||
{
|
||||
auto itr = room->frame_data.emotes_hash.find(room->frame_no);
|
||||
@ -396,34 +422,38 @@ void Player::Shot()
|
||||
shot->set_offhand(true);
|
||||
shot->set_bullskin(10001);
|
||||
}
|
||||
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
|
||||
Vector2D bullet_born_offset = Vector2D(std::get<0>(tuple), std::get<1>(tuple));
|
||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(Vector2D::UP));
|
||||
Vector2D bullet_born_pos = pos + bullet_born_offset;
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFBullet>* bullets = nullptr;
|
||||
{
|
||||
if (room->gas_data.gas_mode != GasInactive && room->gas_data.gas_mode != GasJump) {
|
||||
for (auto& tuple : curr_weapon->meta->bullet_born_offset) {
|
||||
Vector2D bullet_born_offset = Vector2D(std::get<0>(tuple), std::get<1>(tuple));
|
||||
bullet_born_offset.Rotate(attack_dir.CalcAngle(Vector2D::UP));
|
||||
Vector2D bullet_born_pos = pos + bullet_born_offset;
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFBullet>* bullets = nullptr;
|
||||
{
|
||||
auto itr = room->frame_data.bullets_hash.find(room->frame_no);
|
||||
if (itr == room->frame_data.bullets_hash.end()) {
|
||||
room->frame_data.bullets_hash[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFBullet>();
|
||||
itr = room->frame_data.bullets_hash.find(room->frame_no);
|
||||
{
|
||||
auto itr = room->frame_data.bullets_hash.find(room->frame_no);
|
||||
if (itr == room->frame_data.bullets_hash.end()) {
|
||||
room->frame_data.bullets_hash[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFBullet>();
|
||||
itr = room->frame_data.bullets_hash.find(room->frame_no);
|
||||
}
|
||||
bullets = &itr->second;
|
||||
}
|
||||
bullets = &itr->second;
|
||||
}
|
||||
{
|
||||
cs::MFBullet* bullet = bullets->Add();
|
||||
bullet->set_player_id(entity_uniid);
|
||||
bullet->set_bullet_id(curr_weapon->meta->i->use_bullet());
|
||||
bullet_born_pos.ToPB(bullet->mutable_pos());
|
||||
attack_dir.ToPB(bullet->mutable_dir());
|
||||
bullet->set_bulletskin(10001);
|
||||
bullet->set_gun_id(curr_weapon->meta->i->id());
|
||||
bullet->set_fly_distance(fly_distance);
|
||||
}
|
||||
room->CreateBullet(this, curr_weapon->meta, bullet_born_pos, attack_dir, fly_distance);
|
||||
}
|
||||
{
|
||||
cs::MFBullet* bullet = bullets->Add();
|
||||
bullet->set_player_id(entity_uniid);
|
||||
bullet->set_bullet_id(curr_weapon->meta->i->use_bullet());
|
||||
bullet_born_pos.ToPB(bullet->mutable_pos());
|
||||
attack_dir.ToPB(bullet->mutable_dir());
|
||||
bullet->set_bulletskin(10001);
|
||||
bullet->set_gun_id(curr_weapon->meta->i->id());
|
||||
bullet->set_fly_distance(fly_distance);
|
||||
}
|
||||
room->CreateBullet(this, curr_weapon->meta, bullet_born_pos, attack_dir, fly_distance);
|
||||
}
|
||||
--curr_weapon->ammo;
|
||||
if (curr_weapon->weapon_idx != 0) {
|
||||
--curr_weapon->ammo;
|
||||
}
|
||||
int slot_id = curr_weapon->meta->i->_inventory_slot();
|
||||
switch (slot_id) {
|
||||
case 5:
|
||||
@ -479,6 +509,10 @@ void Player::Shot()
|
||||
|
||||
void Player::ProcInteraction()
|
||||
{
|
||||
if (a8::HasBitFlag(status, HS_Fly)) {
|
||||
interaction_objids.Clear();
|
||||
return;
|
||||
}
|
||||
for (auto obj_id : interaction_objids) {
|
||||
Entity* entity = room->GetEntityByUniId(obj_id);
|
||||
if (entity) {
|
||||
|
@ -755,7 +755,20 @@ void Room::UpdateGas()
|
||||
switch (gas_data.gas_mode) {
|
||||
case GasInactive:
|
||||
{
|
||||
if (frame_no - gas_data.gas_start_frameno >= MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE) {
|
||||
if (frame_no - gas_data.gas_start_frameno >=
|
||||
MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE) {
|
||||
gas_data.gas_mode = GasJump;
|
||||
gas_data.gas_start_frameno = frame_no;
|
||||
ShuaPlane();
|
||||
RoomMgr::Instance()->RemoveFromInactiveRoomHash(room_uuid);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GasJump:
|
||||
{
|
||||
Vector2D len_vec = plane.dir * (frame_no - gas_data.gas_start_frameno)*MetaMgr::Instance()->plane_speed;
|
||||
plane.curr_pos = plane.start_point + len_vec;
|
||||
if ((plane.end_point - plane.start_point).Norm() <= len_vec.Norm()) {
|
||||
gas_data.gas_mode = GasWaiting;
|
||||
gas_data.old_area_meta = MetaMgr::Instance()->GetSafeArea(30001);
|
||||
gas_data.new_area_meta = MetaMgr::Instance()->GetSafeArea(30002);
|
||||
@ -773,15 +786,9 @@ void Room::UpdateGas()
|
||||
}
|
||||
gas_data.rad_old = gas_data.old_area_meta->i->rad();
|
||||
gas_data.rad_new = gas_data.new_area_meta->i->rad();
|
||||
RoomMgr::Instance()->RemoveFromInactiveRoomHash(room_uuid);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GasJump:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
case GasWaiting:
|
||||
{
|
||||
if (frame_no - gas_data.gas_start_frameno >=
|
||||
@ -845,7 +852,7 @@ void Room::UpdateGas()
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (gas_data.gas_mode != GasInactive) {
|
||||
if (gas_data.gas_mode != GasInactive && gas_data.gas_mode != GasJump) {
|
||||
if (!game_over && alive_count_ <= 1) {
|
||||
game_over = true;
|
||||
game_over_frameno = frame_no;
|
||||
@ -1030,3 +1037,12 @@ void Room::AirDrop(int appear_time, int box_id)
|
||||
&xtimer_attacher.timer_list_);
|
||||
}
|
||||
}
|
||||
|
||||
void Room::ShuaPlane()
|
||||
{
|
||||
for (auto& pair : human_hash_) {
|
||||
a8::SetBitFlag(pair.second->status, HS_Fly);
|
||||
pair.second->pos = plane.curr_pos;
|
||||
pair.second->attack_dir = plane.dir;
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
long long game_over_frameno = 0;
|
||||
RoomProfile profile;
|
||||
a8::XTimer xtimer;
|
||||
Plane plane;
|
||||
|
||||
~Room();
|
||||
void Init();
|
||||
@ -89,6 +90,7 @@ private:
|
||||
void AutoMatchTeam();
|
||||
void InitAirDrop();
|
||||
void AirDrop(int appear_time, int box_id);
|
||||
void ShuaPlane();
|
||||
|
||||
private:
|
||||
timer_list* stats_timer_ = nullptr;
|
||||
|
@ -60,3 +60,11 @@ struct PlayerStats
|
||||
std::string killer_name;
|
||||
|
||||
};
|
||||
|
||||
struct Plane
|
||||
{
|
||||
Vector2D start_point;
|
||||
Vector2D end_point;
|
||||
Vector2D dir;
|
||||
Vector2D curr_pos;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user