Browse Source

改成单机版本

develop
曹衍涛 4 years ago
parent
commit
0956d207b8
  1. 12
      Assets/Data/1/File/NodeList.xml
  2. 24
      Assets/ReplayUIManager.cs
  3. BIN
      Assets/Scene/MainScene_New.unity
  4. 22
      Assets/Scripts/DisasterList/AddDisaster.cs
  5. 8
      Assets/Scripts/DisasterList/DISASTER_FILES_UPDATE_SYNC.cs
  6. 25
      Assets/Scripts/DisasterList/DisasterInfosManager.cs
  7. 4
      Assets/Scripts/DisasterList/DisasterItem.cs
  8. 46
      Assets/Scripts/DisasterList/EditDisaster.cs
  9. 38
      Assets/Scripts/DisasterList/PagesController.cs
  10. 6
      Assets/Scripts/DisasterList/SaveDisaster.cs
  11. 302
      Assets/Scripts/DisasterList/UpdateManager.cs
  12. 4
      Assets/Scripts/Replay/DisasterManager.cs
  13. 18
      Assets/Scripts/UIScripts/EditorRight.cs
  14. BIN
      Assets/Sky/Materials/azure[Sky].mat
  15. 2
      Assets/StreamingAssets/TianQiSettingData.xml
  16. BIN
      ProjectSettings/ProjectSettings.asset

12
Assets/Data/1/File/NodeList.xml

@ -1,11 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<NodeList> <NodeList>
<FirstNode> <FirstNode>
<NextID>0</NextID> <NextID>1</NextID>
<Nodes /> <Nodes>
<Node ID="0" Name="1" />
</Nodes>
</FirstNode> </FirstNode>
<SecondNode> <SecondNode>
<NextID>0</NextID> <NextID>1</NextID>
<Nodes /> <Nodes>
<Node ID="0" ParentID="0" Name="1.1" Detail="1.1" />
</Nodes>
</SecondNode> </SecondNode>
</NodeList> </NodeList>

24
Assets/ReplayUIManager.cs

@ -6,16 +6,16 @@ using UnityEngine;
public class ReplayUIManager : MonoBehaviour public class ReplayUIManager : MonoBehaviour
{ {
private GameObject rolePanel; //private GameObject rolePanel;
private GameObject roleSelectPanel; // private GameObject roleSelectPanel;
private GameObject bottomCenterUI; private GameObject bottomCenterUI;
private GameObject editorRight; // private GameObject editorRight;
private void Start() private void Start()
{ {
rolePanel = transform.Find("RolePanel").gameObject; //rolePanel = transform.Find("RolePanel").gameObject;
roleSelectPanel = transform.Find("RoleSelectPanel").gameObject; //roleSelectPanel = transform.Find("RoleSelectPanel").gameObject;
bottomCenterUI = transform.Find("BottomCenterUI").gameObject; bottomCenterUI = transform.Find("BottomCenterUI").gameObject;
editorRight = transform.Find("TopUI/EditorRight").gameObject; //editorRight = transform.Find("TopUI/EditorRight").gameObject;
SetUI(); SetUI();
} }
// Use this for initialization // Use this for initialization
@ -27,16 +27,16 @@ public class ReplayUIManager : MonoBehaviour
{ {
if (DisasterManager.model == PlayModel.view) if (DisasterManager.model == PlayModel.view)
{ {
rolePanel.SetActive(false);//单机版注释 //rolePanel.SetActive(false);//单机版注释
roleSelectPanel.SetActive(false);//单机版注释 //roleSelectPanel.SetActive(false);//单机版注释
editorRight.SetActive(false);//单机版注释 //editorRight.SetActive(false);//单机版注释
} }
else if (DisasterManager.model == PlayModel.editor) else if (DisasterManager.model == PlayModel.editor)
{ {
rolePanel.SetActive(true);//单机版注释 //rolePanel.SetActive(true);//单机版注释
roleSelectPanel.SetActive(true);//单机版注释 //roleSelectPanel.SetActive(true);//单机版注释
editorRight.SetActive(true);//单机版注释 //editorRight.SetActive(true);//单机版注释
MultiSelectNAV.GetInstance.gameObject.SetActive(true); MultiSelectNAV.GetInstance.gameObject.SetActive(true);
} }
/* /*

BIN
Assets/Scene/MainScene_New.unity

Binary file not shown.

22
Assets/Scripts/DisasterList/AddDisaster.cs

@ -10,27 +10,29 @@ using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UI; using UnityEngine.UI;
public class AddDisaster : MonoBehaviour { public class AddDisaster : MonoBehaviour
private Button addBtn; {
private Button addBtn;
// Use this for initialization // Use this for initialization
void Start () { void Start()
{
addBtn = GetComponent<Button>(); addBtn = GetComponent<Button>();
addBtn.onClick.AddListener(AddNewDisaster); addBtn.onClick.AddListener(AddNewDisaster);
} }
void AddNewDisaster() void AddNewDisaster()
{ {
//获取灾情名称 //获取灾情名称
ResourceLoadWindow.Instance.LoadInputWindow("请输入灾情名称", ConfirmNewDisaster, null, null); ResourceLoadWindow.Instance.LoadInputWindow("请输入灾情名称", ConfirmNewDisaster, null, null);
} }
private void ConfirmNewDisaster(string disasterName) private void ConfirmNewDisaster(string disasterName)
{ {
DisasterInfo msg = new DisasterInfo(); DisasterInfo msg = new DisasterInfo();
msg.Name = disasterName; msg.Name = disasterName;
//向服务端申请新建灾情,成功后调用AddDisasterSucced //向服务端申请新建灾情,成功后调用AddDisasterSucced
NetworkManager.Default.SendAsync("CREATE_DISASTER_INFO_REQUEST", msg); // NetworkManager.Default.SendAsync("CREATE_DISASTER_INFO_REQUEST", msg);
//单机版 //单机版
//msg.LastTime = DateTime.Now.ToString(); msg.LastTime = DateTime.Now.ToString();
//DisasterInfosManager.Instance.AddNewDisasterInfo(msg); DisasterInfosManager.Instance.AddNewDisasterInfo(msg);
} }
} }

8
Assets/Scripts/DisasterList/DISASTER_FILES_UPDATE_SYNC.cs

@ -22,16 +22,16 @@ public class DISASTER_FILES_UPDATE_SYNC : NetworkMessageBehaviour
MessageDispatcher.RemoveListener("DisasterUpdateCompelete", UpdateCompelete); MessageDispatcher.RemoveListener("DisasterUpdateCompelete", UpdateCompelete);
} }
protected override void Execute(BinaryMessage message) protected override void Execute(BinaryMessage message)
{ {
int id = message.Body.Deserialize<int>(); int id = message.Body.Deserialize<int>();
if (id == DisasterManager.disaster.Id) if (id == DisasterManager.disaster.Id)
{ {
btn.interactable = true; btn.interactable = true;
} }
} }
private void UpdateCurrentDisaster() private void UpdateCurrentDisaster()
{ {
ResourceLoadWindow.Instance.LoadTipWindow("确认更新?", () => { UpdateManager.Instance.MainSceneUpdateDisaster(); }, null);//单机注释掉 // ResourceLoadWindow.Instance.LoadTipWindow("确认更新?", () => { UpdateManager.Instance.MainSceneUpdateDisaster(); }, null);//单机注释掉
} }
private void UpdateCompelete(IMessage obj) private void UpdateCompelete(IMessage obj)
{ {
@ -39,5 +39,5 @@ public class DISASTER_FILES_UPDATE_SYNC : NetworkMessageBehaviour
btn.interactable = false; btn.interactable = false;
DisasterManager.updateFlag = false; DisasterManager.updateFlag = false;
ResourceLoadWindow.Instance.LoadTextHintWindow("更新完成!", 2); ResourceLoadWindow.Instance.LoadTextHintWindow("更新完成!", 2);
} }
} }

25
Assets/Scripts/DisasterList/DisasterInfosManager.cs

@ -5,7 +5,8 @@ using System.IO;
using System.Xml; using System.Xml;
using UnityEngine; using UnityEngine;
public class DisasterInfosManager { public class DisasterInfosManager
{
private static DisasterInfosManager instance; private static DisasterInfosManager instance;
public static string path; public static string path;
public int currentID = -1; public int currentID = -1;
@ -27,15 +28,15 @@ public class DisasterInfosManager {
document.Save(path); document.Save(path);
document = null; document = null;
} }
} }
return instance; return instance;
} }
} }
/// <summary> /// <summary>
/// 单机版,获取所有灾情 /// 单机版,获取所有灾情
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<DisasterInfo> GetAllDisasterInfos() public List<DisasterInfo> GetAllDisasterInfos()
{ {
List<DisasterInfo> list = new List<DisasterInfo>(); List<DisasterInfo> list = new List<DisasterInfo>();
XmlDocument document = new XmlDocument(); XmlDocument document = new XmlDocument();
@ -58,7 +59,7 @@ public class DisasterInfosManager {
{ {
info.Name = element.InnerText; info.Name = element.InnerText;
} }
} }
/*string id = fileNode.GetElementsByTagName("Id"). /*string id = fileNode.GetElementsByTagName("Id").
info.Id = int.Parse(fileNode.GetAttribute("Id")); info.Id = int.Parse(fileNode.GetAttribute("Id"));
info.LastTime = fileNode.GetAttribute("LastTime"); info.LastTime = fileNode.GetAttribute("LastTime");
@ -141,10 +142,10 @@ public class DisasterInfosManager {
/// </summary> /// </summary>
/// <param name="info"></param> /// <param name="info"></param>
public void AddNewDisasterInfo(DisasterInfo info) public void AddNewDisasterInfo(DisasterInfo info)
{ {
info.Id = currentID + 1; info.Id = currentID + 1;
XmlDocument document = new XmlDocument(); XmlDocument document = new XmlDocument();
document.Load(path); document.Load(path);
XmlNode node = document.SelectSingleNode("DisasterInfoList"); XmlNode node = document.SelectSingleNode("DisasterInfoList");
XmlElement infoNode = document.CreateElement("DisasterInfo"); XmlElement infoNode = document.CreateElement("DisasterInfo");
/*infoNode.SetAttribute("Id", info.Id.ToString()); /*infoNode.SetAttribute("Id", info.Id.ToString());
@ -242,7 +243,7 @@ public class DisasterInfosManager {
/// </summary> /// </summary>
/// <param name="uId"></param> /// <param name="uId"></param>
/// <param name="uName"></param> /// <param name="uName"></param>
public void UpdateDisasterInfo(int uId,string uName) public void UpdateDisasterInfo(int uId, string uName)
{ {
XmlDocument document = new XmlDocument(); XmlDocument document = new XmlDocument();
document.Load(path); document.Load(path);
@ -251,11 +252,11 @@ public class DisasterInfosManager {
foreach (XmlElement fileNode in nodeList) foreach (XmlElement fileNode in nodeList)
{ {
XmlElement element = (XmlElement)fileNode.GetElementsByTagName("Id")[0]; XmlElement element = (XmlElement)fileNode.GetElementsByTagName("Id")[0];
if(element.InnerText == uId.ToString()) if (element.InnerText == uId.ToString())
{ {
XmlElement nodeName = (XmlElement)fileNode.GetElementsByTagName("Name")[0]; XmlElement nodeName = (XmlElement)fileNode.GetElementsByTagName("Name")[0];
nodeName.InnerText = uName; nodeName.InnerText = uName;
XmlElement nodeTime=(XmlElement)fileNode.GetElementsByTagName("LastTime")[0]; XmlElement nodeTime = (XmlElement)fileNode.GetElementsByTagName("LastTime")[0];
nodeTime.InnerText = DateTime.Now.ToString(); nodeTime.InnerText = DateTime.Now.ToString();
break; break;
} }
@ -263,7 +264,7 @@ public class DisasterInfosManager {
document.Save(path); document.Save(path);
document = null; document = null;
} }
public void SaveDisasterInfo(string uId) public void SaveDisasterInfo(string uId)
{ {
XmlDocument document = new XmlDocument(); XmlDocument document = new XmlDocument();
document.Load(path); document.Load(path);
@ -273,7 +274,7 @@ public class DisasterInfosManager {
{ {
XmlElement element = (XmlElement)fileNode.GetElementsByTagName("Id")[0]; XmlElement element = (XmlElement)fileNode.GetElementsByTagName("Id")[0];
if (element.InnerText == uId) if (element.InnerText == uId)
{ {
XmlElement nodeTime = (XmlElement)fileNode.GetElementsByTagName("LastTime")[0]; XmlElement nodeTime = (XmlElement)fileNode.GetElementsByTagName("LastTime")[0];
nodeTime.InnerText = DateTime.Now.ToString(); nodeTime.InnerText = DateTime.Now.ToString();
break; break;

4
Assets/Scripts/DisasterList/DisasterItem.cs

@ -59,7 +59,7 @@ public class DisasterItem : MonoBehaviour {
} }
private void Delete() private void Delete()
{ {
ResourceLoadWindow.Instance.LoadTipWindow("是否删除预案?", () => { NetworkManager.Default.SendAsync("DELETE_DISASTER_INFO_SYNC", msg.Id); }, null); //单机版注释 //ResourceLoadWindow.Instance.LoadTipWindow("是否删除预案?", () => { NetworkManager.Default.SendAsync("DELETE_DISASTER_INFO_SYNC", msg.Id); }, null); //单机版注释
// ResourceLoadWindow.Instance.LoadTipWindow("是否删除预案?", () => { DisasterInfosManager.Instance.DeleteDisasterInfo(msg.Id); }, null);//非单机版打开 ResourceLoadWindow.Instance.LoadTipWindow("是否删除预案?", () => { DisasterInfosManager.Instance.DeleteDisasterInfo(msg.Id); }, null);//非单机版打开
} }
} }

46
Assets/Scripts/DisasterList/EditDisaster.cs

@ -8,17 +8,19 @@ using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UI; using UnityEngine.UI;
public class EditDisaster : MonoBehaviour { public class EditDisaster : MonoBehaviour
{
private Button editBtn; private Button editBtn;
private string oldName; private string oldName;
// Use this for initialization // Use this for initialization
void Start () { void Start()
{
editBtn = GetComponent<Button>(); editBtn = GetComponent<Button>();
editBtn.onClick.AddListener(Edit); editBtn.onClick.AddListener(Edit);
} }
private void Edit() private void Edit()
{ {
if(DisasterList.Instance.AnySelected() == false) if (DisasterList.Instance.AnySelected() == false)
{ {
ResourceLoadWindow.Instance.LoadTextHintWindow("请选择灾情", 2); ResourceLoadWindow.Instance.LoadTextHintWindow("请选择灾情", 2);
return; return;
@ -26,29 +28,29 @@ public class EditDisaster : MonoBehaviour {
else else
{ {
oldName = UpdateManager.Instance.selectedMsg.Name; oldName = UpdateManager.Instance.selectedMsg.Name;
ResourceLoadWindow.Instance.LoadInputWindow("请编辑灾情名称", ConfirmNewName, null, UpdateManager.Instance.selectedMsg.Name); ResourceLoadWindow.Instance.LoadInputWindow("请编辑灾情名称", ConfirmNewName, null, UpdateManager.Instance.selectedMsg.Name);
} }
} }
private void ConfirmNewName(string disasterName) private void ConfirmNewName(string disasterName)
{ {
//单机版注释下边ifelse //单机版注释下边ifelse
if (oldName == disasterName) //名字没改 //if (oldName == disasterName) //名字没改
{ //{
//先与服务端比对更新 // //先与服务端比对更新
UpdateManager.Instance.Edit(); // UpdateManager.Instance.Edit();
} //}
else //名字已改 //else //名字已改
{
UpdateManager.Instance.selectedMsg.Name = disasterName;
NetworkManager.Default.SendAsync("UPDATE_DISASTER_INFO_REQUEST", UpdateManager.Instance.selectedMsg);
}
//非单机版解开注释
//if(oldName != disasterName)
//{ //{
// UpdateManager.Instance.selectedMsg.Name = disasterName; // UpdateManager.Instance.selectedMsg.Name = disasterName;
// DisasterInfosManager.Instance.UpdateDisasterInfo(UpdateManager.Instance.selectedMsg.Id, UpdateManager.Instance.selectedMsg.Name); // NetworkManager.Default.SendAsync("UPDATE_DISASTER_INFO_REQUEST", UpdateManager.Instance.selectedMsg);
//} //}
//UpdateManager.Instance.Edit(); //非单机版解开注释
if (oldName != disasterName)
{
UpdateManager.Instance.selectedMsg.Name = disasterName;
DisasterInfosManager.Instance.UpdateDisasterInfo(UpdateManager.Instance.selectedMsg.Id, UpdateManager.Instance.selectedMsg.Name);
}
UpdateManager.Instance.Edit();
oldName = ""; oldName = "";
} }
} }

38
Assets/Scripts/DisasterList/PagesController.cs

@ -4,7 +4,8 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
public class PagesController : MonoBehaviour { public class PagesController : MonoBehaviour
{
public static PagesController Instance; public static PagesController Instance;
public Button pre; public Button pre;
public Button next; public Button next;
@ -17,36 +18,37 @@ public class PagesController : MonoBehaviour {
private void Awake() private void Awake()
{ {
Instance = this; Instance = this;
pre.onClick.AddListener(PrePage);//单机版注释 //pre.onClick.AddListener(PrePage);//单机版注释
next.onClick.AddListener(NextPage);//单机版注释 //next.onClick.AddListener(NextPage);//单机版注释
//pre.gameObject.SetActive(false);//非单机版解开注释 pre.gameObject.SetActive(false);//非单机版解开注释
//next.gameObject.SetActive(false);//非单机版解开注释 next.gameObject.SetActive(false);//非单机版解开注释
} }
// Use this for initialization // Use this for initialization
void Start () { void Start()
{
ApplyForInitPage(); ApplyForInitPage();
} }
public void ApplyForInitPage() public void ApplyForInitPage()
{ {
pageIndex = 1; pageIndex = 1;
//1、向服务端申请获取一共的页数,返回调用GetPageCount() //1、向服务端申请获取一共的页数,返回调用GetPageCount()
queryOptions.PageNumber = 1; //申请第一页数据 queryOptions.PageNumber = 1; //申请第一页数据
queryOptions.PageSize = 5; //每页显示5条 queryOptions.PageSize = 5; //每页显示5条
NetworkManager.Default.SendAsync("GET_DISASTER_INFOS_REQUEST", queryOptions); //联机版 //NetworkManager.Default.SendAsync("GET_DISASTER_INFOS_REQUEST", queryOptions); //联机版
// DisasterList.Instance.ShowIndexDisasters(DisasterInfosManager.Instance.GetDisasterInfos()); //单机版,获取本地灾情列表 DisasterList.Instance.ShowIndexDisasters(DisasterInfosManager.Instance.GetDisasterInfos()); //单机版,获取本地灾情列表
} }
public void ApplyForPage(int number) public void ApplyForPage(int number)
{ {
pageIndex = number; pageIndex = number;
queryOptions.PageNumber = number; //申请第一页数据 queryOptions.PageNumber = number; //申请第一页数据
queryOptions.PageSize = 5; //每页显示5条 queryOptions.PageSize = 5; //每页显示5条
NetworkManager.Default.SendAsync("GET_DISASTER_INFOS_REQUEST", queryOptions);//单机版注释 //NetworkManager.Default.SendAsync("GET_DISASTER_INFOS_REQUEST", queryOptions);//单机版注释
//DisasterList.Instance.ShowIndexDisasters(DisasterInfosManager.Instance.GetDisasterInfos()); //单机版,获取本地灾情列表 DisasterList.Instance.ShowIndexDisasters(DisasterInfosManager.Instance.GetDisasterInfos()); //单机版,获取本地灾情列表
} }
public void GetPageCount(int count) public void GetPageCount(int count)
{ {
pageCount = count; pageCount = count;
for(int j = 0; j < transform.childCount; j++) for (int j = 0; j < transform.childCount; j++)
{ {
Destroy(transform.GetChild(j).gameObject); Destroy(transform.GetChild(j).gameObject);
} }
@ -98,7 +100,7 @@ public class PagesController : MonoBehaviour {
} }
else //if (pageIndex < 6 && pageCount>9) else //if (pageIndex < 6 && pageCount>9)
{ {
for(int l = 1; l < 10; l++) for (int l = 1; l < 10; l++)
{ {
GameObject indexItem = Instantiate(prefab, transform); GameObject indexItem = Instantiate(prefab, transform);
indexItem.GetComponent<PageIndex>().Index = l; indexItem.GetComponent<PageIndex>().Index = l;
@ -122,7 +124,7 @@ public class PagesController : MonoBehaviour {
{ {
next.interactable = true; next.interactable = true;
} }
} }
else if (pageIndex == pageCount) else if (pageIndex == pageCount)
{ {
next.interactable = false; next.interactable = false;
@ -134,7 +136,7 @@ public class PagesController : MonoBehaviour {
{ {
pre.interactable = false; pre.interactable = false;
} }
} }
else else
{ {
pre.interactable = true; pre.interactable = true;
@ -142,7 +144,7 @@ public class PagesController : MonoBehaviour {
} }
} }
private void PrePage() private void PrePage()
{ {
pageIndex -= 1; pageIndex -= 1;
//如果页码是第一页,禁用“上一页”按钮 //如果页码是第一页,禁用“上一页”按钮
if (pageIndex == 1) if (pageIndex == 1)
@ -158,13 +160,13 @@ public class PagesController : MonoBehaviour {
ApplyForPage(pageIndex); ApplyForPage(pageIndex);
} }
private void NextPage() private void NextPage()
{ {
pageIndex += 1; pageIndex += 1;
if (pageIndex == pageCount) if (pageIndex == pageCount)
{ {
next.interactable = false; next.interactable = false;
} }
else if(pageIndex == 2) else if (pageIndex == 2)
{ {
pre.interactable = true; pre.interactable = true;
} }

6
Assets/Scripts/DisasterList/SaveDisaster.cs

@ -84,9 +84,9 @@ public class SaveDisaster : MonoBehaviour
//1.根据当前文件夹内容创建新的xml到curLocalFileXml (保存在Data文件夹) //1.根据当前文件夹内容创建新的xml到curLocalFileXml (保存在Data文件夹)
CreateMD5Tool.Instance.CreateManifestXml(directoryPath, curLocalFileXml); CreateMD5Tool.Instance.CreateManifestXml(directoryPath, curLocalFileXml);
ResourceLoadWindow.Instance.LoadTextHintWindow("保存成功", 0.5f);
//2.从服务端下载xml到preLocalFileXml (保存在Temp文件夹) //2.从服务端下载xml到preLocalFileXml (保存在Temp文件夹),单机注释
NetworkManager.Default.DownloadFileAsync(preLocalFileXml, serverFileXml, null, null, OnFileVersionCompleted); //NetworkManager.Default.DownloadFileAsync(preLocalFileXml, serverFileXml, null, null, OnFileVersionCompleted);
} }
private void OnFileVersionCompleted(string preLocalFileXml, string serverFileXml) private void OnFileVersionCompleted(string preLocalFileXml, string serverFileXml)

302
Assets/Scripts/DisasterList/UpdateManager.cs

@ -8,12 +8,13 @@ using System.Xml;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
public class UpdateManager : MonoBehaviour { public class UpdateManager : MonoBehaviour
{
private static UpdateManager instance; private static UpdateManager instance;
public static UpdateManager Instance public static UpdateManager Instance
{ {
get get
{ {
return instance; return instance;
} }
} }
@ -21,15 +22,15 @@ public class UpdateManager : MonoBehaviour {
private string serverDirectoryPath;//服务端文件存储文件夹 private string serverDirectoryPath;//服务端文件存储文件夹
private string localDirectoryPath;//本地文件存储文件夹 private string localDirectoryPath;//本地文件存储文件夹
private string tempDirectoryPath; //下载下来的配置文件暂存文件夹//单机版注释掉 //private string tempDirectoryPath; //下载下来的配置文件暂存文件夹//单机版注释掉
private string serverFileXml;//服务端文件版本配置 private string serverFileXml;//服务端文件版本配置
private string localTempXml; //本地临时配置文件路径 private string localTempXml; //本地临时配置文件路径
private string localFileXml;//本地文件版本配置 private string localFileXml;//本地文件版本配置
private List<string> fileList = new List<string>(); //需要更新的文件列表 private List<string> fileList = new List<string>(); //需要更新的文件列表
private List<string> delList = new List<string>(); //需要删除的文件列表 private List<string> delList = new List<string>(); //需要删除的文件列表
private int updateCount; private int updateCount;
private bool[] completedList; private bool[] completedList;
private float[] progressList; private float[] progressList;
public bool isEdit = false; public bool isEdit = false;
public UpdateState state; public UpdateState state;
@ -38,52 +39,55 @@ public class UpdateManager : MonoBehaviour {
{ {
instance = this; instance = this;
selectedMsg = new DisasterInfo(); selectedMsg = new DisasterInfo();
} }
/// <summary> /// <summary>
/// 进入编辑模式 /// 进入编辑模式
/// </summary> /// </summary>
public void Edit() public void Edit()
{ {
state = UpdateState.Edit; state = UpdateState.Edit;
DisasterManager.disaster = selectedMsg; DisasterManager.disaster = selectedMsg;
initPath(); initPath();
downLoadFileVersion();//单机版注释 DisasterManager.editorRight = true;
//versionUpdateOnCompleted();//联机版取消注释 // downLoadFileVersion();//单机版注释
versionUpdateOnCompleted();//联机版取消注释
} }
public void Edit(DisasterInfo info) public void Edit(DisasterInfo info)
{ {
selectedMsg = info; selectedMsg = info;
DisasterManager.disaster = selectedMsg; DisasterManager.disaster = selectedMsg;
state = UpdateState.Edit;
state = UpdateState.Edit;
initPath(); initPath();
downLoadFileVersion();//单机版注释 //downLoadFileVersion();//单机版注释
//versionUpdateOnCompleted(); versionUpdateOnCompleted();
} }
/// <summary> /// <summary>
/// 进入查看模式 //单机版注释 /// 进入查看模式 //单机版注释
/// </summary> /// </summary>
public void View() public void View()
{ {
state = UpdateState.View; state = UpdateState.View;
DisasterManager.disaster = selectedMsg; DisasterManager.disaster = selectedMsg;
DisasterManager.editorRight = false;
initPath(); initPath();
downLoadFileVersion();//单机版注释 //downLoadFileVersion();//单机版注释
//versionUpdateOnCompleted(); versionUpdateOnCompleted();
} }
/// <summary> /// <summary>
/// 进入主场景之前先更新 //单机版注释 /// 进入主场景之前先更新 //单机版注释
/// </summary> /// </summary>
private void UpdateBeforeContinue() //private void UpdateBeforeContinue()
{ //{
foreach(string key in delList) // foreach(string key in delList)
{ // {
File.Delete(localDirectoryPath + key); // File.Delete(localDirectoryPath + key);
} // }
progressList = new float[fileList.Count]; // progressList = new float[fileList.Count];
completedList = new bool[fileList.Count]; // completedList = new bool[fileList.Count];
UpdateResources(); // UpdateResources();
} //}
/// <summary> /// <summary>
/// 不更新直接进入主场景 /// 不更新直接进入主场景
/// </summary> /// </summary>
@ -93,7 +97,7 @@ public class UpdateManager : MonoBehaviour {
{ {
//删除临时配置文件 //删除临时配置文件
File.Delete(localTempXml); File.Delete(localTempXml);
} }
DisasterManager.updateFlag = true; DisasterManager.updateFlag = true;
switch (state) switch (state)
{ {
@ -105,9 +109,9 @@ public class UpdateManager : MonoBehaviour {
break; break;
case UpdateState.View: case UpdateState.View:
//查看 //查看
DisasterManager.model = PlayModel.view; DisasterManager.model = PlayModel.view;
break; break;
case UpdateState.MainSceneUpdate: case UpdateState.MainSceneUpdate:
break; break;
default: default:
break; break;
@ -116,13 +120,13 @@ public class UpdateManager : MonoBehaviour {
SceneManager.LoadScene("MainScene_New"); SceneManager.LoadScene("MainScene_New");
} }
//单机版注释掉 //单机版注释掉
public void MainSceneUpdateDisaster() //public void MainSceneUpdateDisaster()
{ //{
state = UpdateState.MainSceneUpdate; // state = UpdateState.MainSceneUpdate;
//先更新 // //先更新
initPath(); // initPath();
downLoadFileVersion(); // downLoadFileVersion();
} //}
/// <summary> /// <summary>
/// 文件路径初始化 /// 文件路径初始化
/// </summary> /// </summary>
@ -131,17 +135,17 @@ public class UpdateManager : MonoBehaviour {
fileList = new List<string>(); fileList = new List<string>();
serverDirectoryPath = selectedMsg.Id.ToString() + "/File/"; //服务器相对路径 serverDirectoryPath = selectedMsg.Id.ToString() + "/File/"; //服务器相对路径
localDirectoryPath = Application.dataPath + "/Data/" + selectedMsg.Id.ToString() + "/File/"; //本地路径 localDirectoryPath = Application.dataPath + "/Data/" + selectedMsg.Id.ToString() + "/File/"; //本地路径
tempDirectoryPath = Application.dataPath + "/Temp/" + selectedMsg.Id.ToString() + "/"; //本地临时路径 //单机版注释 //tempDirectoryPath = Application.dataPath + "/Temp/" + selectedMsg.Id.ToString() + "/"; //本地临时路径 //单机版注释
//如果本地没有该灾情的文件夹,先创建 //如果本地没有该灾情的文件夹,先创建
if (!Directory.Exists(localDirectoryPath)) if (!Directory.Exists(localDirectoryPath))
{ {
Directory.CreateDirectory(localDirectoryPath); Directory.CreateDirectory(localDirectoryPath);
} }
//如果本地没有临时路径,先创建 //单机版注释 //如果本地没有临时路径,先创建 //单机版注释
if (!Directory.Exists(tempDirectoryPath)) //if (!Directory.Exists(tempDirectoryPath))
{ //{
Directory.CreateDirectory(tempDirectoryPath); // Directory.CreateDirectory(tempDirectoryPath);
} //}
serverFileXml = selectedMsg.Id.ToString() + "/" + selectedMsg.Id.ToString() + ".xml"; //服务器配置文件 serverFileXml = selectedMsg.Id.ToString() + "/" + selectedMsg.Id.ToString() + ".xml"; //服务器配置文件
localTempXml = Application.dataPath + "/Temp/" + selectedMsg.Id.ToString() + ".xml"; //本地临时配置文件 localTempXml = Application.dataPath + "/Temp/" + selectedMsg.Id.ToString() + ".xml"; //本地临时配置文件
@ -150,88 +154,88 @@ public class UpdateManager : MonoBehaviour {
/// <summary> /// <summary>
/// 下载最新的文件配置文档 //单机版注释 /// 下载最新的文件配置文档 //单机版注释
/// </summary> /// </summary>
private void downLoadFileVersion() //private void downLoadFileVersion()
{ //{
NetworkManager.Default.DownloadFileAsync(localTempXml, serverFileXml , null, OnDownloadProgress, OnFileVersionCompleted); // NetworkManager.Default.DownloadFileAsync(localTempXml, serverFileXml , null, OnDownloadProgress, OnFileVersionCompleted);
} //}
private void OnDownloadProgress(string arg1, string arg2, float progress) private void OnDownloadProgress(string arg1, string arg2, float progress)
{ {
if (progress < 100) if (progress < 100)
{ {
ResourceLoadWindow.Instance.LoadTextHintWindow("正在更新...", 0.5f); ResourceLoadWindow.Instance.LoadTextHintWindow("正在更新...", 0.5f);
} }
} }
//单机版注释掉该方法 //单机版注释掉该方法
private void OnFileVersionCompleted(string localTempXml, string serverFileXml) //private void OnFileVersionCompleted(string localTempXml, string serverFileXml)
{ //{
if (!File.Exists(localFileXml)) // if (!File.Exists(localFileXml))
{ // {
CreateMD5Tool.Instance.CreateManifestXml(localDirectoryPath, localFileXml); // CreateMD5Tool.Instance.CreateManifestXml(localDirectoryPath, localFileXml);
} // }
//获取本地的HashID // //获取本地的HashID
Dictionary<string, string> localHashID = getMainFileVersion(localFileXml); // Dictionary<string, string> localHashID = getMainFileVersion(localFileXml);
//获取最新的HashID // //获取最新的HashID
Dictionary<string, string> serverHashID = getMainFileVersion(localTempXml); // Dictionary<string, string> serverHashID = getMainFileVersion(localTempXml);
foreach (string key in serverHashID.Keys) // foreach (string key in serverHashID.Keys)
{ // {
//1、先判断本地资源列表是否存在,若不存在则属于新资源 // //1、先判断本地资源列表是否存在,若不存在则属于新资源
if (!localHashID.ContainsKey(key)) // if (!localHashID.ContainsKey(key))
{ // {
fileList.Add(key); // fileList.Add(key);
} // }
else // else
{ // {
//2、再判断HashID是否相等,若不等则属于新资源 // //2、再判断HashID是否相等,若不等则属于新资源
string hash = serverHashID[key]; // string hash = serverHashID[key];
if (localHashID[key] != serverHashID[key]) // if (localHashID[key] != serverHashID[key])
{ // {
fileList.Add(key); // fileList.Add(key);
} // }
} // }
} // }
foreach(string key in localHashID.Keys) // foreach(string key in localHashID.Keys)
{ // {
//如果本地有但服务端没有,则删除该资源 // //如果本地有但服务端没有,则删除该资源
if (!serverHashID.ContainsKey(key)) // if (!serverHashID.ContainsKey(key))
{ // {
//File.Delete(localDirectoryPath + key); // //File.Delete(localDirectoryPath + key);
delList.Add(key); // delList.Add(key);
} // }
} // }
if (fileList.Count > 0 || delList.Count > 0) // if (fileList.Count > 0 || delList.Count > 0)
{ // {
switch (state) // switch (state)
{ // {
case UpdateState.None: // case UpdateState.None:
break; // break;
case UpdateState.Edit: // case UpdateState.Edit:
ResourceLoadWindow.Instance.LoadUpdateTipWindow("本地与服务端内容不一致,是否更新?", UpdateBeforeContinue, ContinueWithoutUpdate); // ResourceLoadWindow.Instance.LoadUpdateTipWindow("本地与服务端内容不一致,是否更新?", UpdateBeforeContinue, ContinueWithoutUpdate);
break; // break;
case UpdateState.View: // case UpdateState.View:
ResourceLoadWindow.Instance.LoadUpdateTipWindow("本地与服务端内容不一致,是否更新?", UpdateBeforeContinue, ContinueWithoutUpdate); // ResourceLoadWindow.Instance.LoadUpdateTipWindow("本地与服务端内容不一致,是否更新?", UpdateBeforeContinue, ContinueWithoutUpdate);
break; // break;
case UpdateState.MainSceneUpdate: // case UpdateState.MainSceneUpdate:
UpdateBeforeContinue(); // UpdateBeforeContinue();
break; // break;
default: // default:
break; // break;
} // }
} // }
else // else
{ // {
//将本地临时配置文件替换原有配置文件 // //将本地临时配置文件替换原有配置文件
FileMove(localTempXml, localFileXml); // FileMove(localTempXml, localFileXml);
//更新完成 // //更新完成
versionUpdateOnCompleted(); // versionUpdateOnCompleted();
} // }
} //}
/// <summary> /// <summary>
/// 更新完成 /// 更新完成
/// </summary> /// </summary>
private void versionUpdateOnCompleted() private void versionUpdateOnCompleted()
{ {
switch (state) switch (state)
{ {
case UpdateState.None: case UpdateState.None:
@ -246,28 +250,28 @@ public class UpdateManager : MonoBehaviour {
break; break;
case UpdateState.MainSceneUpdate: case UpdateState.MainSceneUpdate:
Debug.Log("灾情更新完成"); Debug.Log("灾情更新完成");
MessageDispatcher.SendMessage("DisasterUpdateCompelete"); //单机版注释 // MessageDispatcher.SendMessage("DisasterUpdateCompelete"); //单机版注释
break; break;
default: default:
break; break;
} }
} }
/// <summary> /// <summary>
/// 文件下载更新 单机版注释 /// 文件下载更新 单机版注释
/// </summary> /// </summary>
private void UpdateResources() //private void UpdateResources()
{ //{
updateCount = 0; // updateCount = 0;
for (int i = 0; i < fileList.Count; i++) // for (int i = 0; i < fileList.Count; i++)
{ // {
// Debug.Log("#########################第" + i + "个文件开始下载"); // // Debug.Log("#########################第" + i + "个文件开始下载");
var fullPath = tempDirectoryPath + fileList[i]; //本地临时路径 // var fullPath = tempDirectoryPath + fileList[i]; //本地临时路径
var filePath = serverDirectoryPath + fileList[i]; //服务器相对路径 // var filePath = serverDirectoryPath + fileList[i]; //服务器相对路径
checkDirectory(fullPath); // checkDirectory(fullPath);
NetworkManager.Default.DownloadFileAsync(fullPath, filePath, null, OnDownloadProgress, OnCompleted); // NetworkManager.Default.DownloadFileAsync(fullPath, filePath, null, OnDownloadProgress, OnCompleted);
} // }
} //}
private void checkDirectory(string path) private void checkDirectory(string path)
{ {
string directoryName = Path.GetDirectoryName(path); string directoryName = Path.GetDirectoryName(path);
@ -277,27 +281,27 @@ public class UpdateManager : MonoBehaviour {
} }
} }
//单机版注释 //单机版注释
private void OnCompleted(string fullname,string filename) //private void OnCompleted(string fullname,string filename)
{ //{
updateCount++; // updateCount++;
var fileName = filename.Replace(serverDirectoryPath, string.Empty); // var fileName = filename.Replace(serverDirectoryPath, string.Empty);
var targetFile = localDirectoryPath + fileName; // var targetFile = localDirectoryPath + fileName;
//将临时文件替换原有文件 // //将临时文件替换原有文件
FileMove(fullname, targetFile); // FileMove(fullname, targetFile);
int index = fileList.IndexOf(fileName); // int index = fileList.IndexOf(fileName);
completedList[index] = true; // completedList[index] = true;
Debug.Log("*************************第" + index + "个文件下载完成"); // Debug.Log("*************************第" + index + "个文件下载完成");
//所有文件更新完成 // //所有文件更新完成
if (updateCount == fileList.Count) // if (updateCount == fileList.Count)
{ // {
Directory.Delete(tempDirectoryPath, true); // Directory.Delete(tempDirectoryPath, true);
//将本地临时配置文件替换原有配置文件 // //将本地临时配置文件替换原有配置文件
FileMove(localTempXml, localFileXml); // FileMove(localTempXml, localFileXml);
versionUpdateOnCompleted(); // versionUpdateOnCompleted();
} // }
} //}
/// <summary> /// <summary>
/// 文件移动 /// 文件移动
/// </summary> /// </summary>
@ -325,7 +329,7 @@ public class UpdateManager : MonoBehaviour {
{ {
Debug.LogError(exception.Message); Debug.LogError(exception.Message);
} }
} }
private void createLocalFileXml(string path) private void createLocalFileXml(string path)
{ {
XmlDocument document = new XmlDocument(); XmlDocument document = new XmlDocument();

4
Assets/Scripts/Replay/DisasterManager.cs

@ -18,7 +18,7 @@ public class DisasterManager : MonoBehaviour
private void Awake() private void Awake()
{ {
//updateFlag = false; //updateFlag = false;
editorRight = true;//单机版 //editorRight = true;//单机版
//editorRight = true;//联机版 //editorRight = true;//联机版
} }
private void Start() private void Start()
@ -130,7 +130,7 @@ public class DisasterManager : MonoBehaviour
obj.nodeID = int.Parse(node.GetAttribute("ID")); obj.nodeID = int.Parse(node.GetAttribute("ID"));
obj.nodeName = node.GetAttribute("Name"); obj.nodeName = node.GetAttribute("Name");
obj.nodeDetail = node.GetAttribute("Detail"); obj.nodeDetail = node.GetAttribute("Detail");
obj.ParentID= int.Parse(node.GetAttribute("ParentID")); obj.ParentID = int.Parse(node.GetAttribute("ParentID"));
secondNodeObjects.Add(obj); secondNodeObjects.Add(obj);
} }
} }

18
Assets/Scripts/UIScripts/EditorRight.cs

@ -6,28 +6,30 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
public class EditorRight : MonoBehaviour { public class EditorRight : MonoBehaviour
{
private Toggle toggle; private Toggle toggle;
// Use this for initialization // Use this for initialization
void Start () void Start()
{ {
toggle = GetComponent<Toggle>(); toggle = GetComponent<Toggle>();
toggle.onValueChanged.AddListener(SetEditorRight); toggle.onValueChanged.AddListener(SetEditorRight);
} }
private void SetEditorRight(bool isOn) private void SetEditorRight(bool isOn)
{ {
DisasterManager.editorRight = isOn; DisasterManager.editorRight = isOn;
MessageDispatcher.SendMessage("PlayStatusChanged"); MessageDispatcher.SendMessage("PlayStatusChanged");
NetworkManager.Default.SendAsync("DISASTER_EDITOR_RIGHT_SYNC", new EditorRightStruct { controlRight= isOn , disasterID= DisasterManager.disaster.Id });//单机版注释 //NetworkManager.Default.SendAsync("DISASTER_EDITOR_RIGHT_SYNC", new EditorRightStruct { controlRight= isOn , disasterID= DisasterManager.disaster.Id });//单机版注释
GetComponent<DISASTER_EDITOR_RIGHT_SYNC>().SetInteractable(isOn); GetComponent<DISASTER_EDITOR_RIGHT_SYNC>().SetInteractable(isOn);
} }
// Update is called once per frame // Update is called once per frame
void Update () { void Update()
{
}
}
} }
public struct EditorRightStruct public struct EditorRightStruct
{ {

BIN
Assets/Sky/Materials/azure[Sky].mat

Binary file not shown.

2
Assets/StreamingAssets/TianQiSettingData.xml

@ -1 +1 @@
<Root>{"tianqi":0,"wendu":10,"fengli":2,"fengxiang":0,"datetime":11,"neightLast":1,"Hasneight":0}</Root> <Root>{"tianqi":0,"wendu":10,"fengli":4,"fengxiang":2,"datetime":11,"neightLast":1,"Hasneight":0}</Root>

BIN
ProjectSettings/ProjectSettings.asset

Binary file not shown.
Loading…
Cancel
Save