private Task ReadTask(XmlNode _taskNode) { Task task = new Task(); task.taskContnent = ((XmlElement)_taskNode.SelectSingleNode("TaskText")).InnerText; task.targetGameObject = ((XmlElement)_taskNode.SelectSingleNode("TaskText")).GetAttribute("targetGameObject"); foreach (XmlNode Xmlreward in _taskNode.SelectSingleNode("RewardList").ChildNodes) { Tool reward = new Tool(); reward.ToolName = ((XmlElement)Xmlreward).InnerText; reward.ToolType = ((XmlElement)Xmlreward).GetAttribute("ToolType"); string s = ((XmlElement)Xmlreward).GetAttribute("Value"); if (((XmlElement)Xmlreward).GetAttribute("Value") == "") { reward.value = 0; } else { reward.value = float.Parse(((XmlElement)Xmlreward).GetAttribute("Value")); } task.rewardList.Add(reward); } XmlNode commandNode = _taskNode.SelectSingleNode("storyCommand"); if (commandNode != null) { storyCommand story_command = new storyCommand(); story_command.commandType = ((XmlElement)commandNode).GetAttribute("commandType"); List <gameElement> gameObjList = new List <gameElement>(); XmlNodeList xmlgameList = commandNode.SelectSingleNode("gameObjectList").ChildNodes; foreach (XmlNode node in xmlgameList) { gameElement game = new gameElement(); XmlElement game_element = (XmlElement)node; game.gameObj = game_element.InnerText; game.position.x = float.Parse(game_element.GetAttribute("PositionX")); game.position.y = float.Parse(game_element.GetAttribute("PositionY")); game.position.z = float.Parse(game_element.GetAttribute("PositionZ")); gameObjList.Add(game); } story_command.gameList = gameObjList; task.story_command = story_command; } else { task.story_command = null; } return(task); }
private IEnumerator carryCommandStory(TaskCommand taskCommand) { storyCommand story = taskCommand.task.story_command; if (story != null) { if (story.commandType == "ChangePlace") { for (int i = 0; i < story.gameList.Count; i++) { GameObject.Find(story.gameList[i].gameObj).transform.position = story.gameList[i].position; } } } yield return(null); }