public string GetPatcherString(stPatcherTable stData, int nStringIndex) { switch( nStringIndex) { case 1: return stData._str_1; case 2: return stData._str_2; case 3: return stData._str_3; case 4: return stData._str_4; case 5: return stData._str_5; default: return ""; } }
private void _LoadPatcherTable() { TextAsset xmlText = Resources.Load( "UseScript/PatcherTable") as TextAsset; byte[] encodedString = Encoding.UTF8.GetBytes( xmlText.text); MemoryStream memoryStream = new MemoryStream(encodedString); StreamReader streamReader = new StreamReader(memoryStream); StringReader stringReader = new StringReader(streamReader.ReadToEnd()); string str = stringReader.ReadToEnd(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(str); XmlNodeList xnList = xmlDoc.SelectNodes( "PatcherTable/Patcher"); foreach( XmlNode xn in xnList) { int nID = int.Parse( xn["ID"].InnerText); string strPath = ""; if( false == xn["FilePath"].InnerText.ToLower().Contains( "none")) strPath = xn["FilePath"].InnerText; int nTime = int.Parse( xn["Time"].InnerText); int nStr_1 = 0; if( false == xn["String_1"].InnerText.ToLower().Contains( "none")) nStr_1 = int.Parse( xn["String_1"].InnerText); int nStr_2 = 0; if( false == xn["String_2"].InnerText.ToLower().Contains( "none")) nStr_2 = int.Parse( xn["String_2"].InnerText); int nStr_3 = 0; if( false == xn["String_3"].InnerText.ToLower().Contains( "none")) nStr_3 = int.Parse( xn["String_3"].InnerText); int nStr_4 = 0; if( false == xn["String_4"].InnerText.ToLower().Contains( "none")) nStr_4 = int.Parse( xn["String_4"].InnerText); int nStr_5 = 0; if( false == xn["String_5"].InnerText.ToLower().Contains( "none")) nStr_5 = int.Parse( xn["String_5"].InnerText); stPatcherTable stData = new stPatcherTable( nID, strPath, nTime, GetPatcherString( nStr_1), GetPatcherString( nStr_2), GetPatcherString( nStr_3), GetPatcherString( nStr_4), GetPatcherString( nStr_5)); int nRes = nID / 100; int nResID = nID % 100; if( 1 == nRes) m_dPatcherTable_1.Add( nResID, stData); else if( 2 == nRes) m_dPatcherTable_2.Add( nResID, stData); else if( 3 == nRes) m_dPatcherTable_3.Add( nResID, stData); else if( 4 == nRes) m_dPatcherTable_4.Add( nResID, stData); else if( 5 == nRes) m_dPatcherTable_5.Add( nResID, stData); } memoryStream.Close(); streamReader.Close(); }