This commit is contained in:
aozhiwei 2019-08-28 16:18:40 +08:00
parent a8534e4aeb
commit 9ad76dcd62
5 changed files with 51 additions and 9 deletions

View File

@ -1862,6 +1862,7 @@ void Human::SendUIUpdate()
cs::SMUiUpdate notifymsg; cs::SMUiUpdate notifymsg;
notifymsg.set_alive_count(room->AliveCount()); notifymsg.set_alive_count(room->AliveCount());
notifymsg.set_kill_count(stats.kills); notifymsg.set_kill_count(stats.kills);
room->FillSMUiUpdate(notifymsg);
SendNotifyMsg(notifymsg); SendNotifyMsg(notifymsg);
} }

View File

@ -22,6 +22,7 @@
#include "app.h" #include "app.h"
#include "hero.h" #include "hero.h"
#include "gamelog.h" #include "gamelog.h"
#include "typeconvert.h"
const int ROOM_MAX_PLAYER_NUM = 50; const int ROOM_MAX_PLAYER_NUM = 50;
@ -344,14 +345,24 @@ void Room::CreateThings()
} else { } else {
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id); MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id);
if (equip_meta) { if (equip_meta) {
CreateLoot(equip_meta->i->id(), int entity_uniid = CreateLoot(equip_meta->i->id(),
a8::Vec2( a8::Vec2(
thing_tpl.i->x(), thing_tpl.i->x(),
thing_tpl.i->y() thing_tpl.i->y()
), ),
1, 1,
1 1
); );
if (entity_uniid && equip_meta->i->is_luck() == 2) {
Entity* loot_entity = GetEntityByUniId(entity_uniid);
if (loot_entity && loot_entity->entity_type == ET_Loot) {
CarObject car;
car.car_uniid = loot_entity->entity_uniid;
car.car_id = equip_meta->i->id();
car.pos = loot_entity->pos;
car_hash_[car.car_uniid] = car;
}
}
} }
} }
} }
@ -814,6 +825,17 @@ void Room::FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCo
} }
} }
void Room::FillSMUiUpdate(cs::SMUiUpdate& msg)
{
for (auto& pair : car_hash_) {
if (!pair.second.taken) {
cs::MFCar* car = msg.add_car_list();
car->set_car_id(pair.second.car_id);
TypeConvert::ToPb(pair.second.pos, car->mutable_pos());
}
}
}
std::set<Human*>* Room::GetAliveTeam() std::set<Human*>* Room::GetAliveTeam()
{ {
for (auto& pair : team_hash_) { for (auto& pair : team_hash_) {

View File

@ -91,6 +91,7 @@ public:
Entity* FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aabb_box); Entity* FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aabb_box);
void FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCollider* aabb_box, void FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCollider* aabb_box,
float& new_x, float& new_y); float& new_x, float& new_y);
void FillSMUiUpdate(cs::SMUiUpdate& msg);
private: private:
int AllocUniid(); int AllocUniid();
@ -135,5 +136,6 @@ private:
std::map<int, Entity*> later_add_hash_; std::map<int, Entity*> later_add_hash_;
std::map<int, Human*> human_hash_; std::map<int, Human*> human_hash_;
std::map<int, CarObject> car_hash_;
std::map<int, Human*> removed_robot_hash_; std::map<int, Human*> removed_robot_hash_;
}; };

View File

@ -110,3 +110,11 @@ struct HumanAbility
float def_add = 0.0f; float def_add = 0.0f;
float reflect_damage = 0.0f; float reflect_damage = 0.0f;
}; };
struct CarObject
{
int car_uniid = 0;
int car_id = 0;
a8::Vec2 pos;
bool taken = false;
};

View File

@ -610,6 +610,13 @@ message MFPlane
optional MFVector2D end_point = 2; // optional MFVector2D end_point = 2; //
} }
//
message MFCar
{
optional int32 car_id = 1; //id(equip表)
optional MFVector2D pos = 2; //
}
//end mfmsg //end mfmsg
// //
@ -672,6 +679,7 @@ message CMMove
optional int32 emote = 31; //id optional int32 emote = 31; //id
optional bool jump = 32; // optional bool jump = 32; //
optional bool get_down = 33; //
} }
// //
@ -835,4 +843,5 @@ message SMUiUpdate
{ {
optional int32 alive_count = 1; // optional int32 alive_count = 1; //
optional int32 kill_count = 2; // optional int32 kill_count = 2; //
} repeated MFCar car_list = 3; //
}