我想从我的基类中调用一个方法,该方法也有一个来自基类的变量:
class BaseClass
{
public string BaseClassMethod()
{
if (CheckKeyboard(Keys.Up))
return "Up";
if (CheckKeyboard(Keys.Down))
return "Down";
if (CheckKeyboard(Keys.Enter) && keyboardOn == true) <-- keyboardOn is a variable from my BaseClass that i want to be able to use :/
{
counter = 0; <-- counter is also one of those variables
return "Enter";
}
return "";
}
}
class InheritFromBase : BaseClass
{
public string Update()
{
currentKeyboard = Keyboard.GetState();
currentMouse = Mouse.GetState();
if (BaseClassMethod() == "Up")
if (selected > 0)
selected--;
else
selected = buttonList.Count - 1;
if (BaseClassMethod() == "Down")
if (selected < buttonList.Count - 1)
selected++;
else
selected = 0;
if (BaseClassMethod() == "Enter")
return buttonList[selected];
previousKeyboard = currentKeyboard;
previousMouse = currentMouse;
return "";
}
}
并且由于我从另一个类调用该方法,因此似乎无法访问他的变量(值)然后更改它们。请帮助:)谢谢