国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

【Unity開發(fā)教程】從零開始開發(fā)i wanna系列游戲(3)讀取游戲存檔

2023-09-03 01:37 作者:薔薇對你說晚安  | 我要投稿

太陽戰(zhàn)士索拉爾來啦,感覺unity有個bug,路徑設(shè)置對了依然會找不到,不如直接公開,把data文件拖進(jìn)去using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using System.Xml;


public class ResourceRvc : MonoBehaviour

{

public static ResourceRvc Instance; // 單例

public XmlDocument dataDocument; // 用于存儲XML文檔

public XmlNodeList dataNodeList; // 用于存儲XML節(jié)點列表

public TextAsset xmlFile; // 在Inspector面板中手動設(shè)置


public void Initsvc()

{

Instance = this; // 初始化單例

InitSaveDate(); // 初始化存檔數(shù)據(jù)

}


private void InitSaveDate()

{

dataDocument = new XmlDocument(); // 創(chuàng)建新的XML文檔

dataDocument.LoadXml(xmlFile.text); // 加載XML文件內(nèi)容

dataNodeList = dataDocument.SelectSingleNode("data").ChildNodes; // 獲取"data"節(jié)點的所有子節(jié)點

}


public struct SaveData // 存檔數(shù)據(jù)結(jié)構(gòu)

{

public string state; // 狀態(tài)

public int deathCount; // 死亡次數(shù)

public string time; // 時間

public string savePosition; // 存檔位置

// public string 最好把角色的子集狀態(tài)也儲存

}

public SaveData GetSaveData(int dataChooseNum) // 獲取存檔數(shù)據(jù)

{

XmlElement element = (XmlElement)dataNodeList[dataChooseNum]; // 獲取指定索引的節(jié)點

SaveData saveData = new SaveData(); // 創(chuàng)建新的存檔數(shù)據(jù)

saveData.state = element.GetAttribute("state"); // 獲取狀態(tài)

saveData.deathCount = int.Parse(element.GetAttribute("death")); // 獲取死亡次數(shù)

saveData.time = element.GetAttribute("time"); // 獲取時間

saveData.savePosition = element.GetAttribute("save_position"); // 獲取存檔位置

return saveData; // 返回存檔數(shù)據(jù)

}

}

【Unity開發(fā)教程】從零開始開發(fā)i wanna系列游戲(3)讀取游戲存檔的評論 (共 條)

分享到微博請遵守國家法律
兰考县| 河曲县| 阳新县| 蒲城县| 棋牌| 海晏县| 泊头市| 密云县| 行唐县| 张家川| 壶关县| 大名县| 富川| 平塘县| 那曲县| 周口市| 鄂托克前旗| 饶阳县| 班玛县| 大埔县| 饶河县| 吉隆县| 济阳县| 吉水县| 肥东县| 定远县| 齐齐哈尔市| 泰顺县| 七台河市| 桐城市| 霍邱县| 额尔古纳市| 宝丰县| 奇台县| 宁阳县| 长武县| 安图县| 丁青县| 梅河口市| 奈曼旗| 原阳县|