public void load(string path) { FileStream fs = File.OpenRead(path); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, (int)fs.Length); data = new GameUnitLevelUp[GameDefine.MAX_USER]; int[] id1 = new int[GameDefine.MAX_USER]; int index = 0; for (int i = 0; i < GameDefine.MAX_USER; ++i) { GameUnitLevelUp unit = new GameUnitLevelUp(); unit.ID = BitConverter.ToInt16(bytes, index); index += 2; unit.HP = BitConverter.ToInt16(bytes, index); index += 2; unit.MP = BitConverter.ToInt16(bytes, index); index += 2; unit.StrBase = BitConverter.ToInt16(bytes, index); index += 2; unit.StrRand = BitConverter.ToInt16(bytes, index); index += 2; unit.IntBase = BitConverter.ToInt16(bytes, index); index += 2; unit.IntRand = BitConverter.ToInt16(bytes, index); index += 2; unit.AvgBase = BitConverter.ToInt16(bytes, index); index += 2; unit.AvgRand = BitConverter.ToInt16(bytes, index); index += 2; unit.VitBase = BitConverter.ToInt16(bytes, index); index += 2; unit.VitRand = BitConverter.ToInt16(bytes, index); index += 2; unit.LukBase = BitConverter.ToInt16(bytes, index); index += 2; unit.LukRand = BitConverter.ToInt16(bytes, index); index += 2; data[unit.ID] = unit; id1[i] = unit.ID; } for (int i = 0; i < GameDefine.MAX_USER; ++i) { for (int j = 0; j < GameDefine.MAX_SLOT; j++) { GameUnitLevelUpSkillLearn unit = new GameUnitLevelUpSkillLearn(); unit.LV = BitConverter.ToInt16(bytes, index); index += 2; for (int k = 0; k < (int)GameSpiritType.Count; k++) { unit.SpiritRequest[k] = BitConverter.ToInt16(bytes, index); index += 2; } unit.SkillID = BitConverter.ToInt16(bytes, index); index += 2; data[id1[i]].Skill[j] = unit; } } Debug.Log("GameUnitLevelUpData loaded."); }
public void saveText() { string strHelp = ""; for (int i = 0; i < data.Length; ++i) { GameUnitLevelUp unit = data[i]; strHelp += "<table interlaced=\"enabled\" align=\"center\" ><tbody>"; strHelp += "<tr>"; strHelp += "<td style=\"background-color: rgb(235, 241, 221);\" width=\"100\" align=\"center\">"; strHelp += "<strong>技能名称:</strong>"; strHelp += "</td>"; strHelp += "<td style=\"background-color: rgb(235, 241, 221);\" width=\"60\" align=\"center\">"; strHelp += "<strong>等级:</strong>"; strHelp += "</td>"; strHelp += "<td style=\"background-color: rgb(235, 241, 221);\" width=\"200\" align=\"center\">"; strHelp += "<strong>需求:</strong>"; strHelp += "</td>"; strHelp += "</tr>"; for (int j = 0; j < unit.Skill.Length; j++) { GameUnitLevelUpSkillLearn learn = unit.Skill[j]; if (learn.SkillID == GameDefine.INVALID_ID) { continue; } strHelp += "<tr>"; strHelp += "<td width=\"100\" align=\"center\">"; strHelp += GameSkillData.instance.getData(learn.SkillID).NameS; strHelp += "</td>"; strHelp += "<td width=\"60\" align=\"center\">"; strHelp += learn.LV; strHelp += "</td>"; strHelp += "<td width=\"200\" align=\"center\">"; if (learn.SpiritRequest[0] > 0) { strHelp += "迅" + learn.SpiritRequest[0]; } if (learn.SpiritRequest[1] > 0) { strHelp += "烈" + learn.SpiritRequest[1]; } if (learn.SpiritRequest[2] > 0) { strHelp += "神" + learn.SpiritRequest[2]; } if (learn.SpiritRequest[3] > 0) { strHelp += "魔" + learn.SpiritRequest[3]; } if (learn.SpiritRequest[4] > 0) { strHelp += "魂" + learn.SpiritRequest[4]; } strHelp += "</td>"; strHelp += "</tr>"; } strHelp += "</tbody></table>"; } File.WriteAllText(Application.dataPath + "/Objects/Help/Help30.txt", strHelp, Encoding.UTF8); }