This commit is contained in:
aozhiwei 2019-07-11 09:15:10 +08:00
parent 58cdec580c
commit d84652ec93
7 changed files with 78 additions and 6 deletions

View File

@ -14,11 +14,14 @@ void AndroidAI::Update(int delta_time)
hum->poisoning_time += delta_time;
}
state_elapsed_time += delta_time;
if (hum->dead) {
return;
}
if (hum->poisoning) {
hum->UpdatePoisoning();
}
if (hum->dead) {
return;
if (hum->playing_skill) {
hum->UpdateSkill();
}
switch (state) {
case AS_thinking:

View File

@ -17,6 +17,7 @@
#include "android.h"
#include "gamelog.h"
#include "typeconvert.h"
#include "obstacle.h"
#include "framework/cpp/utils.h"
#include "framework/cpp/httpclientpool.h"
@ -431,6 +432,21 @@ void Human::UpdatePoisoning()
}
}
void Human::UpdateSkill()
{
if (skill_meta) {
if (curr_skill_phase < skill_meta->phases.size()) {
MetaData::SkillPhase* phase = &skill_meta->phases[curr_skill_phase];
if (phase->time_offset > (room->frame_no - last_use_skill_frameno_) * FRAME_RATE_MS) {
ProcSkillPhase(phase);
++curr_skill_phase;
}
} else {
playing_skill = false;
}
}
}
void Human::SyncAroundPlayers()
{
for (auto& cell : grid_list) {
@ -647,18 +663,28 @@ bool Human::HasNoDownedTeammate()
void Human::DoSkill()
{
if (skill_meta && GetSkillLeftTime() <= 0) {
use_skill = false;
curr_skill_phase = 0;
skill_dir = a8::Vec2();
skill_target_pos = a8::Vec2();
skill_param1 = 0.0f;
playing_skill = true;
last_use_skill_frameno_ = room->frame_no;
Entity* entity = room->GetEntityByUniId(skill_target_id);
if (entity && entity->entity_type == ET_Player) {
Human* hum = (Human*)entity;
std::set<Entity*> target_list;
skill_target_pos = hum->pos;
SelectSkillTargets(hum->pos, target_list);
TriggerBuff(target_list, BTT_UseSkill);
if (!skill_meta->phases.empty() && skill_meta->phases[0].time_offset <= 0) {
UpdateSkill();
}
} else {
playing_skill = false;
}
}
use_skill = false;
skill_target_id = 0;
skill_dir = a8::Vec2();
skill_param1 = 0.0f;
}
void Human::FindLocation()
@ -1568,6 +1594,11 @@ void Human::Revive()
room->frame_event.AddRevive(this);
room->OnHumanRevive(this);
use_skill = false;
curr_skill_phase = 0;
skill_dir = a8::Vec2();
skill_param1 = 0.0f;
playing_skill = false;
}
void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list)
@ -1677,3 +1708,29 @@ Buff* Human::GetBuffByEffectId(int effect_id)
{
return IsValidBuffEffect(effect_id) ? buff_effect_[effect_id] : nullptr;
}
void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
{
switch (phase->func_id) {
case Skill_Jump:
{
}
break;
case Skill_Shot:
{
}
break;
case Skill_SummonObject:
{
Obstacle* obstacle = room->CreateObstacle(phase->param1.GetInt(), pos.x, pos.y);
if (obstacle) {
obstacle->master_id = entity_uniid;
}
}
break;
default:
break;
}
}

View File

@ -12,6 +12,7 @@ namespace MetaData
struct Dress;
struct Skill;
struct Tank;
struct SkillPhase;
}
enum HumanStatus
@ -121,7 +122,9 @@ class Human : public Entity
int curr_skill_phase = 0;
int skill_target_id = 0;
a8::Vec2 skill_dir;
a8::Vec2 skill_target_pos;
float skill_param1 = 0;
bool playing_skill = false;
Human();
virtual ~Human() override;
@ -142,6 +145,7 @@ class Human : public Entity
float GetRadius();
float GetMaxHP();
void UpdatePoisoning();
void UpdateSkill();
void SyncAroundPlayers();
void AutoLoadingBullet(bool manual = false);
void StartAction(ActionType_e action_type,
@ -218,6 +222,7 @@ private:
void Revive();
void SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list);
Buff* GetBuffById(int buff_id);
void ProcSkillPhase(MetaData::SkillPhase* phase);
protected:
long long last_shot_frameno_ = 0;

View File

@ -114,6 +114,9 @@ void Obstacle::FillMFObjectFull(cs::MFObjectFull* full_data)
p->set_health(health);
p->set_dead(dead);
p->set_dead_at_thisframe(dead ? dead_frameno <= room->frame_no : false);
if (master_id != 0) {
p->set_master_id(master_id);
}
p->set_is_door(is_door);
if (is_door) {

View File

@ -32,6 +32,7 @@ class Obstacle : public Entity
DoorState_e door_state = DoorStateClose;
Building* building = nullptr;
int door_house_uniid = 0;
int master_id = 0;
const metatable::DoorObjJson* door_state0 = nullptr;
const metatable::DoorObjJson* door_state1 = nullptr;

View File

@ -64,6 +64,9 @@ void Player::Update(int delta_time)
if (poisoning) {
UpdatePoisoning();
}
if (playing_skill) {
UpdateSkill();
}
if (select_weapon) {
UpdateSelectWeapon();
}

View File

@ -87,6 +87,7 @@ public:
std::set<Human*>* GetAliveTeam();
bool CanJoin(const std::string& accountid);
void OnPlayerOffline(Player* hum);
Obstacle* CreateObstacle(int id, float x, float y);
private:
int AllocUniid();
@ -98,7 +99,6 @@ private:
void AutoMatchTeam();
void MatchTeam(Human* hum);
int NewTeam();
Obstacle* CreateObstacle(int id, float x, float y);
void CreateThings();
void CreateBuilding(int thing_id, float building_x, float building_y);
Obstacle* InternalCreateObstacle(int id, float x, float y,