This commit is contained in:
aozhiwei 2024-01-15 11:27:54 +08:00
parent 20de4d231c
commit 8cfc78be90
5 changed files with 45 additions and 10 deletions

View File

@ -3932,17 +3932,46 @@ void Creature::AdjustMobaBornDir()
void Creature::SetHeroLevel(int level, int exp, const mt::BattleHeroGrow* grow_meta) void Creature::SetHeroLevel(int level, int exp, const mt::BattleHeroGrow* grow_meta)
{ {
for (int buff_uniid : grow_buff_list_) {
RemoveBuffByUniId(buff_uniid);
}
grow_buff_list_.clear();
for (auto handle : grow_attr_list_) {
GetAbility()->RemoveAttr(handle);
}
grow_attr_list_.clear();
hero_level_ = level; hero_level_ = level;
hero_exp_ = exp; hero_exp_ = exp;
hero_grow_meta_ = grow_meta; hero_grow_meta_ = grow_meta;
if (hero_grow_meta_) {
{
auto attrs = hero_grow_meta_->GetLevelAttrs();
if (attrs) {
for (auto handle : grow_attr_list_) {
GetAbility()->RemoveAttr(handle);
}
grow_attr_list_.clear();
for (auto tuple : *attrs) {
auto handle = GetAbility()->AddAttr(std::get<0>(tuple), std::get<1>(tuple));
if (!handle.expired()) {
grow_attr_list_.push_back(handle);
}
}
}
}
{
auto effects = hero_grow_meta_->GetEquipEffects();
if (effects) {
for (int buff_uniid : grow_buff_list_) {
RemoveBuffByUniId(buff_uniid);
}
grow_buff_list_.clear();
for (int buff_id : *effects) {
TryAddBuff(this, buff_id);
}
}
}
if (hero_grow_meta_->GetSkillEffect()) {
for (auto& pair : skill_hash_) {
pair.second->LevelUp();
}
for (auto& pair : passive_skill_hash_) {
pair.second->LevelUp();
}
}
}
} }
int Creature::GetHeroLevel() int Creature::GetHeroLevel()

View File

@ -36,7 +36,7 @@ namespace mt
return nullptr; return nullptr;
} }
int BattleHeroGrow::GetSkilLEffect() const int BattleHeroGrow::GetSkillEffect() const
{ {
return 0; return 0;
} }

View File

@ -18,7 +18,7 @@ namespace mt
bool IsFullLevel() const; bool IsFullLevel() const;
std::shared_ptr<std::vector<std::tuple<int, float>>> GetLevelAttrs() const; std::shared_ptr<std::vector<std::tuple<int, float>>> GetLevelAttrs() const;
std::shared_ptr<std::vector<int>> GetEquipEffects() const; std::shared_ptr<std::vector<int>> GetEquipEffects() const;
int GetSkilLEffect() const; int GetSkillEffect() const;
private: private:
}; };

View File

@ -550,6 +550,11 @@ void Skill::LevelUp()
} }
} }
bool Skill::IsFullLevel()
{
return level_ == 4;
}
void Skill::Reset() void Skill::Reset()
{ {
Clear(); Clear();

View File

@ -56,6 +56,7 @@ class Skill
void Deactive() { actived_ = false; } void Deactive() { actived_ = false; }
bool IsMainSkill(); bool IsMainSkill();
void LevelUp(); void LevelUp();
bool IsFullLevel();
void Clear(); void Clear();
void Reset(); void Reset();
const mt::Skill* GetCurrSkillMeta(); const mt::Skill* GetCurrSkillMeta();