This commit is contained in:
aozhiwei 2019-09-09 18:00:45 +08:00
parent 71d32c05a2
commit ffa7f0982a
6 changed files with 51 additions and 14 deletions

View File

@ -206,3 +206,6 @@ const int MAX_TEAM_NUM = 4;
const int MAX_SYS_HTTP_NUM = 2;
const int MAX_USER_HTTP_NUM = 8;
const int MAX_ALL_HTTP_NUM = MAX_SYS_HTTP_NUM + MAX_USER_HTTP_NUM;
const int DEFAULT_BORN_POINT_X = 3000;
const int DEFAULT_BORN_POINT_Y = 3000;

View File

@ -116,6 +116,7 @@ class Human : public Entity
std::set<Human*> kill_humans;
Human* last_tank_attacker = nullptr;
long long last_tank_attack_idx = 0;
const BornPoint* born_point = nullptr;
bool shot_start = false;
bool shot_hold = false;

View File

@ -166,14 +166,18 @@ int Room::AliveCount()
void Room::AddPlayer(Player* hum)
{
assert(gas_data.gas_mode == GasInactive);
{
hum->pos.x = 3000 + rand() % 100;
hum->pos.y = 3000 + rand() % 200;
hum->attack_dir = hum->pos;
hum->attack_dir.Normalize();
hum->attack_dir.Rotate(a8::RandAngle());
hum->move_dir = hum->attack_dir;
hum->born_point = AllocBornPoint();
if (!hum->born_point) {
hum->pos.x = DEFAULT_BORN_POINT_X + rand() % 100;
hum->pos.y = DEFAULT_BORN_POINT_Y + rand() % 200;
} else {
hum->pos = hum->born_point->RandPoint();
}
hum->attack_dir = hum->pos;
hum->attack_dir.Normalize();
hum->attack_dir.Rotate(a8::RandAngle());
hum->move_dir = hum->attack_dir;
hum->entity_uniid = AllocUniid();
hum->room = this;
hum->join_frameno = frame_no;
@ -264,14 +268,18 @@ void Room::CreateAndroid(int robot_num)
hum->meta = hum_meta;
hum->robot_meta = robot_meta;
hum->entity_uniid = AllocUniid();
{
hum->pos.x = 3000 + rand() % 1400;
hum->pos.y = 3000 + rand() % 1500;
hum->attack_dir = hum->pos;
hum->attack_dir.Normalize();
hum->attack_dir.Rotate(a8::RandAngle());
hum->move_dir = hum->attack_dir;
hum->born_point = AllocBornPoint();
if (!hum->born_point) {
hum->pos.x = DEFAULT_BORN_POINT_X + rand() % 1400;
hum->pos.y = DEFAULT_BORN_POINT_Y + rand() % 1500;
} else {
hum->pos = hum->born_point->RandPoint();
}
hum->attack_dir = hum->pos;
hum->attack_dir.Normalize();
hum->attack_dir.Rotate(a8::RandAngle());
hum->move_dir = hum->attack_dir;
hum->room = this;
hum->Initialize();
uniid_hash_[hum->entity_uniid] = hum;
@ -1474,3 +1482,8 @@ void Room::NotifyWxVoip()
},
&xtimer_attacher.timer_list_);
}
BornPoint* Room::AllocBornPoint()
{
return nullptr;
}

View File

@ -120,6 +120,7 @@ private:
void OnGameOver();
void RandRemoveAndroid();
void NotifyWxVoip();
BornPoint* AllocBornPoint();
private:
int elapsed_time_ = 0;
@ -138,6 +139,7 @@ private:
std::map<int, Entity*> uniid_hash_;
std::map<int, Entity*> later_add_hash_;
std::map<int, Human*> human_hash_;
std::map<int, BornPoint> born_point_hash_;
std::map<int, CarObject> car_hash_;
std::map<int, Human*> removed_robot_hash_;

View File

@ -30,3 +30,9 @@ void Skin::ToPB(cs::MFSkin* pb_obj)
pb_obj->set_skin_id(skin_id);
pb_obj->set_skin_lv(skin_lv);
}
a8::Vec2 BornPoint::RandPoint() const
{
a8::Vec2 born_point = pos;
return born_point;
}

View File

@ -118,3 +118,15 @@ struct CarObject
a8::Vec2 pos;
bool taken = false;
};
struct BornPoint
{
int born_point_id = 0;
a8::Vec2 pos;
float rad = 0.0f;
int player_num = 0;
int android_num = 0;
a8::Vec2 RandPoint() const;
};