// 读取XML void ReadXML() { m_enemylist = new ArrayList(); XMLParser xmlparse = new XMLParser(); XMLNode node = xmlparse.Parse(xmldata.text); XMLNodeList list = node.GetNodeList("ROOT>0>table"); for (int i = 0; i < list.Count; i++) { string wave = node.GetValue("ROOT>0>table>" + i + ">@wave"); string enemyname = node.GetValue("ROOT>0>table>" + i + ">@enemyname"); string level = node.GetValue("ROOT>0>table>" + i + ">@level"); string wait = node.GetValue("ROOT>0>table>" + i + ">@wait"); SpawnData data = new SpawnData(); data.wave = int.Parse(wave); data.enemyname = enemyname; data.level = int.Parse(level); data.wait = float.Parse(wait); m_enemylist.Add(data); } }
private void ParseAnnounce() { XMLNode xn = XMLParser.Parse(curAnnounce); date = xn.GetValue("note>0>date>0>_text"); content = xn.GetValue("note>0>content>0>_text"); }
public void Awake() { XMLNode xml = XMLParser.Parse((Resources.Load("level", typeof(TextAsset)) as TextAsset).text); XMLNodeList tilesXML = xml.GetNodeList("doc>0>tiles>0>tile"); for (int i = 0; i < tilesXML.Count; i++) { XMLNode tileXML = tilesXML[i] as XMLNode; Tile tile = new Tile(); tile.type = tileXML.GetValue("@type"); XMLNodeList enemiesXML = tileXML.GetNodeList("enemies>0>enemy"); for (int j = 0; j < enemiesXML.Count; j++) { XMLNode enemyXML = enemiesXML[j] as XMLNode; Enemy enemy = new Enemy(); enemy.type = enemyXML.GetValue("@type"); enemy.position = new Vector3( float.Parse(enemyXML.GetValue("@x")), 0, float.Parse(enemyXML.GetValue("@z")) ); tile.enemies.Add(enemy); } tiles.Add(tile); } }
//public override void FromXML(XmlNode node, CameraPath cameraPath) //{ // base.FromXML(node, cameraPath); // time = float.Parse(node["time"].FirstChild.Value); // introStartEasePercentage = float.Parse(node["introStartEasePercentage"].FirstChild.Value); // outroEndEasePercentage = float.Parse(node["outroEndEasePercentage"].FirstChild.Value); // introCurve = XMLVariableConverter.FromXMLtoAnimationCurve(node["introCurve"]); // outroCurve = XMLVariableConverter.FromXMLtoAnimationCurve(node["outroCurve"]); //} public override void FromXML(XMLNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); time = float.Parse(node.GetValue("time>0>_text")); introStartEasePercentage = float.Parse(node.GetValue("introStartEasePercentage>0>_text")); outroEndEasePercentage = float.Parse(node.GetValue("outroEndEasePercentage>0>_text")); introCurve = XMLVariableConverter.FromXMLtoAnimationCurve(node.GetNode("introCurve>0")); outroCurve = XMLVariableConverter.FromXMLtoAnimationCurve(node.GetNode("outroCurve>0")); }
public override void ParseNode(XMLNode node) { this.text = node.GetValue("@text"); this.duration = Convert.ToSingle(node.GetValue("@duration")); if (duration <= 0f) { duration = 2f; } }
public override void ParseNode(XMLNode node) { this.value = Convert.ToSingle(node.GetValue("@value")); this.duration = Convert.ToSingle(node.GetValue("@duration")); this.block = Convert.ToBoolean(node.GetValue("@block")); if (value > 0f) { value = 1 / value; } }
/// <summary> /// Create a new Cell /// </summary> /// <param name="cellElement">Cell</param> /// <param name="sharedStrings">The collection of shared strings used by this document</param> internal Cell(XMLNode cellElement, SharedStrings sharedStrings) { bool iShareString = cellElement.GetValue("@t") == "s"; string columnName = cellElement.GetValue("@r"); this.ColumnIndex = GetExcelColumnNumber(columnName); this.Value = cellElement.GetValue("v>0>_text"); if (this.Value != null && iShareString) { this.Value = sharedStrings.GetString(this.Value); } }
public override void ParseNode(XMLNode node) { this.createId = node.GetValue("@id"); this.targetX = Convert.ToSingle(node.GetValue("@targetX")); this.targetY = Convert.ToSingle(node.GetValue("@targetY")); this.speed = Convert.ToInt32(node.GetValue("@speed")); this.block = Convert.ToBoolean(node.GetValue("@block")); if (this.speed <= 0f) { speed = Global.ROLE_RUN_SPEED; } }
private void LoadRandomNameCallback(TextAsset nameText) { string text = nameText.ToString(); /* text = text.Replace("\r\n", "").Replace("\t", ""); * int sin, dou, nam; * string douStr, namStr; * sin = text.IndexOf("//单姓"); * dou = text.IndexOf("//复姓"); * nam = text.IndexOf("//名字"); * singleFamilys = text.Substring(sin + 4, dou - sin - 4); * douStr = text.Substring(dou + 4, nam - dou - 4); * namStr = text.Substring(nam + 4); * //sinStr=sinStr.Replace("\"", "").Replace(" +", ""); * //douStr=douStr.Replace("[\"","").Replace("\"];",""); * //namStr = namStr.Replace("[\"", "").Replace("\"];", ""); * //doubleFamilys = Regex.Split(douStr, "\",\"", RegexOptions.IgnoreCase); * //firstNames = Regex.Split(namStr, "\",\"", RegexOptions.IgnoreCase); * * douStr = douStr.Replace("\",\"", "|"); * douStr = douStr.Replace("\"", ""); * doubleFamilys = douStr.Split('|'); * * namStr = namStr.Replace("\",\"", "|"); * namStr = namStr.Replace("\"", ""); * firstNames = namStr.Split('|');*/ XMLNode xml = XMLParser.Parse(text); string spec = xml.GetValue("root>0>special>0>_text"); _specialName = spec.Split(','); string manS = xml.GetValue("root>0>man>0>single>0>_text"); _manSingleName = manS.Split(','); string manD = xml.GetValue("root>0>man>0>double>0>_text"); _manDoubleName = manD.Split(','); string womanS = xml.GetValue("root>0>women>0>single>0>_text"); _womanSingleName = womanS.Split(','); string womanD = xml.GetValue("root>0>women>0>double>0>_text"); _womanDoubleName = womanD.Split(','); RandomRole(null); }
//public override void FromXML(XmlNode node, CameraPath cameraPath) //{ // base.FromXML(node, cameraPath); // rotation.x = float.Parse(node["rotationX"].FirstChild.Value); // rotation.y = float.Parse(node["rotationY"].FirstChild.Value); // rotation.z = float.Parse(node["rotationZ"].FirstChild.Value); // rotation.w = float.Parse(node["rotationW"].FirstChild.Value); // if (node["lookAt"] != null && node["lookAt"].HasChildNodes) // lookAt = GameObject.Find(node["lookAt"].FirstChild.Value).transform; //} public override void FromXML(XMLNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); rotation.x = float.Parse(node.GetValue("rotationX>0>_text")); rotation.y = float.Parse(node.GetValue("rotationY>0>_text")); rotation.z = float.Parse(node.GetValue("rotationZ>0>_text")); rotation.w = float.Parse(node.GetValue("rotationW>0>_text")); string strLookAt = node.GetValue("lookAt>0>_text"); if (strLookAt != null) { lookAt = GameObject.Find(strLookAt).transform; } }
public void StartWave() { int numberSpawned = 0; float offset = 400f; waveXML = wavesXML[wave] as XMLNode; string uniqueValue = waveXML.GetValue("@unique"); if (uniqueValue != "") { int unique = int.Parse(uniqueValue); } int dc = int.Parse(waveXML.GetValue("@dc")); int toSpawn = int.Parse(waveXML.GetValue("@tospawn")); while (toSpawn > 0) { int x = dc - 1; XMLNode enemyXML = enemiesXML[x] as XMLNode; Enemy e = Instantiate(Resources.Load("Enemies/" + enemyXML.GetValue("@type"), typeof(Enemy)) as Enemy) as Enemy; e.Birth(enemyXML); enemies.Add(e); e.index = enemies.IndexOf(e); e.name = e.name.Split("("[0])[0]; toSpawn--; Transform spawner = GameObject.Find("Spawner").transform; e.transform.position = new Vector3(spawner.position.x, spawner.position.y + (offset * numberSpawned), -20f); numberSpawned++; } wave++; enemiesLeft = numberSpawned; GameObject btn; btn = GameObject.Find("BtnReady"); btn.GetComponent <Collider>().enabled = false; btn.GetComponent <Renderer>().enabled = false; }
public void Birth(XMLNode e){ gameplay = Gameplay.Instance(); currentTile = 0; status = "Fine"; type = e.GetValue("@type"); maxHealth = int.Parse(e.GetValue("@health")); health = int.Parse(e.GetValue("@health")); movementSpeed = (float)int.Parse(e.GetValue("@movement")); goldValue = int.Parse(e.GetValue("@gold")); xpValue = int.Parse(e.GetValue("@xp")); damage = int.Parse(e.GetValue("@damage")); range = int.Parse(e.GetValue("@range")); attackSpeed = int.Parse(e.GetValue("@speed")); attackCooldown = attackSpeed; string value = e.GetValue("@flying"); if(value == "true") flying = true; else flying = false; if(type != "Fairy") ranged = false; else ranged = true; detecting = false; focusIndex = 0; SphereCollider detection = transform.Find("Detection").GetComponent<SphereCollider>(); detection.radius = range; transform.position = new Vector3(transform.position.x, transform.position.y, -20f); TextMesh textMesh; textMesh = transform.Find("CI").Find("Name").GetComponent<TextMesh>(); textMesh.text = type; healthBar = transform.Find("CI/Health/Bar").gameObject; healthBarWidth = healthBar.transform.localScale.x; transform.parent = GameObject.Find("Enemies").transform; index = gameplay.enemies.IndexOf(this); }
/// <summary> /// Create a new Cell /// </summary> /// <param name="cellElement">Cell</param> /// <param name="sharedStrings">The collection of shared strings used by this document</param> public Cell(XMLNode cellElement, SharedStrings sharedStrings) { bool isTextRow = cellElement.GetValue("@t") == "s"; string columnName = cellElement.GetValue("@r"); this.ColumnNumber = GetExcelColumnNumber(columnName); if (isTextRow) { string textValue = cellElement.GetValue("v>0>_text"); this.Value = sharedStrings.GetString(textValue); } else { this.Value = cellElement.GetValue("_text"); } }
void PopulateGrid() { int _numOf_Coordinates = LevelXML.GetNodeList("LevelsContainer>0>Coordinates>0>Level" + GamePrefs.CURRENT_LEVEL + ">0>value").Count; for (int i = 0; i < _numOf_Coordinates; i++) { string _attribute_x_ValueString = LevelXML.GetValue("LevelsContainer>0>Coordinates>0>Level" + GamePrefs.CURRENT_LEVEL + ">0>value>" + i + ">@attribute_i"); int _attribute_x_ValueInt; int.TryParse(_attribute_x_ValueString, out _attribute_x_ValueInt); string _attribute_y_ValueString = LevelXML.GetValue("LevelsContainer>0>Coordinates>0>Level" + GamePrefs.CURRENT_LEVEL + ">0>value>" + i + ">@attribute_j"); int _attribute_y_ValueInt; int.TryParse(_attribute_y_ValueString, out _attribute_y_ValueInt); BubbleProperties b_property = GameManager.FindObjectOfType <GameManager>().MatrixGrid[_attribute_x_ValueInt][_attribute_y_ValueInt].GetComponent <BubbleProperties>(); GameManager.FindObjectOfType <GameManager>().MatrixGrid[_attribute_x_ValueInt][_attribute_y_ValueInt].GetComponent <BubbleProperties>().isEmpty = false; switch (LevelXML.GetValue("LevelsContainer>0>Coordinates>0>Level" + GamePrefs.CURRENT_LEVEL + ">0>value>" + i + ">@attribute_color")) { case "Green": b_property.BubbleColor = ColorProperty.Green; break; case "Yellow": b_property.BubbleColor = ColorProperty.Yellow; break; case "Blue": b_property.BubbleColor = ColorProperty.Blue; break; case "Red": b_property.BubbleColor = ColorProperty.Red; break; case "Purple": b_property.BubbleColor = ColorProperty.Purple; break; case "Black": b_property.BubbleColor = ColorProperty.Black; break; } } }
private void LevelUp() { if (lv < 20) { levelXML = levelsXML[lv] as XMLNode; lv++; damage = int.Parse(levelXML.GetValue("@damage")); attackSpeed = int.Parse(levelXML.GetValue("@speed")); range = float.Parse(levelXML.GetValue("@range")); maxHealth = int.Parse(levelXML.GetValue("@health")); health = maxHealth; toNextLevel += int.Parse(levelXML.GetValue("@next")); SphereCollider detection = transform.Find("Detection").GetComponent <SphereCollider>(); detection.radius = range; } }
// 读取规则XML private void ReadSpeed() { XMLParser xmlparse = new XMLParser(); XMLNode node = xmlparse.Parse(_xmldata.text); XMLNodeList list = node.GetNodeList("ROOT>0>table"); for (int i = 0; i < list.Count; i++) { string id = node.GetValue("ROOT>0>table>" + i + ">@id"); string speedv = node.GetValue("ROOT>0>table>" + i + ">@speedv"); string speedh = node.GetValue("ROOT>0>table>" + i + ">@speedh"); ItemSpeed itemSpeed = new ItemSpeed(); itemSpeed.id = int.Parse(id); itemSpeed.speed_V = (double)(double.Parse(speedv) / 10); itemSpeed.speed_H = (double)(double.Parse(speedh) / 10); _speedListR.Add(itemSpeed); } }
// 读取规则XML private void ReadRule() { XMLParser xmlparse = new XMLParser(); XMLNode node = xmlparse.Parse(_xmldata.text); XMLNodeList list = node.GetNodeList("ROOT>0>table"); for (int i = 0; i < list.Count; i++) { string id = node.GetValue("ROOT>0>table>" + i + ">@id"); string ruleName = node.GetValue("ROOT>0>table>" + i + ">@rulename"); string rule = node.GetValue("ROOT>0>table>" + i + ">@rule"); RuleData ruleData = new RuleData(); ruleData.id = int.Parse(id); ruleData.ruleName = ruleName; ruleData.rule = rule; _ruleListR.Add(ruleData); } }
public void FromXML(XMLNode xml) { if (xml == null) { return; } //GameObject animationObjectGO = GameObject.Find(xml["animationObject"].FirstChild.Value); //if (animationObjectGO != null) // animationObject = animationObjectGO.transform; //GameObject orientationTargetGO = GameObject.Find(xml["orientationTarget"].FirstChild.Value); //if (orientationTargetGO != null) // orientationTarget = orientationTargetGO.transform; //_animateSceneObjectInEditor = bool.Parse(xml["animateSceneObjectInEditor"].FirstChild.Value); //playOnStart = bool.Parse(xml["playOnStart"].FirstChild.Value); //animationMode = (animationModes)Enum.Parse(typeof(animationModes), xml["animationMode"].FirstChild.Value); //orientationMode = (orientationModes)Enum.Parse(typeof(orientationModes), xml["orientationMode"].FirstChild.Value); //normalised = bool.Parse(xml["normalised"].FirstChild.Value); //_pathSpeed = float.Parse(xml["pathSpeed"].FirstChild.Value); GameObject animationObjectGO = GameObject.Find(xml.GetValue("animationObject>0>_text")); if (animationObjectGO != null) { animationObject = animationObjectGO.transform; } GameObject orientationTargetGO = GameObject.Find(xml.GetValue("orientationTarget>0>_text")); if (orientationTargetGO != null) { orientationTarget = orientationTargetGO.transform; } _animateSceneObjectInEditor = bool.Parse(xml.GetValue("animateSceneObjectInEditor>0>_text")); playOnStart = bool.Parse(xml.GetValue("playOnStart>0>_text")); animationMode = (animationModes)Enum.Parse(typeof(animationModes), xml.GetValue("animationMode>0>_text")); orientationMode = (orientationModes)Enum.Parse(typeof(orientationModes), xml.GetValue("orientationMode>0>_text")); normalised = bool.Parse(xml.GetValue("normalised>0>_text")); _pathSpeed = float.Parse(xml.GetValue("pathSpeed>0>_text")); }
private void Config() { //获取模式 string keyPath = LOCAL_BASE + @"\DevelopKey"; if (File.Exists(keyPath)) { this.APP_MODE = "2"; } else { this.APP_MODE = "1"; } string filePath = LOCAL_BASE + @"\config.xml"; //发布模式才需要读配置 if (this.APP_MODE.Equals("1")) { if (File.Exists(filePath)) { // 读取配置文件 string content = File.ReadAllText(filePath, Encoding.UTF8); XMLParser xp = new XMLParser(); XMLNode xn = xp.Parse(content); this.SHARE_PATH = @"\\" + xn.GetValue("Config>0>SERVER_IP>0>@value") + @"\upload"; this.SERVER_USERNAME = xn.GetValue("Config>0>SERVER_USERNAME>0>@value"); this.SERVER_PASSWORD = xn.GetValue("Config>0>SERVER_PASSWORD>0>@value"); } else { MessageBox.Show("文件:" + filePath + "不存在!"); } } else { this.SHARE_PATH = LOCAL_BASE; } }
public void LoadHeroInformation(int argument) { ClearInformation(); EnablePopup(); tavernLevel = Tavern.Instance().level; XMLNode heroXML = heroesXML[argument] as XMLNode; string className = heroXML.GetValue("@class"); XMLNode levelXML = heroXML.GetNodeList("levels>0>level")[tavernLevel] as XMLNode; Debug.Log(className); txtRange.text = "Range: " + levelXML.GetValue("@range"); txtDamage.text = "Damage: " + levelXML.GetValue("@damage"); txtSpeed.text = "Speed: " + levelXML.GetValue("@speed"); txtHealth.text = "Health: " + levelXML.GetValue("@health"); txtLevel.text = "LV " + tavernLevel.ToString(); txtName.text = className; }
public override void ParseNode(XMLNode node) { this.key = node.GetValue("@key"); this.duration = Convert.ToSingle(node.GetValue("@duration")); this.fadeInTime = Convert.ToSingle(node.GetValue("@fadeIn")); this.fadeOutTime = Convert.ToSingle(node.GetValue("@fadeOut")); this.fadeInAlpha = Convert.ToSingle(node.GetValue("@fadeInTo")); this.fadeOutAlpha = Convert.ToSingle(node.GetValue("@fadeOutTo")); }
public override void ParseNode(XMLNode node) { this.targetX = Convert.ToSingle(node.GetValue("@targetX")); this.targetY = Convert.ToSingle(node.GetValue("@targetY")); this.followId = node.GetValue("@followId"); this.reset = Convert.ToBoolean(node.GetValue("@reset")); this.speed = Convert.ToInt32(node.GetValue("@speed")); this.block = Convert.ToBoolean(node.GetValue("@block")); }
public override void ParseNode(XMLNode node) { this.createId = node.GetValue("@id"); this.resourceId = node.GetValue("@resourceId"); this.targetX = Convert.ToSingle(node.GetValue("@targetX")); this.targetY = Convert.ToSingle(node.GetValue("@targetY")); this.resourceType = node.GetValue("@resourceType"); this.dir = node.GetValue("@dir"); }
private void DevelopInit() { // 读取配置文件 try { string content = File.ReadAllText(this.SHARE_PATH + @"\Pfmd\config.xml", Encoding.UTF8); XMLParser xp = new XMLParser(); XMLNode xn = xp.Parse(content); this.URL_HEAD = xn.GetValue("Config>0>@UrlHead"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
void Awake() { //Time.timeScale = 0.2f; parser = new XMLParser(); LevelXML = parser.Parse(LevelXMLFile.text); int _numOf_Coordinates = LevelXML.GetNodeList("LevelsContainer>0>Coordinates>0>Level" + GamePrefs.CURRENT_LEVEL + ">0>colors").Count; GamePrefs.NO_OF_SCENE_COLORS = _numOf_Coordinates; for (int i = 0; i < _numOf_Coordinates; i++) { string _attribute_color_String = LevelXML.GetValue("LevelsContainer>0>Coordinates>0>Level" + GamePrefs.CURRENT_LEVEL + ">0>colors>" + i + ">@attribute"); int _attribute_color_ValueInt; int.TryParse(_attribute_color_String, out _attribute_color_ValueInt); GamePrefs.SCENE_COLORS[_attribute_color_ValueInt] = true; } //Objectives string level_objective = LevelXML.GetValue("LevelsContainer>0>Coordinates>0>Level" + GamePrefs.CURRENT_LEVEL + ">0>@attribute_objective"); GamePrefs.LEVEL_OBJECTIVE = level_objective; //Number of Bubbles in level string number_of_bubbles = LevelXML.GetValue("LevelsContainer>0>Coordinates>0>Level" + GamePrefs.CURRENT_LEVEL + ">0>@numberOfBubbles"); int attribute_num_of_bubbles; int.TryParse(number_of_bubbles, out attribute_num_of_bubbles); if (attribute_num_of_bubbles > 0) { GamePrefs.NO_OF_BUBBLES = attribute_num_of_bubbles; } GamePrefs.temp_no_of_bubbles = attribute_num_of_bubbles; }
public override void ParseNode(XMLNode node) { this.key = node.GetValue("@key"); this.startX = Convert.ToSingle(node.GetValue("@startX")); this.startY = Convert.ToSingle(node.GetValue("@startY")); this.time = Convert.ToSingle(node.GetValue("@time")) / 30; this.targetX = Convert.ToSingle(node.GetValue("@targetX")); this.targetY = Convert.ToSingle(node.GetValue("@targetY")); this.effectId = this.key; }
static int GetValue(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); XMLNode obj = (XMLNode)ToLua.CheckObject(L, 1, typeof(XMLNode)); string arg0 = ToLua.CheckString(L, 2); string o = obj.GetValue(arg0); LuaDLL.lua_pushstring(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
//public override void FromXML(XmlNode node, CameraPath cameraPath) //{ // base.FromXML(node, cameraPath); // type = (Types)System.Enum.Parse(typeof(Types), node["type"].FirstChild.Value); // eventName = node["eventName"].FirstChild.Value; // if (node["target"] != null && node["target"].HasChildNodes) // target = GameObject.Find(node["target"].FirstChild.Value); // if (node["methodName"] != null && node["methodName"].HasChildNodes) // methodName = node["methodName"].FirstChild.Value; // if (node["methodArgument"] != null && node["methodArgument"].HasChildNodes) // methodArgument = node["methodArgument"].FirstChild.Value; // argumentType = (ArgumentTypes)System.Enum.Parse(typeof(ArgumentTypes), node["argumentType"].FirstChild.Value); //} public override void FromXML(XMLNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); type = (Types)System.Enum.Parse(typeof(Types), node.GetValue("type>0>_text")); eventName = node.GetValue("eventName>0>_text"); if (node.GetValue("target>0>_text") != null) { target = GameObject.Find(node.GetValue("target>0>_text")); } if (node.GetValue("methodName>0>_text") != null) { methodName = node.GetValue("methodName>0>_text"); } if (node.GetValue("methodArgument>0>_text") != null) { methodArgument = node.GetValue("methodArgument>0>_text"); } argumentType = (ArgumentTypes)System.Enum.Parse(typeof(ArgumentTypes), node.GetValue("argumentType>0>_text")); }
public Row(XMLNode rowElement, SharedStrings sharedStrings) { try { this.RowNumber = int.Parse(rowElement.GetValue("@r")); } catch (Exception ex) { throw new Exception("Row Number not found", ex); } XMLNodeList cellList = rowElement.GetNodeList("c"); if (cellList != null && cellList.Count > 0) { this.Cells = GetCells(rowElement.GetNodeList("c"), sharedStrings); } }
internal Row(XMLNode rowElement, SharedStrings sharedStrings) { m_ColumnStart = 1; try { this.RowIndex = int.Parse(rowElement.GetValue("@r")); } catch (Exception ex) { throw new Exception("Row Number not found", ex); } XMLNodeList cellList = rowElement.GetDeepNodeList("c"); this.Cells = new List <Cell>(); if (cellList != null && cellList.Count > 0) { this.Cells = GetCells(cellList, sharedStrings); } }