1
This commit is contained in:
parent
3a038a15e8
commit
0cf4f7651f
@ -174,7 +174,7 @@ void AndroidAI::DoMove()
|
||||
}
|
||||
HumMaster()->room->grid_service.MoveHuman(HumMaster());
|
||||
}
|
||||
HumMaster()->CheckGrass();
|
||||
HumMaster()->CheckSpecObject();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,6 +158,7 @@ enum BuffEffectType_e
|
||||
kBET_ReleaseDcgr = 8, //释放电磁干扰
|
||||
kBET_ReleaseFireBomb = 9, //喷火
|
||||
kBET_Assault = 10, //向心突击
|
||||
kBET_OnceChgAttr = 11, //一次性buff
|
||||
kBET_End
|
||||
};
|
||||
|
||||
@ -187,6 +188,7 @@ enum HumanAttrType_e
|
||||
enum EquipType_e
|
||||
{
|
||||
kEquipType_Bullet = 1,
|
||||
kEquipType_Buff = 3,
|
||||
};
|
||||
|
||||
enum BulletType_e
|
||||
@ -200,6 +202,7 @@ enum BulletType_e
|
||||
enum ColliderTag_e
|
||||
{
|
||||
kColliderTag_Grass = 1, //草丛
|
||||
kColliderTag_Loot = 2, //掉落物
|
||||
};
|
||||
|
||||
const char* const kPROJ_NAME_FMT = "game%d_gameserver";
|
||||
|
@ -48,8 +48,9 @@ class Entity
|
||||
void NotifyDelObject();
|
||||
void RemoveFromMapService();
|
||||
|
||||
protected:
|
||||
void ClearColliders();
|
||||
|
||||
private:
|
||||
std::list<ColliderComponent*> colliders;
|
||||
|
||||
void ClearColliders();
|
||||
};
|
||||
|
@ -1162,6 +1162,19 @@ void Human::AddBuff(MetaData::Buff* buff_meta)
|
||||
RemoveBuffById(buff->meta->i->buff_id());
|
||||
}
|
||||
}
|
||||
if (buff_meta->i->buff_effect() == kBET_OnceChgAttr) {
|
||||
if ((int)buff_meta->param1== kHAT_Hp) {
|
||||
if ((int)buff_meta->param2 == 1) {
|
||||
//绝对值
|
||||
ability.hp += buff_meta->param2;
|
||||
ability.hp = std::min(ability.max_hp, ability.hp);
|
||||
} else if ((int)buff_meta->param2 == 2) {
|
||||
//百分比
|
||||
ability.hp *= 1 + buff_meta->param2;
|
||||
ability.hp = std::min(ability.max_hp, ability.hp);
|
||||
}
|
||||
}
|
||||
}
|
||||
Buff* buff = &a8::FastAppend(buff_list_);
|
||||
buff->owner = this;
|
||||
buff->meta = buff_meta;
|
||||
@ -1306,6 +1319,11 @@ void Human::ProcBuffEffect(Buff* buff)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kBET_OnceChgAttr:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1379,20 +1397,48 @@ void Human::OnLeaveGrass()
|
||||
&xtimer_attacher.timer_list_);
|
||||
}
|
||||
|
||||
void Human::CheckGrass()
|
||||
void Human::CheckSpecObject()
|
||||
{
|
||||
bool in_grass = false;
|
||||
long long spec_flags = 0;
|
||||
a8::SetBitFlag(spec_flags, kColliderTag_Grass);
|
||||
a8::SetBitFlag(spec_flags, kColliderTag_Loot);
|
||||
std::set<ColliderComponent*> colliders;
|
||||
room->map_service.GetGrassColliders(pos.x, pos.y, colliders);
|
||||
room->map_service.GetSpecColliders(0, pos.x, pos.y, colliders);
|
||||
|
||||
for (const ColliderComponent* collider : colliders) {
|
||||
switch (collider->owner->entity_type) {
|
||||
case kET_Loot:
|
||||
{
|
||||
if (TestCollision((ColliderComponent*)collider)) {
|
||||
Loot* loot_entity = (Loot*)collider->owner;
|
||||
if (!loot_entity->pickuped &&
|
||||
loot_entity->count > 0) {
|
||||
MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(loot_entity->item_id);
|
||||
if (item_meta) {
|
||||
switch (item_meta->i->equip_type()) {
|
||||
case kEquipType_Buff:
|
||||
{
|
||||
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(item_meta->i->buff_id());
|
||||
if (buff_meta) {
|
||||
AddBuff(buff_meta);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
loot_entity->pickuped = true;
|
||||
room->RemoveObjectLater(loot_entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kET_Obstacle:
|
||||
case kET_Building:
|
||||
{
|
||||
if (TestCollision((ColliderComponent*)collider)) {
|
||||
in_grass = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1523,7 +1569,7 @@ void Human::_UpdateMove(int speed)
|
||||
}
|
||||
room->grid_service.MoveHuman(this);
|
||||
}
|
||||
CheckGrass();
|
||||
CheckSpecObject();
|
||||
}
|
||||
|
||||
void Human::_UpdateAssaultMove()
|
||||
@ -1548,7 +1594,7 @@ void Human::_UpdateAssaultMove()
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckGrass();
|
||||
CheckSpecObject();
|
||||
if (move_end) {
|
||||
if (!skill_meta_->phases.empty()) {
|
||||
MetaData::SkillPhase* phase = &skill_meta_->phases[0];
|
||||
@ -1592,7 +1638,7 @@ void Human::PullHuman(const a8::Vec2& pull_dir, float distance)
|
||||
}
|
||||
room->grid_service.MoveHuman(this);
|
||||
}
|
||||
CheckGrass();
|
||||
CheckSpecObject();
|
||||
}
|
||||
|
||||
void Human::ClearFrameData()
|
||||
@ -1682,7 +1728,7 @@ void Human::Revive()
|
||||
room->frame_event.AddRevive(this);
|
||||
room->OnHumanRevive(this);
|
||||
|
||||
CheckGrass();
|
||||
CheckSpecObject();
|
||||
use_skill = false;
|
||||
curr_skill_phase = 0;
|
||||
skill_dir = a8::Vec2();
|
||||
|
@ -195,7 +195,7 @@ class Human : public Entity
|
||||
void OnHit();
|
||||
void OnEnterGrass();
|
||||
void OnLeaveGrass();
|
||||
void CheckGrass();
|
||||
void CheckSpecObject();
|
||||
void GrassTempShow();
|
||||
float* GetAbilityById(int attr_id);
|
||||
void RecalcBaseAttr();
|
||||
|
@ -27,6 +27,15 @@ void Loot::Initialize()
|
||||
|
||||
void Loot::RecalcSelfCollider()
|
||||
{
|
||||
if (!self_collider_) {
|
||||
self_collider_ = new CircleCollider();
|
||||
self_collider_->owner = this;
|
||||
AddCollider(self_collider_);
|
||||
}
|
||||
self_collider_->pos = a8::Vec2();
|
||||
self_collider_->rad = 64.0f / 2.0;
|
||||
ClearColliders();
|
||||
room->map_service.AddCollider(self_collider_);
|
||||
}
|
||||
|
||||
void Loot::FillMFObjectPart(cs::MFObjectPart* part_data)
|
||||
|
@ -26,4 +26,7 @@ class Loot : public Entity
|
||||
void RecalcSelfCollider();
|
||||
virtual void FillMFObjectPart(cs::MFObjectPart* part_data) override;
|
||||
virtual void FillMFObjectFull(cs::MFObjectFull* full_data) override;
|
||||
|
||||
private:
|
||||
CircleCollider* self_collider_ = nullptr;
|
||||
};
|
||||
|
@ -176,7 +176,7 @@ void MapService::GetColliders(float world_x, float world_y, std::set<ColliderCom
|
||||
}
|
||||
struct CellNode *node, *tmp;
|
||||
list_for_each_entry_safe(node, tmp, head, entry) {
|
||||
if (node->collider->tag != kColliderTag_Grass) {
|
||||
if (node->collider->tag == 0) {
|
||||
colliders.insert(node->collider);
|
||||
}
|
||||
}
|
||||
@ -184,7 +184,8 @@ void MapService::GetColliders(float world_x, float world_y, std::set<ColliderCom
|
||||
}
|
||||
}
|
||||
|
||||
void MapService::GetGrassColliders(float world_x, float world_y, std::set<ColliderComponent*>& colliders)
|
||||
void MapService::GetSpecColliders(long long flags, float world_x, float world_y,
|
||||
std::set<ColliderComponent*>& colliders)
|
||||
{
|
||||
int center_grid_id = GetGridId(world_x, world_y);
|
||||
if (center_grid_id < 0 || center_grid_id >= max_grid_id_) {
|
||||
@ -199,7 +200,7 @@ void MapService::GetGrassColliders(float world_x, float world_y, std::set<Collid
|
||||
}
|
||||
struct CellNode *node, *tmp;
|
||||
list_for_each_entry_safe(node, tmp, head, entry) {
|
||||
if (node->collider->tag == kColliderTag_Grass) {
|
||||
if (a8::HasBitFlag(flags, node->collider->tag)) {
|
||||
colliders.insert(node->collider);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ class MapService
|
||||
void AddCollider(ColliderComponent* collider);
|
||||
void RemoveCollider(ColliderComponent* collider);
|
||||
void GetColliders(float world_x, float world_y, std::set<ColliderComponent*>& colliders);
|
||||
void GetGrassColliders(float world_x, float world_y, std::set<ColliderComponent*>& colliders);
|
||||
void GetSpecColliders(long long flags, float world_x, float world_y,
|
||||
std::set<ColliderComponent*>& colliders);
|
||||
|
||||
private:
|
||||
int GetGridId(float world_x, float world_y);
|
||||
|
@ -289,6 +289,7 @@ void Player::ObstacleInteraction(Obstacle* entity)
|
||||
|
||||
void Player::LootInteraction(Loot* entity)
|
||||
{
|
||||
#if 0
|
||||
if (entity->pickuped ||
|
||||
entity->count <= 0) {
|
||||
return;
|
||||
@ -299,6 +300,7 @@ void Player::LootInteraction(Loot* entity)
|
||||
}
|
||||
entity->pickuped = true;
|
||||
room->RemoveObjectLater(entity);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::HumanInteraction(Human* hum)
|
||||
|
@ -594,10 +594,27 @@ void Room::RemoveObjectLater(Entity* entity)
|
||||
}
|
||||
break;
|
||||
case kET_Loot:
|
||||
{
|
||||
entity->BroadcastDeleteState();
|
||||
entity->room->grid_service.DelEntity(entity);
|
||||
entity->RemoveFromMapService();
|
||||
Loot* loot_entity = (Loot*)entity;
|
||||
if (loot_entity->airdrop_point_id != 0) {
|
||||
auto itr = loot_entity->room->airdrop_hash_.find(loot_entity->airdrop_point_id);
|
||||
if (itr != loot_entity->room->airdrop_hash_.end()) {
|
||||
itr->second.erase(loot_entity->entity_uniid);
|
||||
if (itr->second.empty()) {
|
||||
loot_entity->room->airdrop_hash_.erase(itr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kET_Hero:
|
||||
{
|
||||
entity->BroadcastDeleteState();
|
||||
entity->room->grid_service.DelEntity(entity);
|
||||
entity->RemoveFromMapService();
|
||||
}
|
||||
break;
|
||||
case kET_Player:
|
||||
|
@ -73,7 +73,6 @@ message Equip
|
||||
required int32 bullet_speed = 13; //子弹速度
|
||||
required int32 range = 14; //射程
|
||||
//required int32 use_time = 15; //使用时间
|
||||
required int32 heal = 16; //瞬间生命恢复
|
||||
required int32 time = 17; //时间
|
||||
//required string volume = 19; //装备容量
|
||||
required int32 bullet_rad = 20; //子弹半径
|
||||
@ -82,6 +81,7 @@ message Equip
|
||||
required string bullet_born_offset = 30; //子弹出生偏移
|
||||
required float bullet_angle = 34; //子弹浮动方向
|
||||
required string name = 35; //装备名字
|
||||
required int32 buff_id = 36;
|
||||
|
||||
//required string inventory_slot = 31; //库存槽位
|
||||
//required int32 _inventory_slot = 32; //库存槽位
|
||||
|
Loading…
x
Reference in New Issue
Block a user