本文整理汇总了C#中ICharacter.Atack方法的典型用法代码示例。如果您正苦于以下问题:C# ICharacter.Atack方法的具体用法?C# ICharacter.Atack怎么用?C# ICharacter.Atack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICharacter
的用法示例。
在下文中一共展示了ICharacter.Atack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Choose
private int Choose(ICharacter player)
{
ICharacter target = new Enemy();
var random = new Random();
ConsoleKeyInfo option = Console.ReadKey(true);
switch (option.Key)
{
case ConsoleKey.Escape:
Environment.Exit(0);
break;
case ConsoleKey.A:
player.Move(Direction.Up);
break;
case ConsoleKey.B:
player.Atack(target);
break;
}
return random.Next(0, 1980);
}
示例2: Input
private void Input(ICharacter player)
{
var info = Console.ReadKey();
switch (info.Key)
{
case ConsoleKey.Spacebar:
var ninja = Enemies.FirstOrDefault();
player.Atack(ninja);
if (ninja != null && ninja.Blood == 0)
{
Enemies.Remove(ninja);
}
break;
case ConsoleKey.LeftArrow:
player.Move(Direction.Left);
break;
case ConsoleKey.UpArrow:
player.Move(Direction.Up);
break;
case ConsoleKey.RightArrow:
player.Move(Direction.Right);
break;
case ConsoleKey.DownArrow:
player.Move(Direction.Down);
break;
}
}