1
This commit is contained in:
parent
f36d0a8383
commit
12b963ec79
@ -24,10 +24,11 @@ void Android::Initialize()
|
|||||||
health = meta->i->health();
|
health = meta->i->health();
|
||||||
helmet = DEF_HELMET_ID;
|
helmet = DEF_HELMET_ID;
|
||||||
chest = DEF_CHEST_ID;
|
chest = DEF_CHEST_ID;
|
||||||
|
#if 0
|
||||||
weapon = DEF_WEAPON_ID;
|
weapon = DEF_WEAPON_ID;
|
||||||
|
#endif
|
||||||
helmet_meta = MetaMgr::Instance()->GetEquip(helmet);
|
helmet_meta = MetaMgr::Instance()->GetEquip(helmet);
|
||||||
chest_meta = MetaMgr::Instance()->GetEquip(chest);
|
chest_meta = MetaMgr::Instance()->GetEquip(chest);
|
||||||
weapon_meta = MetaMgr::Instance()->GetEquip(weapon);
|
|
||||||
RecalcSelfCollider();
|
RecalcSelfCollider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,3 +74,6 @@ const int SYNC_FRAME_RATE = 10;
|
|||||||
|
|
||||||
const int MAX_INVENTORY_NUM = 14;
|
const int MAX_INVENTORY_NUM = 14;
|
||||||
const int MAX_WEAPON_NUM = 5;
|
const int MAX_WEAPON_NUM = 5;
|
||||||
|
|
||||||
|
const int GUN_SLOT1 = 1;
|
||||||
|
const int GUN_SLOT2 = 2;
|
||||||
|
@ -15,6 +15,7 @@ Human::Human()
|
|||||||
default_weapon.weapon_idx = 0;
|
default_weapon.weapon_idx = 0;
|
||||||
default_weapon.weapon_id = 12102;
|
default_weapon.weapon_id = 12102;
|
||||||
default_weapon.weapon_lv = 1;
|
default_weapon.weapon_lv = 1;
|
||||||
|
default_weapon.meta = MetaMgr::Instance()->GetEquip(default_weapon.weapon_id);
|
||||||
weapons.reserve(MAX_WEAPON_NUM);
|
weapons.reserve(MAX_WEAPON_NUM);
|
||||||
for (size_t i = 0; i < MAX_WEAPON_NUM; ++i) {
|
for (size_t i = 0; i < MAX_WEAPON_NUM; ++i) {
|
||||||
auto& weapon = a8::FastAppend(weapons);
|
auto& weapon = a8::FastAppend(weapons);
|
||||||
@ -78,7 +79,7 @@ void Human::FillMFObjectFull(cs::MFObjectFull* full_data)
|
|||||||
|
|
||||||
void Human::Shot(Vector2D& target_dir)
|
void Human::Shot(Vector2D& target_dir)
|
||||||
{
|
{
|
||||||
if (!weapon_meta) {
|
if (!curr_weapon->meta) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,18 +93,18 @@ void Human::Shot(Vector2D& target_dir)
|
|||||||
{
|
{
|
||||||
cs::MFBullet* bullet = room->frame_data.bullets.Add();
|
cs::MFBullet* bullet = room->frame_data.bullets.Add();
|
||||||
bullet->set_player_id(entity_uniid);
|
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());
|
pos.ToPB(bullet->mutable_pos());
|
||||||
target_dir.ToPB(bullet->mutable_dir());
|
target_dir.ToPB(bullet->mutable_dir());
|
||||||
bullet->set_bulletskin(10001);
|
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* bullet = new Bullet();
|
||||||
bullet->player = this;
|
bullet->player = this;
|
||||||
bullet->room = room;
|
bullet->room = room;
|
||||||
bullet->gun_meta = weapon_meta;
|
bullet->gun_meta = curr_weapon->meta;
|
||||||
bullet->meta = MetaMgr::Instance()->GetEquip(weapon_meta->i->use_bullet());
|
bullet->meta = MetaMgr::Instance()->GetEquip(curr_weapon->meta->i->use_bullet());
|
||||||
bullet->pos = pos;
|
bullet->pos = pos;
|
||||||
bullet->dir = target_dir;
|
bullet->dir = target_dir;
|
||||||
bullet->born_pos = pos;
|
bullet->born_pos = pos;
|
||||||
|
@ -23,7 +23,6 @@ class Human : public Entity
|
|||||||
MetaData::Player* meta = nullptr;
|
MetaData::Player* meta = nullptr;
|
||||||
MetaData::Equip* helmet_meta = nullptr;
|
MetaData::Equip* helmet_meta = nullptr;
|
||||||
MetaData::Equip* chest_meta = nullptr;
|
MetaData::Equip* chest_meta = nullptr;
|
||||||
MetaData::Equip* weapon_meta = nullptr;
|
|
||||||
|
|
||||||
Vector2D move_dir;
|
Vector2D move_dir;
|
||||||
Vector2D attack_dir;
|
Vector2D attack_dir;
|
||||||
@ -39,7 +38,6 @@ class Human : public Entity
|
|||||||
int skin = 0;
|
int skin = 0;
|
||||||
int helmet = 0;
|
int helmet = 0;
|
||||||
int chest = 0;
|
int chest = 0;
|
||||||
int weapon = 0;
|
|
||||||
int energy_shield = 0;
|
int energy_shield = 0;
|
||||||
int vip = 0;
|
int vip = 0;
|
||||||
int sdmg = 0;
|
int sdmg = 0;
|
||||||
|
@ -47,10 +47,15 @@ void Player::Initialize()
|
|||||||
health = meta->i->health();
|
health = meta->i->health();
|
||||||
helmet = DEF_HELMET_ID;
|
helmet = DEF_HELMET_ID;
|
||||||
chest = DEF_CHEST_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);
|
helmet_meta = MetaMgr::Instance()->GetEquip(helmet);
|
||||||
chest_meta = MetaMgr::Instance()->GetEquip(chest);
|
chest_meta = MetaMgr::Instance()->GetEquip(chest);
|
||||||
weapon_meta = MetaMgr::Instance()->GetEquip(weapon);
|
|
||||||
RecalcSelfCollider();
|
RecalcSelfCollider();
|
||||||
inventory.reserve(MAX_INVENTORY_NUM);
|
inventory.reserve(MAX_INVENTORY_NUM);
|
||||||
for (size_t i = 0; i < inventory.size(); ++i) {
|
for (size_t i = 0; i < inventory.size(); ++i) {
|
||||||
@ -131,34 +136,32 @@ void Player::UpdateShot()
|
|||||||
|
|
||||||
void Player::Shot()
|
void Player::Shot()
|
||||||
{
|
{
|
||||||
if (!weapon_meta) {
|
if (!curr_weapon->meta) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
cs::MFShot* shot = room->frame_data.shots.Add();
|
cs::MFShot* shot = room->frame_data.shots.Add();
|
||||||
shot->set_player_id(entity_uniid);
|
shot->set_player_id(entity_uniid);
|
||||||
#if 0
|
curr_weapon->ToPB(shot->mutable_weapon());
|
||||||
shot->set_weapon_id(weapon_meta->i->id());
|
|
||||||
#endif
|
|
||||||
shot->set_offhand(true);
|
shot->set_offhand(true);
|
||||||
shot->set_bullskin(10001);
|
shot->set_bullskin(10001);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
cs::MFBullet* bullet = room->frame_data.bullets.Add();
|
cs::MFBullet* bullet = room->frame_data.bullets.Add();
|
||||||
bullet->set_player_id(entity_uniid);
|
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());
|
pos.ToPB(bullet->mutable_pos());
|
||||||
attack_dir.ToPB(bullet->mutable_dir());
|
attack_dir.ToPB(bullet->mutable_dir());
|
||||||
bullet->set_bulletskin(10001);
|
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* bullet = new Bullet();
|
||||||
bullet->player = this;
|
bullet->player = this;
|
||||||
bullet->room = room;
|
bullet->room = room;
|
||||||
bullet->gun_meta = weapon_meta;
|
bullet->gun_meta = curr_weapon->meta;
|
||||||
bullet->meta = MetaMgr::Instance()->GetEquip(weapon_meta->i->use_bullet());
|
bullet->meta = MetaMgr::Instance()->GetEquip(curr_weapon->meta->i->use_bullet());
|
||||||
bullet->pos = pos;
|
bullet->pos = pos;
|
||||||
bullet->dir = attack_dir;
|
bullet->dir = attack_dir;
|
||||||
bullet->born_pos = pos;
|
bullet->born_pos = pos;
|
||||||
|
@ -45,6 +45,7 @@ struct Vector2D
|
|||||||
namespace MetaData
|
namespace MetaData
|
||||||
{
|
{
|
||||||
struct SafeArea;
|
struct SafeArea;
|
||||||
|
struct Equip;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GasData
|
struct GasData
|
||||||
@ -69,6 +70,7 @@ struct Weapon
|
|||||||
int weapon_id = 0;
|
int weapon_id = 0;
|
||||||
int weapon_lv = 0;
|
int weapon_lv = 0;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
MetaData::Equip* meta = nullptr;
|
||||||
|
|
||||||
void ToPB(cs::MFWeapon* pb_obj);
|
void ToPB(cs::MFWeapon* pb_obj);
|
||||||
};
|
};
|
||||||
|
@ -653,9 +653,9 @@ message SMGameOver
|
|||||||
//拾取
|
//拾取
|
||||||
message SMPickup
|
message SMPickup
|
||||||
{
|
{
|
||||||
optional int32 type = 1;
|
optional int32 error_code = 1; //0:没有错误 1:背包空间不足 2:物品已拥有 3:物品已装备
|
||||||
optional int32 item_id = 2;
|
optional int32 item_id = 2; //道具id
|
||||||
optional int32 count = 3;
|
optional int32 count = 3; //获得数量
|
||||||
}
|
}
|
||||||
|
|
||||||
//断线通知
|
//断线通知
|
||||||
|
Loading…
x
Reference in New Issue
Block a user