本文整理汇总了C#中Monster.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Monster.Initialize方法的具体用法?C# Monster.Initialize怎么用?C# Monster.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monster
的用法示例。
在下文中一共展示了Monster.Initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadMonsters
/// <summary>
/// Loads the monsters from the file monsters.txt
/// </summary>
/// <param name="game">
/// The game object
/// </param>
private static void LoadMonsters(Game game)
{
if (FullModel.monsters != null) return;
StreamReader reader = new StreamReader(TitleContainer.OpenStream("monsters.txt"));
int n = int.Parse(reader.ReadLine());
string line;
List<Monster> monsters = new List<Monster>();
for (int i = 0; i < n; i++)
{
line = reader.ReadLine();
if (line.StartsWith("//")) continue;
string[] data = line.Split(',');
System.Diagnostics.Debug.Assert(data.Length == 11, "Error when parsing monsters, at line " + (i + 2));
int id = int.Parse(data[0]);
string name = data[1].Substring(1, data[1].Length - 2);
bool master = bool.Parse(data[2]);
int speed = int.Parse(data[3]);
int health = int.Parse(data[4].Split('/')[2]); // TODO: How many players are playing?
int armor = int.Parse(data[5]);
EAttackType type = data[6].Equals("MELEE")
? EAttackType.MELEE
: (data[5].Equals("MAGIC") ? EAttackType.MAGIC : EAttackType.RANGED);
List<Dice> attackDice = (
from string dice
in data[7].Split(' ')
select GetDice(dice)).ToList<Dice>();
List<Ability> abilities = data[8].Split('/').Select(Ability.GetAbility).ToList();
Rectangle size = new Rectangle(0, 0, int.Parse(data[9]), int.Parse(data[10]));
Texture2D texture = game.Content.Load<Texture2D>("Images/Monsters/" + id);
Monster m = new Monster(id, name, master, speed, health, armor, type, attackDice, abilities, size, texture);
m.Initialize();
monsters.Add(m);
}
FullModel.monsters = monsters;
System.Diagnostics.Debug.WriteLine("Monsters loaded successfully!");
}