This commit is contained in:
aozhiwei 2019-04-02 14:19:40 +08:00
parent f36d0a8383
commit 12b963ec79
7 changed files with 29 additions and 21 deletions

View File

@ -24,10 +24,11 @@ void Android::Initialize()
health = meta->i->health();
helmet = DEF_HELMET_ID;
chest = DEF_CHEST_ID;
#if 0
weapon = DEF_WEAPON_ID;
#endif
helmet_meta = MetaMgr::Instance()->GetEquip(helmet);
chest_meta = MetaMgr::Instance()->GetEquip(chest);
weapon_meta = MetaMgr::Instance()->GetEquip(weapon);
RecalcSelfCollider();
}

View File

@ -74,3 +74,6 @@ const int SYNC_FRAME_RATE = 10;
const int MAX_INVENTORY_NUM = 14;
const int MAX_WEAPON_NUM = 5;
const int GUN_SLOT1 = 1;
const int GUN_SLOT2 = 2;

View File

@ -15,6 +15,7 @@ Human::Human()
default_weapon.weapon_idx = 0;
default_weapon.weapon_id = 12102;
default_weapon.weapon_lv = 1;
default_weapon.meta = MetaMgr::Instance()->GetEquip(default_weapon.weapon_id);
weapons.reserve(MAX_WEAPON_NUM);
for (size_t i = 0; i < MAX_WEAPON_NUM; ++i) {
auto& weapon = a8::FastAppend(weapons);
@ -78,7 +79,7 @@ void Human::FillMFObjectFull(cs::MFObjectFull* full_data)
void Human::Shot(Vector2D& target_dir)
{
if (!weapon_meta) {
if (!curr_weapon->meta) {
return;
}
@ -92,18 +93,18 @@ void Human::Shot(Vector2D& target_dir)
{
cs::MFBullet* bullet = room->frame_data.bullets.Add();
bullet->set_player_id(entity_uniid);
bullet->set_bullet_id(weapon_meta->i->use_bullet());
bullet->set_bullet_id(curr_weapon->meta->i->use_bullet());
pos.ToPB(bullet->mutable_pos());
target_dir.ToPB(bullet->mutable_dir());
bullet->set_bulletskin(10001);
bullet->set_gun_id(weapon_meta->i->id());
bullet->set_gun_id(curr_weapon->meta->i->id());
}
{
Bullet* bullet = new Bullet();
bullet->player = this;
bullet->room = room;
bullet->gun_meta = weapon_meta;
bullet->meta = MetaMgr::Instance()->GetEquip(weapon_meta->i->use_bullet());
bullet->gun_meta = curr_weapon->meta;
bullet->meta = MetaMgr::Instance()->GetEquip(curr_weapon->meta->i->use_bullet());
bullet->pos = pos;
bullet->dir = target_dir;
bullet->born_pos = pos;

View File

@ -23,7 +23,6 @@ class Human : public Entity
MetaData::Player* meta = nullptr;
MetaData::Equip* helmet_meta = nullptr;
MetaData::Equip* chest_meta = nullptr;
MetaData::Equip* weapon_meta = nullptr;
Vector2D move_dir;
Vector2D attack_dir;
@ -39,7 +38,6 @@ class Human : public Entity
int skin = 0;
int helmet = 0;
int chest = 0;
int weapon = 0;
int energy_shield = 0;
int vip = 0;
int sdmg = 0;

View File

@ -47,10 +47,15 @@ void Player::Initialize()
health = meta->i->health();
helmet = DEF_HELMET_ID;
chest = DEF_CHEST_ID;
weapon = DEF_WEAPON_ID;
#if 1
weapons[GUN_SLOT1].weapon_idx = GUN_SLOT1;
weapons[GUN_SLOT1].weapon_id = DEF_WEAPON_ID;
weapons[GUN_SLOT1].weapon_lv = 1;
weapons[GUN_SLOT1].meta = MetaMgr::Instance()->GetEquip(DEF_WEAPON_ID);;
curr_weapon = &weapons[GUN_SLOT1];
#endif
helmet_meta = MetaMgr::Instance()->GetEquip(helmet);
chest_meta = MetaMgr::Instance()->GetEquip(chest);
weapon_meta = MetaMgr::Instance()->GetEquip(weapon);
RecalcSelfCollider();
inventory.reserve(MAX_INVENTORY_NUM);
for (size_t i = 0; i < inventory.size(); ++i) {
@ -131,34 +136,32 @@ void Player::UpdateShot()
void Player::Shot()
{
if (!weapon_meta) {
if (!curr_weapon->meta) {
return;
}
{
cs::MFShot* shot = room->frame_data.shots.Add();
shot->set_player_id(entity_uniid);
#if 0
shot->set_weapon_id(weapon_meta->i->id());
#endif
curr_weapon->ToPB(shot->mutable_weapon());
shot->set_offhand(true);
shot->set_bullskin(10001);
}
{
cs::MFBullet* bullet = room->frame_data.bullets.Add();
bullet->set_player_id(entity_uniid);
bullet->set_bullet_id(weapon_meta->i->use_bullet());
bullet->set_bullet_id(curr_weapon->meta->i->use_bullet());
pos.ToPB(bullet->mutable_pos());
attack_dir.ToPB(bullet->mutable_dir());
bullet->set_bulletskin(10001);
bullet->set_gun_id(weapon_meta->i->id());
bullet->set_gun_id(curr_weapon->meta->i->id());
}
{
Bullet* bullet = new Bullet();
bullet->player = this;
bullet->room = room;
bullet->gun_meta = weapon_meta;
bullet->meta = MetaMgr::Instance()->GetEquip(weapon_meta->i->use_bullet());
bullet->gun_meta = curr_weapon->meta;
bullet->meta = MetaMgr::Instance()->GetEquip(curr_weapon->meta->i->use_bullet());
bullet->pos = pos;
bullet->dir = attack_dir;
bullet->born_pos = pos;

View File

@ -45,6 +45,7 @@ struct Vector2D
namespace MetaData
{
struct SafeArea;
struct Equip;
}
struct GasData
@ -69,6 +70,7 @@ struct Weapon
int weapon_id = 0;
int weapon_lv = 0;
int num = 0;
MetaData::Equip* meta = nullptr;
void ToPB(cs::MFWeapon* pb_obj);
};

View File

@ -653,9 +653,9 @@ message SMGameOver
//
message SMPickup
{
optional int32 type = 1;
optional int32 item_id = 2;
optional int32 count = 3;
optional int32 error_code = 1; //0: 1: 2: 3:
optional int32 item_id = 2; //id
optional int32 count = 3; //
}
//线