【问题标题】:No overload for method `CastSkill' takes `2' arguments方法'CastSkill'没有重载需要'2'参数
【发布时间】:2017-10-15 17:50:13
【问题描述】:

我是 Unity3d 编程的新手,我在 c# 中几乎不需要帮助。我的问题是我试图在不选择怪物的情况下施放技能。

所以代码是:

    if (EventSkillFinished()) {
        var skill = skills[currentSkill];

        // apply the skill on the target
       **CastSkill(skill, target);**

        if (nextSkill != -1) {
            currentSkill = nextSkill;
            nextSkill = -1;
        } else currentSkill = skill.followupDefaultAttack ? 0 : -1;

这里有一些代码

  public void CastSkill(Skill skill) {
        if (CastCheckSelf(skill, false) && CastCheckTarget(skill)) {
            // do the logic in here or let the skill effect take care of it?
            if (skill.effectPrefab == null || skill.effectPrefab.isPurelyVisual) {
                // attack
                if (skill.category == "Attack") {
                    // deal damage directly
                    DealDamageAt(target, damage + skill.damage, skill.aoeRadius);

【问题讨论】:

    标签: c# unity3d


    【解决方案1】:
    //This function takes one parameter:
    public void CastSkill(Skill skill) { ... }
    
    //This is passing two parameters:
    CastSkill(skill, target);
    

    你期待什么?

    您需要创建一个接受两个参数的新函数,一个用于正在使用的技能,另一个用于某个Type 的目标。

    【讨论】:

    • 有人对我说“你必须修改 CastSkill 以通过 (skill, target) 而不仅仅是 (skill)。然后从那里设置目标,完成。”对不起,我不擅长编程
    • @mhartiancruz 您需要修改public void CastSkill(Skill skill) 部分。具体来说,创建一个带有两个参数的新函数。
    猜你喜欢
    • 2016-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-23
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    相关资源
    最近更新 更多