CS1501“没有重载方法'权重'需要'0'参数”

时间:2015-09-30 17:05:30

标签: c# unity3d monodevelop

我在Unity Engine中遇到以下类的错误。

错误:

No overload for method 'Weight' takes '0' arguments

儿童班:

using UnityEngine;
using System.Collections;

public class CreateHammerstone : MonoBehaviour {



private BaseTool newTool;

void Start(){
    Debug.Log (newTool.Weight());

}



public void CreateTool() {

    newTool = new BaseTool ();

    //assign name to tool
    newTool.ItemName = "Hammer Stone";
    //Create a weapon description
    newTool.ItemDescription = "The Hammer Stone is a rather universal blunt tool that is primarly used to strike off lithic flakes in the procces of stone tool crafting. Alternatively it can also be used to breaking hard nuts,shells etc. Or executing small prey"; 
    //Tool ID
    newTool.ItemID = 1;
    //stats
    newTool.Density = 2.6f; //gram pr cm3 
    newTool.Volume = 360f;  //cm3
    newTool.Weight(newTool.Density, newTool.Volume); // HERE IS THE ISSUE!!!!
    //Choose type of Tool
    newTool.ToolType = BaseTool.ToolTypes.CRAFTING;

}
}

家长班:

using UnityEngine;
using System.Collections;

public class BaseStatsItem : BaseItem {

private float volume;
private float density;
private int willPower;
private int perception;
private int intelligence;




public float Volume {
    get {return volume;}
    set {volume = value;} 
}
public float Density {
    get { return density;}
    set { density = value;}
}

public int WillPower{
    get {return willPower;}
    set {willPower = value;}
}
public int Perception{
    get {return perception;}
    set {perception = value;}
}
public int Intelligence{
    get {return intelligence;}
    set {intelligence = value;}
}

public float Weight(float density, float volume){ // here is the function!!
    float sum = density * volume;
    return sum;  
}




}

正如你所看到的,似乎没有任何争议。我想这是因为体积和密度与权重函数同时分配,因此它们仍然没有要检索的权重函数的信息。我对吗?以及如何解决这个问题?

0 个答案:

没有答案