This commit is contained in:
aozhiwei 2020-07-24 15:59:05 +08:00
parent 6eadc4c999
commit c68350eac4
2 changed files with 66 additions and 1 deletions

View File

@ -423,6 +423,47 @@ void Human::Shot(a8::Vec2& target_dir, bool& shot_ok)
shot_ok = true;
}
void Human::DirectShot(MetaData::Equip* bullet_meta, int skill_id, bool& shot_ok)
{
for (size_t i = 0; i < bullet_meta->bullet_born_offset.size(); ++i) {
auto& tuple = bullet_meta->bullet_born_offset[i];
room->xtimer.AddDeadLineTimerAndAttach
(std::get<0>(tuple) / FRAME_RATE_MS,
a8::XParams()
.SetSender(this)
.SetParam1(bullet_meta)
.SetParam2(a8::MakeInt64(skill_id, i))
.SetParam3(a8::MakeInt64(attack_dir.x * TEN_W, attack_dir.y * TEN_W)),
[] (const a8::XParams& param)
{
Human* sender = (Human*)param.sender.GetUserData();
MetaData::Equip* bullet_meta = (MetaData::Equip*)param.param1.GetUserData();
if (sender) {
int skill_id = a8::Low32(param.param2.GetInt64());
int offset_idx = a8::High32(param.param2.GetInt64());
float attack_x = a8::Low32(param.param3.GetInt64()) / (float)TEN_W;
float attack_y = a8::High32(param.param3.GetInt64()) / (float)TEN_W;
a8::Vec2 old_attack_dir = sender->attack_dir;
if (bullet_meta->bullet_born_offset.size() <= 1){
sender->attack_dir = a8::Vec2(attack_x, attack_y);
sender->attack_dir.Normalize();
}
sender->InternalShot(bullet_meta,
skill_id,
offset_idx);
sender->attack_dir = old_attack_dir;
}
},
&xtimer_attacher.timer_list_);
}
OnAttack();
}
void Human::InternalShot(MetaData::Equip* bullet_meta, int skill_id, size_t offset_idx)
{
}
void Human::TankShot(a8::Vec2& target_dir)
{
if (!tank_weapon.meta) {
@ -3229,9 +3270,32 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
switch (phase->func_id) {
case kSkill_TurnOver:
{
}
break;
case kSkill_JumpTo:
{
}
break;
case kSkill_Shot:
{
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(phase->param1.GetInt());
if (bullet_meta) {
a8::Vec2 old_attack_dir = attack_dir;
bool shot_ok = false;
DirectShot(bullet_meta, skill_meta_->i->skill_id(), shot_ok);
attack_dir = old_attack_dir;
}
}
break;
case kSkill_Pull:
{
}
break;
default:
{
}
break;
}
}
@ -3523,4 +3587,3 @@ void Human::ResetSkill()
skill_param1 = 0.0f;
playing_skill = false;
}

View File

@ -169,6 +169,7 @@ class Human : public MoveableEntity
long long GetRealDeadFrameNo(Room* room);
void FillMFTeamData(cs::MFTeamData* team_data, bool is_game_over);
void Shot(a8::Vec2& target_dir, bool& shot_ok);
void DirectShot(MetaData::Equip* bullet_meta, int skill_id, bool& shot_ok);
void TankShot(a8::Vec2& target_dir);
void RecalcSelfCollider();
bool IsCollisionInMapService();
@ -318,6 +319,7 @@ private:
std::set<GridCell*>& dec_grids);
void RemoveFromScene();
void ResetSkill();
void InternalShot(MetaData::Equip* bullet_meta, int skill_id, size_t offset_idx);
protected:
int level_ = 0;