public void Update(float delta) { if (m_bError) { NativeInterface.ShowMsgAndExit("res_save_error", 109); return; } if (m_ActiveDown != null) { if (m_ActiveDown.Type == DownloadType.DOWNLOAD_MULTI_FILE && m_ActiveDown.DownloadBytes != 0) { } else { m_UpdateUI.SetIsQueue(m_ActiveDown.IsQueue, m_ActiveDown.Type == DownloadType.DOWNLOAD_CHECK_VER); } if (m_ActiveDown.IsQueue) { m_UpdateTick = Utility.GetTickCount(); } } switch (m_State) { case UpdateState.UPDATE_CHECK_LOCALVER: CheckLocalFile(); break; case UpdateState.UPDATE_UNZIPING_FILE: CheckUnzipping(); break; case UpdateState.UPDATE_INIT: m_UpdateTick = Utility.GetTickCount(); string ftpurl = RuntimeInfo.GetFTPVersionURL(); m_ActiveDown = FTPClient.Instance.AddDownload(DownloadType.DOWNLOAD_CHECK_VER, ftpurl, null); m_State = UpdateState.UPDATE_DOWNLOAD_VERSION; break; case UpdateState.UPDATE_DOWNLOAD_VERSION: if (m_ActiveDown.IsOK) { m_RetryCount = 0; string xml = m_ActiveDown.Text; m_ActiveDown = null; if (!CheckVersion(xml)) { NativeInterface.ShowMsgAndExit("update_error", 101); } } else if (m_ActiveDown.HasError) { //出错了 if (++m_RetryCount > MAX_RETRY_COUNT) { NativeInterface.ShowMsgAndExit("res_connect_error", 102); } else { m_State = UpdateState.UPDATE_INIT; m_ActiveDown = null; } } else { if (m_ActiveDown.IsQueue == false && Utility.GetTickCount() - m_UpdateTick > UPDATE_VERSION_TIME_OUT) { NativeInterface.ShowMsgAndExit("res_connect_error", 103); } } break; case UpdateState.UPDATE_DOWNLOAD_RES: if (m_ActiveDown == null) { if (m_DownList.Count > 0) { m_DownloadBytes = 0; m_UpdateTick = Utility.GetTickCount(); m_UpdateUI.BeginDown(ResType.FishRes); m_ActiveDown = FTPClient.Instance.AddMultiResDownload(DownloadType.DOWNLOAD_MULTI_FILE, m_ResFtpList, m_DownList); m_RecvFileCount = m_DownList.Count; m_DownList.Clear(); } else { m_State = UpdateState.UPDATE_COMPLETE; } } else if (m_ActiveDown.IsOK) { m_RetryCount = 0; m_CurrentDownloadBytes += m_ActiveDown.DownloadBytes; m_DownloadBytes = 0; //m_ThreadList.AddItem(m_ActiveDown); SaveDownloadData(m_ActiveDown); m_ActiveDown = null; } else if (m_ActiveDown.HasError) { NativeInterface.ShowMsgAndExit("update_error", 105); } else { if (m_ActiveDown.IsQueue) { //排队中 } else if (m_DownloadBytes != m_ActiveDown.DownloadBytes) { m_DownloadBytes = m_ActiveDown.DownloadBytes; m_UpdateTick = Utility.GetTickCount(); MultiFileDownData mfdd = (MultiFileDownData)m_ActiveDown.Data; if (mfdd.OutsideRecvIndex < mfdd.RecvCount) { SaveDownloadData(m_ActiveDown); } } else if (Utility.GetTickCount() - m_UpdateTick > UPDATE_RES_TIME_OUT) { NativeInterface.ShowMsgAndExit("update_error", 106); } } break; case UpdateState.UPDATE_COMPLETE: //if (m_DownloadCompletionCount != m_DownloadOrgCount) //{ // m_UpdateUI.SetUnzipping(); // return; //} //更新完成,进入下一个逻辑 if (m_SaveCount != m_RecvFileCount) { return; } if (m_bNewClient) { if (RuntimeInfo.GetPlatform() == GamePlatformType.Android) { NativeInterface.DownNewClientVersion(GetClientPath()); } else if (RuntimeInfo.GetPlatform() == GamePlatformType.Windows) { NativeInterface.ShowMsgAndExit("update_restart", 0); } else { NativeInterface.DownNewClientVersion(m_NewClientURL); } } else { LogicManager.Instance.Forward(null); } break; case UpdateState.UPDATE_NEW_CLIENT: LogicManager.Instance.Shutdown(); break; } }