public bool LoadCsv(string strContent) { if (strContent.Length == 0) { return(false); } m_mapElements.Clear(); m_vecAllElements.Clear(); int contentOffset = 0; List <string> vecLine; vecLine = GameAssist.readCsvLine(strContent, ref contentOffset); if (vecLine.Count != 8) { Ex.Logger.Log("WayPoint.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "waypoint_id") { Ex.Logger.Log("WayPoint.csv中字段[waypoint_id]位置不对应"); return(false); } if (vecLine[1] != " spawn_map_id") { Ex.Logger.Log("WayPoint.csv中字段[ spawn_map_id]位置不对应"); return(false); } if (vecLine[2] != "spawn_x") { Ex.Logger.Log("WayPoint.csv中字段[spawn_x]位置不对应"); return(false); } if (vecLine[3] != "spawn_y") { Ex.Logger.Log("WayPoint.csv中字段[spawn_y]位置不对应"); return(false); } if (vecLine[4] != "spawn_z") { Ex.Logger.Log("WayPoint.csv中字段[spawn_z]位置不对应"); return(false); } if (vecLine[5] != "waypoint_next_id") { Ex.Logger.Log("WayPoint.csv中字段[waypoint_next_id]位置不对应"); return(false); } if (vecLine[6] != "waypoint_animation") { Ex.Logger.Log("WayPoint.csv中字段[waypoint_animation]位置不对应"); return(false); } if (vecLine[7] != "waypoint_delay") { Ex.Logger.Log("WayPoint.csv中字段[waypoint_delay]位置不对应"); return(false); } while (true) { vecLine = GameAssist.readCsvLine(strContent, ref contentOffset); if ((int)vecLine.Count == 0) { break; } if ((int)vecLine.Count != (int)8) { return(false); } WayPointElement member = new WayPointElement(); member.waypoint_id = Convert.ToInt32(vecLine[0]); member.spawn_map_id = Convert.ToInt32(vecLine[1]); member.spawn_x = Convert.ToSingle(vecLine[2]); member.spawn_y = Convert.ToSingle(vecLine[3]); member.spawn_z = Convert.ToSingle(vecLine[4]); member.waypoint_next_id = Convert.ToInt32(vecLine[5]); member.waypoint_animation = vecLine[6]; member.waypoint_delay = Convert.ToInt32(vecLine[7]); member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.waypoint_id] = member; } return(true); }
private WayPointTable() { m_mapElements = new Dictionary <int, WayPointElement>(); m_emptyItem = new WayPointElement(); m_vecAllElements = new List <WayPointElement>(); }
public bool LoadBin(byte[] binContent) { m_mapElements.Clear(); m_vecAllElements.Clear(); int nCol, nRow; int readPos = 0; readPos += GameAssist.ReadInt32Variant(binContent, readPos, out nCol); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out nRow); List <string> vecLine = new List <string>(nCol); List <int> vecHeadType = new List <int>(nCol); string tmpStr; int tmpInt; for (int i = 0; i < nCol; i++) { readPos += GameAssist.ReadString(binContent, readPos, out tmpStr); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out tmpInt); vecLine.Add(tmpStr); vecHeadType.Add(tmpInt); } if (vecLine.Count != 8) { Ex.Logger.Log("WayPoint.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "waypoint_id") { Ex.Logger.Log("WayPoint.csv中字段[waypoint_id]位置不对应"); return(false); } if (vecLine[1] != " spawn_map_id") { Ex.Logger.Log("WayPoint.csv中字段[ spawn_map_id]位置不对应"); return(false); } if (vecLine[2] != "spawn_x") { Ex.Logger.Log("WayPoint.csv中字段[spawn_x]位置不对应"); return(false); } if (vecLine[3] != "spawn_y") { Ex.Logger.Log("WayPoint.csv中字段[spawn_y]位置不对应"); return(false); } if (vecLine[4] != "spawn_z") { Ex.Logger.Log("WayPoint.csv中字段[spawn_z]位置不对应"); return(false); } if (vecLine[5] != "waypoint_next_id") { Ex.Logger.Log("WayPoint.csv中字段[waypoint_next_id]位置不对应"); return(false); } if (vecLine[6] != "waypoint_animation") { Ex.Logger.Log("WayPoint.csv中字段[waypoint_animation]位置不对应"); return(false); } if (vecLine[7] != "waypoint_delay") { Ex.Logger.Log("WayPoint.csv中字段[waypoint_delay]位置不对应"); return(false); } for (int i = 0; i < nRow; i++) { WayPointElement member = new WayPointElement(); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.waypoint_id); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.spawn_map_id); readPos += GameAssist.ReadFloat(binContent, readPos, out member.spawn_x); readPos += GameAssist.ReadFloat(binContent, readPos, out member.spawn_y); readPos += GameAssist.ReadFloat(binContent, readPos, out member.spawn_z); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.waypoint_next_id); readPos += GameAssist.ReadString(binContent, readPos, out member.waypoint_animation); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.waypoint_delay); member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.waypoint_id] = member; } return(true); }