//填充Level类数据 public static void FillLevel(string fileName, ref FBLevel level) { FileInfo file = new FileInfo(fileName); StreamReader sr = new StreamReader(file.OpenRead(), Encoding.UTF8); XmlDocument doc = new XmlDocument(); doc.Load(sr); level.Name = doc.SelectSingleNode("/Level/Name").InnerText; level.CardImage = doc.SelectSingleNode("/Level/CardImage").InnerText; level.Background = doc.SelectSingleNode("/Level/Background").InnerText; level.Road = doc.SelectSingleNode("/Level/Road").InnerText; level.InitScore = int.Parse(doc.SelectSingleNode("/Level/InitScore").InnerText); XmlNodeList nodes; nodes = doc.SelectNodes("/Level/Holder/Point"); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; FBCoords p = new FBCoords( int.Parse(node.Attributes["X"].Value), int.Parse(node.Attributes["Y"].Value)); level.Holders.Add(p); } nodes = doc.SelectNodes("/Level/Path/Point"); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; FBCoords p = new FBCoords( int.Parse(node.Attributes["X"].Value), int.Parse(node.Attributes["Y"].Value)); level.Path.Add(p); } nodes = doc.SelectNodes("/Level/Rounds/Round"); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; FBRound r = new FBRound( int.Parse(node.Attributes["Monster"].Value), int.Parse(node.Attributes["Count"].Value) ); level.Rounds.Add(r); } sr.Close(); sr.Dispose(); }
IEnumerator RunRound() { f_roundIndex = -1; f_allRoundsComplete = false; for (int i = 0; i < f_rounds.Count; i++) { f_roundIndex = i; //回合开始 FBRoundStartArgs e = new FBRoundStartArgs { RoundIndex = f_roundIndex, RoundTotal = RoundTotal }; SendEvent(FBConsts.E_RoundStart, e); FBRound round = f_rounds[i]; for (int k = 0; k < round.Count; k++) { //出怪间隔 yield return(new WaitForSeconds(f_spawnInterval)); //出怪事件 FBSpawnMonsterArgs spawnArgs = new FBSpawnMonsterArgs { MonsterID = round.MonsterID }; SendEvent(FBConsts.E_SpawnMonster, spawnArgs); if (i == f_rounds.Count - 1 && k == round.Count - 1) { f_allRoundsComplete = true; } } //回合间隔 if (!f_allRoundsComplete) { yield return(new WaitForSeconds(f_roundInterval)); } } }