This commit is contained in:
wulongxiao 2024-12-23 20:00:58 +08:00
parent e5867b8d48
commit 2715420564
2 changed files with 58 additions and 82 deletions

View File

@ -9,100 +9,76 @@ public class SkillUp : MonoBehaviour
[Header("攻击范围加成倍数")] public float AttackRange = 1f;
[Header("攻击冷却加成倍速")] public float AttackCooldown = 1f;
[Header("攻击持续时间加成倍速")] public float AttackDuration = 1f;
[Header("攻击子弹数量加成")] public int NumberOfBullets = 1;
[Header("攻击子弹速度加成")] public float SpeedOfBullets = 1f;
[Header("攻击子弹数量加成倍速")] public int NumberOfBullets = 1;
[Header("攻击子弹速度加成倍速")] public float SpeedOfBullets = 1f;
[Header("暴击率倍率加成")]public float CritRate = 1f;
// 存储技能加成效果
private Dictionary<string, Dictionary<int, System.Action>> skillUpgrades = new Dictionary<string, Dictionary<int, System.Action>>();
void Start()
{
// 初始化技能加成升级
InitializeSkillUpgrades();
}
// 初始化技能加成升级
private void InitializeSkillUpgrades()
{
// 技能1的加成效果
skillUpgrades["Skill_1"] = new Dictionary<int, System.Action>
{
{ 1, Skill_1_1 },
{ 2, Skill_1_2 },
{ 3, Skill_1_3 },
{ 4, Skill_1_4 },
{ 5, Skill_1_5 }
};
// 技能2的加成效果
skillUpgrades["Skill_2"] = new Dictionary<int, System.Action>
{
{ 1, Skill_2_1 },
{ 2, Skill_2_2 },
{ 3, Skill_2_3 },
{ 4, Skill_2_4 },
{ 5, Skill_2_5 }
};
}
/// <summary>
/// 使用技能
/// </summary>
/// <param name="index">技能索引</param>
/// <param name="level">等级</param>
public virtual void UseSkill(int index, int level)
public void UseSkill(int index, int level)
{
switch (index)
string skillKey = $"Skill_{index}";
// 判断是否有这个技能
if (skillUpgrades.ContainsKey(skillKey) && skillUpgrades[skillKey].ContainsKey(level))
{
case 1:
switch (level)
{
case 1:
Skill_1_1();
break;
case 2:
Skill_1_2();
break;
case 3:
Skill_1_3();
break;
case 4:
Skill_1_4();
break;
case 5:
Skill_1_5();
break;
}
break;
case 2:
switch (level)
{
case 1:
Skill_2_1();
break;
case 2:
Skill_2_2();
break;
case 3:
Skill_2_3();
break;
case 4:
Skill_2_4();
break;
case 5:
Skill_2_5();
break;
}
break;
default:
Debug.LogWarning("没有这个技能");
break;
// 调用相应技能等级的效果
skillUpgrades[skillKey][level].Invoke();
}
else
{
Debug.LogWarning("没有这个技能或者技能等级无效");
}
}
public virtual void Skill_1_1()
{
}
public virtual void Skill_1_2()
{
DamageUp *= 1.15f;
}
public virtual void Skill_1_3()
{
}
public virtual void Skill_1_4()
{
DamageUp *= 1.35f;
}
public virtual void Skill_1_5()
{
}
public virtual void Skill_1_1() { }
public virtual void Skill_1_2() { DamageUp *= 1.15f; }
public virtual void Skill_1_3() { }
public virtual void Skill_1_4() { DamageUp *= 1.35f; }
public virtual void Skill_1_5() { }
public virtual void Skill_2_1()
{
}
public virtual void Skill_2_2()
{
DamageUp *= 1.15f;
}
public virtual void Skill_2_3()
{
DamageUp *= 1.35f;
}
public virtual void Skill_2_4()
{
}
public virtual void Skill_2_5()
{
}
public virtual void Skill_2_1() { }
public virtual void Skill_2_2() { DamageUp *= 1.15f; }
public virtual void Skill_2_3() { DamageUp *= 1.35f; }
public virtual void Skill_2_4() { }
public virtual void Skill_2_5() { }
}

View File

@ -19,7 +19,7 @@ public class mkl_SkillUp : SkillUp
base.SpeedOfBullets *= 1.3f;
}
/// <summary>
/// 每次攻击增加20%暴击率 。攻击CD增加5%
/// 攻击增加20%暴击率 。攻击CD增加5%
/// </summary>
public override void Skill_1_5()
{