本文整理汇总了C#中Scanner.getNextWord方法的典型用法代码示例。如果您正苦于以下问题:C# Scanner.getNextWord方法的具体用法?C# Scanner.getNextWord怎么用?C# Scanner.getNextWord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner.getNextWord方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: loadInventory
/// <summary>
/// Loads a saved state of the inventory
/// </summary>
/// <param name="k"></param>
private void loadInventory(Scanner k)
{
string word = k.getNextWord();
while (!word.Equals("END_INVENTORY"))
{
string itemName = word;
Vector3 itemPosition = new Vector3(k.nextFloat(), k.nextFloat(), k.nextFloat());
float itemRotation = k.nextFloat();
GameObject item = Inventory.inv.makeItem(itemName);
item.transform.position = itemPosition;
if (itemName.Equals("DOOR"))
{
item.transform.rotation = Quaternion.Euler(270, itemRotation, 0);
}
else
{
item.transform.rotation = Quaternion.Euler(0, itemRotation, 0);
}
word = k.getNextWord();
}
}
示例2: loadWorkers
/// <summary>
/// Loads a saved state of workers
/// </summary>
/// <param name="k"></param>
private void loadWorkers(Scanner k)
{
string word = k.getNextWord();
while (!word.Equals("END_WORKERS"))
{
word = k.getNextWord();
}
}
示例3: loadGame
/// <summary>
/// Loads a saved game
/// </summary>
public void loadGame(string fileName = @"playersave.dat")
{
Scanner k;
try {
k = new Scanner(System.IO.File.ReadAllText(Application.persistentDataPath + @"\" + @fileName));
}
catch (FileNotFoundException e)
{
print("File not found");
return;
}
string word;
do
{
word = k.getNextWord();
switch (word)
{
case "NAME":
this.name = k.getNextWord();
break;
case "MONEY":
Inventory.inv.setMoney(k.nextInt());
break;
case "PAY":
Inventory.inv.setPay(k.nextInt());
break;
case "BOSSLEVEL":
LevelState.cur.setBossLevel(k.nextInt());
break;
case "INVENTORY":
loadInventory(k);
break;
case "WORKERS":
loadWorkers(k);
break;
default:
print("Error Parsing Save File: Unexpected Keyword '" + @word + "'");
return;
}
} while (k.hasNext());
}