public void UpdateAssetBundle(UpdateInfo updateInfo, Dictionary <string, string> headers, IEnumerable <AssetBundleInfo> assetBundleifInfos, VersionInfo persistentInfos, string version, GameFrameworkAction <DownloadProgressInfo, string> progressHandle = null, GameFrameworkAction <AssetBundleInfo> anyCompleteHandle = null, GameFrameworkAction allCompleteHandle = null, GameFrameworkAction <string> errorHandle = null) { DownloadManager.AllCompleteHandle = () => { persistentInfos.SetVersion(version); _updateVersionInfoFile(persistentInfos); allCompleteHandle?.Invoke(); }; List <DownloadUnitInfo> downloadUnitInfos = new List <DownloadUnitInfo>(); foreach (var assetBundleInfo in assetBundleifInfos) { var downloadTools = new UnityWebRequestDownload(_coroutine); if (headers != null) { var unityWeb = (UnityWebRequest)downloadTools.DownlodTool; foreach (var pair in headers) { unityWeb.SetRequestHeader(pair.Key, pair.Value); } } downloadUnitInfos.Add(new DownloadUnitInfo() { CompleteHandle = x => { persistentInfos.AddOrUpdateAssetBundleInfo(assetBundleInfo); _updateVersionInfoFile(persistentInfos); anyCompleteHandle?.Invoke(assetBundleInfo); //解压 Utility.ZipUtil.UnzipZip(x, Application.persistentDataPath); GameFramework.Utility.FileUtil.DeleteFile(x); }, ErrorHandle = errorHandle.Invoke, DownloadProgressHandle = progressHandle.Invoke, FileName = assetBundleInfo.PackName.Replace("dat", "zip"), SavePath = Path.Combine(Application.persistentDataPath, assetBundleInfo.PackPath), Url = updateInfo.AssetBundleUrl + "/" + assetBundleInfo.PackFullName.Replace("dat", "zip"), IsFindCacheLibrary = false, //ab包更新不找缓存 DownloadUtil = downloadTools, Headers = headers }); } DownloadManager.AddRangeDownload(downloadUnitInfos); }
public void Check(Dictionary <string, string> headers, GameFrameworkAction <IEnumerable <AssetBundleInfo> > checkAssetBundleInfoCompleteHandle = null, GameFrameworkFunc <string> getAppUpdateUrl = null, GameFrameworkAction <string> errorHandle = null, GameFrameworkAction <string> stateUpdateHandle = null) { _isInitCheck = false; _completeHandle = checkAssetBundleInfoCompleteHandle; _errorHandle = errorHandle; _stateUpdateHandle = stateUpdateHandle; _getAppUpdateUrl = getAppUpdateUrl; _stateUpdate("资源版本,检查开始!"); StartCoroutine(_check(headers)); }
IEnumerator LoadAsset(string path, GameFrameworkAction <AssetBundle, string> LoadAssetCallBack) { using (WWW www = new WWW(path)) { yield return(www); if (LoadAssetCallBack != null) { LoadAssetCallBack(www.assetBundle, www.error); } } }
/// <summary> /// 初始化版本资源列表处理器的新实例。 /// </summary> /// <param name="resourceManager">资源管理器。</param> public VersionListProcessor(ResourceManager resourceManager) { m_ResourceManager = resourceManager; m_DownloadManager = null; m_VersionListLength = 0; m_VersionListHashCode = 0; m_VersionListZipLength = 0; m_VersionListZipHashCode = 0; VersionListUpdateSuccess = null; VersionListUpdateFailure = null; }
public DownloadAgent(IDownloadAgentHelper downloadAgentHelper) { m_Helper = downloadAgentHelper; m_Task = null; m_FileStream = null; m_WaitFlushSize = 0; m_StartLength = 0; m_SavedLength = 0; m_Disposed = false; DownloadAgentStart = null; }
/// <summary> /// 初始化资源检查器的新实例。 /// </summary> /// <param name="resourceManager">资源管理器。</param> public ResourceChecker(ResourceManager resourceManager) { m_ResourceManager = resourceManager; m_CheckInfos = new Dictionary <ResourceName, CheckInfo>(); m_CurrentVariant = null; m_VersionListReady = false; m_ReadOnlyListReady = false; m_ReadWriteListReady = false; ResourceNeedUpdate = null; ResourceCheckComplete = null; }
public NetworkChannel(string name, INetworkChannel networkChannelHelper) { m_Name = name ?? string.Empty; m_EventPool = new EventPool<Packet>(EventPoolMode.Defalut); m_NetworkChannelHelper = networkChannelHelper; m_Socket = null; m_ReceiveState = new ReceiveState(); m_Disposed = false; NetworkChannelConnected = null; networkChannelHelper.Initialize(this); }
public ResourceUpdater(ResourceManager resourceManager) { m_ResourceManager = resourceManager; m_UpdateWaitingInfo = new List<UpdateInfo>(); m_DownloadManager = null; m_CheckResourceComplete = false; m_UpdateAllowed = false; m_UpdateComplete = false; m_RetryCount = 3; m_UpdatingCount = 0; ResourceUpdateStart = null; }
/// <summary> /// 初始化 Web 请求代理的新实例。 /// </summary> /// <param name="webRequestAgentHelper">Web 请求代理辅助器。</param> public WebRequestAgent(IWebRequestAgentHelper webRequestAgentHelper) { if (webRequestAgentHelper == null) { Debug.LogError("Web request agent helper is invalid."); } m_Helper = webRequestAgentHelper; m_Task = null; m_WaitTime = 0f; WebRequestAgentStart = null; WebRequestAgentSuccess = null; WebRequestAgentFailure = null; }
public static void LoadText(string fileName, GameFrameworkAction <string> action) { GameEntry.Resource.LoadAsset(AssetUtility.GetDataTableAsset(fileName, LoadType.Bytes), new LoadAssetCallbacks( (assetName, asset, duration, userData) => { Log.Info("Load UIItem prefab '{0}' OK.", assetName); action(asset.ToString()); }, (assetName, status, errorMessage, userData) => { Log.Error("Can not load UIItem prefab '{0}' error message '{1}'.", assetName, errorMessage); action(""); })); }
/// <summary> /// 初始化 Web 请求代理的新实例。 /// </summary> /// <param name="webRequestAgentHelper">Web 请求代理辅助器。</param> public WebRequestAgent(IWebRequestAgentHelper webRequestAgentHelper) { if (webRequestAgentHelper == null) { throw new System.Exception("Web request agent helper is invalid."); } m_Helper = webRequestAgentHelper; m_Task = null; m_WaitTime = 0f; WebRequestAgentStart = null; WebRequestAgentSuccess = null; WebRequestAgentFailure = null; }
/// <summary> /// 初始化资源校验器的新实例。 /// </summary> /// <param name="resourceManager">资源管理器。</param> public ResourceVerifier(ResourceManager resourceManager) { m_ResourceManager = resourceManager; m_VerifyInfos = new List <VerifyInfo>(); m_CachedHashBytes = new byte[CachedHashBytesLength]; m_LoadReadWriteVersionListComplete = false; m_VerifyResourceLengthPerFrame = 0; m_VerifyResourceIndex = 0; m_FailureFlag = false; ResourceVerifyStart = null; ResourceVerifySuccess = null; ResourceVerifyFailure = null; ResourceVerifyComplete = null; }
public static void LoadUIItem(string fileName, GameFrameworkAction <GameObject, string> action, string str) { GameEntry.Resource.LoadAsset(AssetUtility.GetUIItemAsset(fileName), new LoadAssetCallbacks( (assetName, asset, duration, userData) => { Log.Info("Load UIItem prefab '{0}' OK.", assetName); action(asset as GameObject, str); }, (assetName, status, errorMessage, userData) => { Log.Error("Can not load UIItem prefab '{0}' error message '{1}'.", assetName, errorMessage); action(null, null); })); }
public void SetConfirUI(DialogParams dialogParams) { if (m_title != null) { m_title.text = dialogParams.Title; } if (m_content != null) { m_content.text = dialogParams.Message; } OnClickConfirm = dialogParams.OnClickConfirm; OnClickCancel = dialogParams.OnClickCancel; m_UserData = dialogParams.UserData; }
public override bool Select(GameObject go, GameFrameworkAction finish) { if (!m_IsComplete) { for (int i = 0; i < m_MapPuzzleDatas.Length; i++) { if (m_MapPuzzleDatas[i].Select(go)) { SelectSuccess(); } } m_IsComplete = IsAllComplete(); if (m_IsComplete) { ComplateFirst(); } } else { if (m_IsPropComplete) { return(true); } for (int i = 0; i < m_PropTouchObjs.Length; i++) { if (m_PropTouchObjs[i] == go && !m_PropFlags[i]) { m_PropFlags[i] = true; SelectSuccess(); Scale(m_PropObjs[i]); m_IsPropComplete = IsAllPropComplete(); if (m_IsPropComplete) { if (OnComplatre != null) { OnComplatre(); } } } } } return(false); }
protected override void OnClose(object userData) { if (m_PauseGame) { GameEntry.Base.ResumeGame(); } m_CloseTime = 0; m_TitleText.text = string.Empty; m_MessageText.text = string.Empty; m_PauseGame = false; m_RunOnce = false; m_UserData = null; m_OnFinish = null; base.OnClose(userData); }
/// <summary> /// 连接服务器 /// </summary> /// <returns>The connect.</returns> /// <param name="serverIp">Server ip.</param> /// <param name="serverPort">Server port.</param> /// <param name="connectSuccessCallback">Connect callback.</param> /// <param name="connectFailedCallback">Connect failed callback.</param> public void Connect(string serverIp, int serverPort, GameFrameworkAction connectSuccessCallback, GameFrameworkAction connectFailedCallback) { m_ConnectSuccessDelegate = connectSuccessCallback; m_ConnectFailedDelegate = connectFailedCallback; //采用TCP方式连接 m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //服务器IP地址 IPAddress address = IPAddress.Parse(serverIp); //服务器端口 IPEndPoint endpoint = new IPEndPoint(address, serverPort); //异步连接,连接成功调用connectCallback方法 IAsyncResult result = m_Socket.BeginConnect(endpoint, new AsyncCallback(ConnectedSuccessCallback), m_Socket); //这里做一个超时的监测,当连接超过5秒还没成功表示超时 bool success = result.AsyncWaitHandle.WaitOne(5000, true); if (!success) { //超时 if (m_ConnectFailedDelegate != null) { m_ConnectFailedDelegate(); } Closed(); } else { //与socket建立连接成功,开启线程接受服务端数据。 m_IsStopReceive = false; m_ThreadReceive = new Thread(ReceiveSocket) { IsBackground = true }; m_ThreadReceive.Start(); } if (m_RegisterResp != null) { m_RegisterResp(); } }
protected override void OnOpen(object userData) { base.OnOpen(userData); DialogFormParams data = (DialogFormParams)userData; if (data == null) { Log.Warning("DialogFormParams is invalid."); return; } m_DialogMode = data.Mode; RefreshDialogMode(); m_TitleText.text = data.Title; m_MessageText.text = data.Message; m_PauseGame = data.PauseGame; RefreshPauseGame(); m_UserData = data.UserData; if (m_ConfirmButton != null) { RefreshConfirmText(data.ConfirmText); m_OnClickConfirm = data.OnClickConfirm; m_ConfirmButton.onClick.Add(OnConfirmButtonClick); } if (m_CancelButton != null) { RefreshCancelText(data.CancelText); m_OnClickCancel = data.OnClickCancel; m_CancelButton.onClick.Add(OnCancelButtonClick); } if (m_OtherButton != null) { RefreshOtherText(data.OtherText); m_OnClickOther = data.OnClickOther; m_OtherButton.onClick.Add(OnOtherButtonClick); } }
/// <summary> /// 初始化资源更新器的新实例 /// </summary> /// <param name="resourceManager"></param> public ResourceUpdater(ResourceManager resourceManager) { m_ResourceManager = resourceManager; m_UpdateWaitingInfo = new List <UpdateInfo>(); m_UpdateFailureInfo = new List <UpdateInfo>(); m_DownloadManager = null; m_CheckResourcesComplete = false; m_UpdateAllowed = false; m_GenerateReadWriteListLength = 0; m_CurrentGenerateReadWriteListLength = 0; m_RetryCount = 3; m_UpdatingCount = 0; ResourceUpdateStart = null; ResourceUpdateChanged = null; ResourceUpdateSuccess = null; ResourceUpdateFailure = null; ResourceUpdateAllComplete = null; }
/// <summary> /// 界面销毁 /// </summary> protected override void OnDestroy() { luaOnDestroy?.Invoke(); luaOnInit = null; luaOnOpen = null; luaOnClose = null; luaOnPause = null; luaOnResume = null; luaOnCover = null; luaOnReveal = null; luaOnRefocus = null; luaOnUpdate = null; luaOnDepthChanged = null; luaOnDestroy = null; m_luaForm.Dispose(); base.OnDestroy(); }
protected void SecondFinger(GameFrameworkAction secondEvent) { m_SlapEffect.gameObject.SetActive(true); m_SlapEffect.Rewind(() => { m_SlapEffect.Rewind(() => { m_SlapEffect.Rewind(() => { m_SlapEffect.Stop(); m_SlapEffect.gameObject.SetActive(false); if (secondEvent != null) { secondEvent(); } }); }); }); }
/// <summary> /// 界面销毁 /// </summary> public override void Clear() { luaOnDestroy?.Invoke(); luaOnInit = null; luaOnOpen = null; luaOnClose = null; luaOnPause = null; luaOnResume = null; luaOnCover = null; luaOnReveal = null; luaOnRefocus = null; luaOnUpdate = null; luaOnDepthChanged = null; luaOnDestroy = null; m_luaForm?.Dispose(); base.Clear(); }
/// <summary> /// 移动笔刷 /// </summary> /// <param name="paint_drum"></param> /// <param name="finish"></param> public void MoveTo(PaintDrum paint_drum, GameFrameworkAction finish) { paint_drum.BrushStopShake(); Sequence ms = DOTween.Sequence(); Tween move1 = paint_drum.BrushTransform.DOMove(transform.position + Vector3.left, 1).SetEase(Ease.Linear); Tween move2 = paint_drum.BrushTransform.DOMoveX(transform.position.x + 1, 0.625f).SetLoops(4, LoopType.Yoyo); StartCoroutine(IEnumeratorBrush()); move2.OnComplete(() => { if (finish != null) { finish(); } m_ColorMask.enabled = true; paint_drum.InitBrush(); }); ms.Append(move1); ms.Append(move2); }
/// <summary> /// 初始化自定义网络频道的新实例。 /// </summary> /// <param name="name">网络频道名称。</param> /// <param name="networkChannelHelper">网络频道辅助器。</param> public WebSocketChannel(string name, IWebSocketChannelHelper networkChannelHelper) { m_Name = name ?? string.Empty; m_NetworkChannelHelper = networkChannelHelper; m_ResetHeartBeatElapseSecondsWhenReceivePacket = false; m_HeartBeatInterval = DefaultHeartBeatInterval; m_Socket = null; m_heartbeatTime = 0f; m_missingHeartBeatCount = 0; m_Active = false; m_Disposed = false; NetworkChannelConnected = null; NetworkChannelClosed = null; NetworkChannelSended = null; NetworkChannelMissHeartBeat = null; NetworkChannelError = null; networkChannelHelper.Initialize(this); }
protected override void OnOpen(object userData) { base.OnOpen(userData); DialogParams dialogParams = (DialogParams)userData; if (dialogParams == null) { Log.Warning("DialogParams is invalid."); return; } m_CloseTime = dialogParams.CloseTime; m_TitleText.text = dialogParams.Title; m_MessageText.text = dialogParams.Message; m_PauseGame = dialogParams.PauseGame; RefreshPauseGame(); m_UserData = dialogParams.UserData; m_OnFinish = dialogParams.OnFinish; }
/// <summary> /// 初始化资源更新器的新实例。 /// </summary> /// <param name="resourceManager">资源管理器。</param> public ResourceUpdater(ResourceManager resourceManager) { m_ResourceManager = resourceManager; m_UpdateWaitingInfo = new List <UpdateInfo>(); m_UpdateCandidateInfo = new List <UpdateInfo>(); m_CachedHashBytes = new byte[CachedHashBytesLength]; m_DownloadManager = null; m_CheckResourcesComplete = false; m_UpdatingResourceGroup = null; m_GenerateReadWriteListLength = 0; m_CurrentGenerateReadWriteListLength = 0; m_UpdateRetryCount = 3; m_UpdatingCount = 0; m_FailureFlag = false; ResourceUpdateStart = null; ResourceUpdateChanged = null; ResourceUpdateSuccess = null; ResourceUpdateFailure = null; ResourceUpdateAllComplete = null; }
public DownloadAgent(IDownloadAgentHelper downloadAgentHelper) { if (downloadAgentHelper == null) { throw new GameFrameworkException("Download agent helper is invalid."); } m_Helper = downloadAgentHelper; m_Task = null; m_FileStream = null; m_WaitFlushSize = 0; m_WaitTime = 0; m_StartLength = 0; m_DownloadedLength = 0; m_SavedLength = 0; m_Disposed = false; DownloadAgentStart = null; DownloadAgentUpdate = null; DownloadAgentSuccess = null; DownloadAgentFailure = null; }
public void OpenDialog(DialogFormParams data) { if (data == null) { Log.Warning("DialogFormParams is invalid."); return; } m_DialogMode = data.Mode; RefreshDialogMode(); m_TitleText.text = data.Title; m_MessageText.text = data.Message; m_PauseGame = data.PauseGame; RefreshPauseGame(); m_UserData = data.UserData; if (m_ConfirmButton != null) { RefreshConfirmText(data.ConfirmText); m_OnClickConfirm = data.OnClickConfirm; m_ConfirmButton.onClick.AddListener(OnConfirmButtonClick); } if (m_CancelButton != null) { RefreshCancelText(data.CancelText); m_OnClickCancel = data.OnClickCancel; m_CancelButton.onClick.AddListener(OnCancelButtonClick); } if (m_OtherButton != null) { RefreshOtherText(data.OtherText); m_OnClickOther = data.OnClickOther; m_OtherButton.onClick.AddListener(OnOtherButtonClick); } }
/// <summary> /// 初始化网络频道的新实例。 /// </summary> /// <param name="name">网络频道名称。</param> /// <param name="networkHelper">网络辅助器。</param> public NetworkChannel(string name, INetworkHelper networkHelper) { m_Name = name ?? string.Empty; m_NetworkHelper = networkHelper; m_NetworkType = NetworkType.Unknown; m_MaxPacketLength = DefaultMaxPacketLength; m_ResetHeartBeatElapseSecondsWhenReceivePacket = false; m_HeartBeatInterval = DefaultHeartBeatInterval; m_Socket = null; m_ReceiveState = null; m_HeartBeatState = new HeartBeatState(); m_Active = false; m_Disposed = false; NetworkChannelConnected = null; NetworkChannelClosed = null; NetworkChannelSended = null; NetworkChannelReceived = null; NetworkChannelMissHeartBeat = null; NetworkChannelError = null; NetworkChannelCustomError = null; }
protected void FirstFinger(GameFrameworkAction firstEvent) { m_Finger.gameObject.SetActive(true); Vector3 pos = m_Finger.localPosition + Vector3.down * 20; m_Finger.localPosition = pos; //Finger.DOLocalMoveY(pos.y + 20, 0.5f).SetLoops(3, LoopType.Yoyo); Sequence sequence = DOTween.Sequence(); for (int i = 0; i < 3; i++) { Tween move_up = m_Finger.DOLocalMoveY(pos.y + 20, 0.5f); Tween move_down = m_Finger.DOLocalMoveY(pos.y - 20, 0.5f); sequence.Append(move_up); sequence.Append(move_down); } Tween move = m_Finger.DOLocalMoveY(pos.y + 20, 0.5f).OnComplete(() => { m_Finger.gameObject.SetActive(false); Slap.gameObject.SetActive(true); Slap.Rewind(() => { Slap.Rewind(() => { Slap.Rewind(() => { Slap.Stop(); Slap.gameObject.SetActive(false); if (firstEvent != null) { firstEvent(); } }); }); }); }); sequence.Append(move); }