void Start() { parser = GameObject.FindObjectOfType <ParseLevels>(); Text[] texts = GameObject.FindObjectsOfType <Text>(); for (int i = 0; i < texts.Length; ++i) { if (texts[i].name == "Rules") { rules = texts[i]; return; } } }
// Start is called before the first frame update void Start() { gameWin = false; enemies = new ArrayList(); levels = new ArrayList(); try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(new StringReader(xmlRawFile.text)); XmlNode patterns = xmlDoc.DocumentElement; if (patterns.Name == "patterns") { if (patterns.ChildNodes[0].Name == "enemies") { foreach (XmlNode enemy in patterns.ChildNodes[0].ChildNodes) { string enemy_name = enemy.Attributes["name"].Value; ParseEnemy parseEnemy = new ParseEnemy(enemy_name, enemy); enemies.Add(parseEnemy); } } else { throw new ParsingError("patterns should have enemies"); } if (patterns.ChildNodes[1].Name == "levels") { foreach (XmlNode level in patterns.ChildNodes[1].ChildNodes) { int level_number = int.Parse(level.Attributes["number"].Value); ParseLevels parseLevels = new ParseLevels(level_number, level); levels.Add(parseLevels); } } else { throw new ParsingError("patterns should have enemies"); } } else { throw new ParsingError("root name should be patterns"); } } catch (Exception e) { Debug.LogError(e); } }
// Use this for initialization void Start() { meal = new List <GameObject>(); parser = GameObject.FindObjectOfType <ParseLevels>(); }