代码输出结果和《c#实践入门:快捷学习c#编程和unity游戏开发 第四版》书上的不匹配
public class LearningCurve : MonoBehaviour
{
public bool pureOfHeart = true;
public bool hasSecretIncantation = false;
public string rareItem = "RelicStone";
// Start is called before the first frame update
void Start()
{
OpenTreasureChamber();
}
public void OpenTreasureChamber()
{
if (pureOfHeart && rareItem == "RelicStone")
{
if(!hasSecretIncantation)
{
Debug.Log("You have the spirit,but not the knowledge.");
}
else
{
Debug.Log("The treasure is yours,worthy hero");
}
}
else
{
Debug.Log("Come back when you have what it takes");
}
}
}
运行结果
Come back when you have what it takes
书上是
You have the spirit,but not the knowledge.