添加拾取处理
This commit is contained in:
parent
23e9ef0af5
commit
8ade050841
@ -16,6 +16,7 @@ class Loot : public Entity
|
|||||||
MetaData::Equip* meta = nullptr;
|
MetaData::Equip* meta = nullptr;
|
||||||
int item_id = 0;
|
int item_id = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
bool pickuped = false;
|
||||||
|
|
||||||
Loot();
|
Loot();
|
||||||
virtual ~Loot() override;
|
virtual ~Loot() override;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "bullet.h"
|
#include "bullet.h"
|
||||||
#include "obstacle.h"
|
#include "obstacle.h"
|
||||||
#include "building.h"
|
#include "building.h"
|
||||||
|
#include "loot.h"
|
||||||
|
|
||||||
const int F_del_objids = 2;
|
const int F_del_objids = 2;
|
||||||
const int F_full_objects = 3;
|
const int F_full_objects = 3;
|
||||||
@ -59,7 +60,7 @@ void Player::Update(int delta_time)
|
|||||||
if (moving) {
|
if (moving) {
|
||||||
UpdateMove();
|
UpdateMove();
|
||||||
}
|
}
|
||||||
if (updated_times % 2 == 0) {
|
if (room->frame_no % 2 == 0) {
|
||||||
if (shot_start || shot_hold) {
|
if (shot_start || shot_hold) {
|
||||||
UpdateShot();
|
UpdateShot();
|
||||||
}
|
}
|
||||||
@ -169,7 +170,7 @@ void Player::ProcInteraction()
|
|||||||
break;
|
break;
|
||||||
case ET_Loot:
|
case ET_Loot:
|
||||||
{
|
{
|
||||||
|
LootInteraction((Loot*)entity);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -202,9 +203,19 @@ void Player::ObstacleInteraction(Obstacle* entity)
|
|||||||
pair.second->last_collision_door = nullptr;
|
pair.second->last_collision_door = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::LootInteraction(Loot* entity)
|
||||||
|
{
|
||||||
|
if (entity->pickuped) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
entity->pickuped = true;
|
||||||
|
room->AddDeletedObject(entity->entity_uniid);
|
||||||
|
}
|
||||||
|
|
||||||
void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
||||||
{
|
{
|
||||||
bool has_move_dir = msg.has_move_dir();
|
bool has_move_dir = msg.has_move_dir();
|
||||||
|
@ -14,6 +14,7 @@ namespace cs
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Room;
|
class Room;
|
||||||
|
class Loot;
|
||||||
class Obstacle;
|
class Obstacle;
|
||||||
class Player : public Human
|
class Player : public Human
|
||||||
{
|
{
|
||||||
@ -53,6 +54,7 @@ class Player : public Human
|
|||||||
void Shot();
|
void Shot();
|
||||||
void ProcInteraction();
|
void ProcInteraction();
|
||||||
void ObstacleInteraction(Obstacle* entity);
|
void ObstacleInteraction(Obstacle* entity);
|
||||||
|
void LootInteraction(Loot* entity);
|
||||||
|
|
||||||
void _CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg);
|
void _CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg);
|
||||||
void _CMDropItem(f8::MsgHdr& hdr, const cs::CMDropItem& msg);
|
void _CMDropItem(f8::MsgHdr& hdr, const cs::CMDropItem& msg);
|
||||||
|
@ -19,18 +19,19 @@ const int ANDROID_NUM = 0;
|
|||||||
void Room::Update(int delta_time)
|
void Room::Update(int delta_time)
|
||||||
{
|
{
|
||||||
elapsed_time_ += delta_time;
|
elapsed_time_ += delta_time;
|
||||||
++frame_no;
|
|
||||||
while (elapsed_time_ >= 50) {
|
while (elapsed_time_ >= 50) {
|
||||||
ResetFrameData();
|
if (frame_no % 2 == 0) {
|
||||||
int i = 0;
|
ResetFrameData();
|
||||||
|
}
|
||||||
for (auto& pair : moveable_hash_) {
|
for (auto& pair : moveable_hash_) {
|
||||||
pair.second->Update(50);
|
pair.second->Update(50);
|
||||||
pair.second->updated_times++;
|
pair.second->updated_times++;
|
||||||
++i;
|
|
||||||
assert(i < 1000);
|
|
||||||
}
|
}
|
||||||
ClearDeletedObjects();
|
if (frame_no % 2 == 0) {
|
||||||
ProcAddedObjects();
|
ClearDeletedObjects();
|
||||||
|
ProcAddedObjects();
|
||||||
|
}
|
||||||
|
++frame_no;
|
||||||
elapsed_time_ -= 50;
|
elapsed_time_ -= 50;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -372,6 +373,10 @@ void Room::ClearDeletedObjects()
|
|||||||
uniid_hash_.erase(entity->entity_uniid);
|
uniid_hash_.erase(entity->entity_uniid);
|
||||||
moveable_hash_.erase(entity->entity_uniid);
|
moveable_hash_.erase(entity->entity_uniid);
|
||||||
}
|
}
|
||||||
|
for (auto& pair : human_hash_) {
|
||||||
|
pair.second->new_objects.erase(entity);
|
||||||
|
pair.second->part_objects.erase(entity);
|
||||||
|
}
|
||||||
delete entity;
|
delete entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ message MFPlayerFull
|
|||||||
optional int32 anim_seq = 11; //
|
optional int32 anim_seq = 11; //
|
||||||
optional int32 action_type = 12; //0: none 1:reload 2:useitem 3:relive
|
optional int32 action_type = 12; //0: none 1:reload 2:useitem 3:relive
|
||||||
optional int32 skin = 13; //皮肤id
|
optional int32 skin = 13; //皮肤id
|
||||||
//backpack
|
optional int32 backpack = 14; //背包
|
||||||
optional int32 helmet = 16; //头盔
|
optional int32 helmet = 16; //头盔
|
||||||
optional int32 chest = 17; //防弹衣
|
optional int32 chest = 17; //防弹衣
|
||||||
optional int32 weapon = 18; //武器
|
optional int32 weapon = 18; //武器
|
||||||
|
Loading…
x
Reference in New Issue
Block a user