2023-12-10 12:28:20 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Script.UI;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using ZXL.ID;
|
|
|
|
|
|
|
|
|
|
namespace Script
|
|
|
|
|
{
|
|
|
|
|
public class TitleInfo
|
|
|
|
|
{
|
|
|
|
|
public string title;
|
|
|
|
|
public string subject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class FileManager : SingleManager<FileManager>
|
|
|
|
|
{
|
2023-12-12 10:29:10 +08:00
|
|
|
|
private string dataTeamPath;
|
|
|
|
|
private string dataCulturePath;
|
2023-12-10 12:28:20 +08:00
|
|
|
|
private string titlePath;
|
|
|
|
|
|
|
|
|
|
private TitleInfo titleInfo;
|
|
|
|
|
public TitleInfo GetTitle => titleInfo;
|
|
|
|
|
|
|
|
|
|
public FileManager()
|
|
|
|
|
{
|
2023-12-12 10:29:10 +08:00
|
|
|
|
dataTeamPath = Application.streamingAssetsPath + $"/TeamData.txt";
|
|
|
|
|
if (!File.Exists(dataTeamPath))
|
2023-12-10 12:28:20 +08:00
|
|
|
|
{
|
2023-12-12 10:29:10 +08:00
|
|
|
|
var fileStream = File.Create(dataTeamPath);
|
|
|
|
|
fileStream.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dataCulturePath = Application.streamingAssetsPath + $"/CultureData.txt";
|
|
|
|
|
if (!File.Exists(dataCulturePath))
|
|
|
|
|
{
|
|
|
|
|
var fileStream = File.Create(dataCulturePath);
|
2023-12-10 12:28:20 +08:00
|
|
|
|
fileStream.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
titlePath = Application.streamingAssetsPath + "/title.txt";
|
|
|
|
|
var text = File.ReadAllLines(titlePath);
|
|
|
|
|
titleInfo = new TitleInfo() { title = text[0], subject = text[1] };
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-12 10:29:10 +08:00
|
|
|
|
public void SavePlayerTeamData(string content)
|
|
|
|
|
{
|
|
|
|
|
var text = File.ReadAllText(dataTeamPath);
|
|
|
|
|
File.WriteAllText(dataTeamPath, "\n" + content);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SavePlayerCultureData(string content)
|
2023-12-10 12:28:20 +08:00
|
|
|
|
{
|
2023-12-12 10:29:10 +08:00
|
|
|
|
var text = File.ReadAllText(dataCulturePath);
|
|
|
|
|
File.WriteAllText(dataCulturePath, "\n" + content);
|
2023-12-10 12:28:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|