public void ReadXml(XmlLoad X) { if (!X.Read()) return; switch (X.ElementName) { case "drawtile": Type = StepType.STEP_DRAWTILE; Player = X.GetIntAttribute("player"); Tile = X.GetIntAttribute("tile"); break; case "discardtile": Type = StepType.STEP_DISCARDTILE; Player = X.GetIntAttribute("player"); Tile = X.GetIntAttribute("tile"); Shanten = X.GetIntAttribute("shanten"); { int F = X.GetIntAttribute("furiten"); Furiten = (F == 1); } break; case "drawdeadtile": Type = StepType.STEP_DRAWDEADTILE; Player = X.GetIntAttribute("player"); Tile = X.GetIntAttribute("tile"); break; case "naki": Type = StepType.STEP_NAKI; Player = X.GetIntAttribute("player"); break; case "riichi1": Type = StepType.STEP_RIICHI; Player = X.GetIntAttribute("player"); break; case "riichi2": Type = StepType.STEP_RIICHI1000; Player = X.GetIntAttribute("player"); break; case "tsumo": Type = StepType.STEP_TSUMO; Player = X.GetIntAttribute("player"); break; case "ron": Type = StepType.STEP_RON; Player = X.GetIntAttribute("player"); FromWho = X.GetIntAttribute("from"); break; case "draw": Type = StepType.STEP_DRAW; Reason = X.GetIntAttribute("reason"); break; case "newdora": Type = StepType.STEP_NEWDORA; Tile = X.GetIntAttribute("tile"); break; case "disconnect": Type = StepType.STEP_DISCONNECT; Player = X.GetIntAttribute("player"); break; case "connect": Type = StepType.STEP_CONNECT; Player = X.GetIntAttribute("player"); break; } { XmlLoad Subtree = X.GetSubtree(); while (Subtree.Read()) { switch (Subtree.ElementName) { case "waiting": { List<int> W = new List<int>(); XmlLoad TileTypes = Subtree.GetSubtree(); while(TileTypes.Read()) { switch (TileTypes.ElementName) { case "tiletype": W.Add(TileTypes.GetIntAttribute("value")); break; } } TileTypes.Close(); if (W.Count > 0) Waiting = W.ToArray(); } break; case "danger": { List<int> D = new List<int>(); XmlLoad Tiles = Subtree.GetSubtree(); while (Tiles.Read()) { switch (Tiles.ElementName) { case "tile": D.Add(Tiles.GetIntAttribute("value")); break; } } Tiles.Close(); if (D.Count > 0) Danger = D.ToArray(); } break; case "nakidata": { NakiData = new Naki(); NakiData.ReadXml(Subtree); } break; } } Subtree.Close(); } }
public void ReadXml(XmlLoad X) { if (!X.Read()) return; switch (X.ElementName) { case "tiles": { int Count = X.GetIntAttribute("count"); int Index = 0; XmlLoad Subtree = X.GetSubtree(); for (int i = 0; i < Count; i++) { if (!Subtree.Read()) break; switch (Subtree.ElementName) { case "tile": Tiles[Index] = Subtree.GetIntAttribute("value"); Index++; break; } } Subtree.Close(); } break; case "naki": { int Count = X.GetIntAttribute("count"); XmlLoad Subtree = X.GetSubtree(); for (int i = 0; i < Count; i++) { Naki N = new Naki(); N.ReadXml(X); Naki.Add(N); } Subtree.Close(); } break; } }