C# 运算符“*';无法应用于`方法组';和`浮动';

C# 运算符“*';无法应用于`方法组';和`浮动';,c#,unity3d,C#,Unity3d,我正在学习BurgZergArcade教程,学习如何创建一个Hack'N'Slash游戏。在此期间,我遇到了一个错误,如果有人能帮助我,我将不胜感激。语言是c# 错误:Assets/Scripts/Character Classes/ModifiedStat.cs(21,66):错误CS0019:运算符*'不能应用于类型为method group'和'float'的操作数 public class BaseStat { public class BaseStat { privat

我正在学习BurgZergArcade教程,学习如何创建一个Hack'N'Slash游戏。在此期间,我遇到了一个错误,如果有人能帮助我,我将不胜感激。语言是c#

错误:Assets/Scripts/Character Classes/ModifiedStat.cs(21,66):错误CS0019:运算符
*'不能应用于类型为
method group'和'float'的操作数

public class BaseStat {
    public class BaseStat {
    private int _baseValue;         //The base value of this stat
    private int _buffValue;         //The amount of buff to this stat
    private int _expToLevel;        //Thetotal amount of exp needed to raise this skill
    private float _levelModifier;   //The modifier applied to the exp needed to raise the skill

    public BaseStat() {
        _baseValue = 0;
        _buffValue = 0;
        _levelModifier = 1.1f;
        _expToLevel = 100;
    }

    public int BaseValue{
        get{ return _baseValue; }
        set{ _baseValue = value; }
    }
    public int BuffValue{
        get{ return _buffValue; }
        set{ _buffValue = value; }
    }
    public int ExpToLevel{
        get{ return _expToLevel; }
        set{ _expToLevel = value; }
    }
    public float LevelModifier{
        get{ return _levelModifier; }
        set{ _levelModifier = value; }
    }

    private int CalculateExpToLevel() {
        return (int)(_expToLevel * _levelModifier);
    }
    public void LevelUp() {
        _expToLevel = CalculateExpToLevel();
        _baseValue++;
    }
    public int AdjustedValue() {
        return _baseValue + _buffValue;
    }
}

public class Atrribute : BaseStat {
    public Atrribute() {
        ExpToLevel = 50;
        LevelModifier = 1.05f;
    }
}

public enum AttributeName{
Might,
Constitution,
Nimbleness,
Speed,
Concentration,
Willpower,
Charisma
}

public class ModifiedStat : BaseStat {
    private List<ModifyingAttribute> _mods;         //A list of Attributes that modify this stat
    private int _modValue;                          //

    public ModifiedStat(){
        _mods = new List<ModifyingAttribute>();
        _modValue = 0;
    }

    public void AddModifier( ModifyingAttribute mod ) {
        _mods.Add(mod);
    }

    private void CalculateModValue() {
        _modValue = 0;

        if(_mods.Count > 0)
            foreach( ModifyingAttribute att in _mods )
                _modValue += (int)(att.attribute.AdjustedValue * att.ratio);
    }
}

public struct ModifyingAttribute {
    public Atrribute attribute;
    public float ratio;
}
公共类BaseStat{
公共类BaseStat{
private int _baseValue;//此stat的基值
private int _buffValue;//此属性的buff量
private int _expToLevel;//提高此技能所需的经验总量
private float _levelModifier;//应用于提高技能所需经验的修饰符
公共BaseStat(){
_baseValue=0;
_buffValue=0;
_levelModifier=1.1f;
_expToLevel=100;
}
公共整数基值{
获取{return\u baseValue;}
设置{u baseValue=value;}
}
公共值{
获取{return\u buffValue;}
设置{u buffValue=value;}
}
公共int扩展级别{
获取{return\u expToLevel;}
设置{u expToLevel=value;}
}
公共浮动水平调整器{
获取{return\u levelModifier;}
设置{u levelModifier=value;}
}
private int CalculateExpToLevel(){
返回值(int)(_expToLevel*_levelModifier);
}
公共空间升级(){
_expToLevel=计算expToLevel();
_baseValue++;
}
公共整数调整值(){
返回_baseValue+_buffValue;
}
}
公共类属性:BaseStat{
公共属性(){
ExpToLevel=50;
LevelModifier=1.05f;
}
}
公共枚举属性名{
可以
宪法,,
灵活,,
速度
浓度
意志力,
魅力
}
公共类ModifiedStat:BaseStat{
私有列表_mods;//修改此状态的属性列表
私有int_modValue//
公共ModifiedStat(){
_mods=新列表();
_modValue=0;
}
公共无效添加修改器(修改属性修改器){
_mods.Add(mod);
}
私有void CalculateModValue(){
_modValue=0;
如果(_mods.Count>0)
foreach(修改mods中的属性att)
_modValue+=(int)(附件属性调整值*附件比率);
}
}
公共结构修改属性{
公共属性;
公众持股比例;
}

由于
BaseState.AdjustedValue
是一种方法,我会将
ModifiedStat.CalculateModValue()中的行更改为:

_modValue += (int)(att.attribute.AdjustedValue() * att.ratio);

请注意
()
之后的
调整后的值

因为
基本状态。调整后的值
是一种方法,我会将
修改后的stat.CalculateModValue()中的行更改为:

_modValue += (int)(att.attribute.AdjustedValue() * att.ratio);

请注意
()
之后的
调整后的值

因为
基本状态。调整后的值
是一种方法,我会将
修改后的stat.CalculateModValue()中的行更改为:

_modValue += (int)(att.attribute.AdjustedValue() * att.ratio);

请注意
()
之后的
调整后的值

因为
基本状态。调整后的值
是一种方法,我会将
修改后的stat.CalculateModValue()中的行更改为:

_modValue += (int)(att.attribute.AdjustedValue() * att.ratio);

请注意
()<代码> >代码> ApdiestDr值< /C> > ./P>沿着这些行的消息几乎总是指示调用方法名称后忘记了括号。当调用方法名称时,括号后面的位置,考虑使用隐式实现的属性和后退字段,因为这将显著清除这些代码中的代码段,几乎总是指示调用方法名称后忘记了括号。S和Buffes字段,因为这将大大清理您的代码框沿这些行几乎总是指示您忘记了一个方法名称后的括号调用它。作为一个例外,考虑使用隐式实现的属性和支持字段,因为这将大大清理你的code@Maarten我也犯了同样的错误这行代码
bPointP0=points[2]+(Vector3.Lerp(points[0],reflectedCp1,t)-points[2])。标准化*(points[0]-points[2])。量级;
@Maarten我得到了与这行代码
bPointP0=points[2]+(Vector3.Lerp(points[0],reflectedCp1,t)-points[2])相同的错误。标准化*(points[0]-points[2]).magnity;
@Maarten我在这行代码中得到了相同的错误
bPointP0=points[2]+(Vector3.Lerp(points[0],reflectedCp1,t)-points[2])。归一化*(points[0]-points[2])。magnity;
@Maarten我在这行代码中得到了相同的错误
bPointP0=points[2]+(Vector3.Lerp(points[0],反射CP1,t)-点[2])。归一化*(点[0]-点[2])。幅值;