/// <summary> /// Needs to be called before any of the usage methods are called. /// </summary> /// <param name="content">GameObjects will load into this conent manager.</param> /// <param name="graphics">Used for rendering.</param> public void Initialize(ContentManager content, GraphicsDeviceManager graphics) { mContent = content; mGraphics = graphics; mSpriteRasterState = new RasterizerState(); mSpriteSamplerState = new SamplerState(); // Prevent the edge of the sprite showing garabage. mSpriteRasterState.MultiSampleAntiAlias = false; // Keep the sprites looking Crisp. mSpriteSamplerState.Filter = TextureFilter.Point; mMultiply = new BlendState(); mMultiply.ColorSourceBlend = Blend.Zero; mMultiply.ColorDestinationBlend = Blend.SourceColor; // For now just hard code it. Eventually this should be driven by the Game side. mDefaultEffect = content.Load <Effect>("Shaders\\Default"); mCurrentUpdatePass = BehaviourDefinition.Passes.DEFAULT; // Just an arbitrary choice. mCellSize = 100; mCurrentUpdateState = UpdatePhase.None; }
public Shaker(Transform transform, float duration, float amount = Constants.PIXEL_SIZE, UpdatePhase phase = UpdatePhase.Update) { this.transform = transform; this.duration = duration; this.amount = amount; this.phase = phase; }
/// <summary> /// 组合打包文件 /// </summary> /// <returns></returns> private IEnumerator PitchFile() { this.m_updatPhase = UpdatePhase.PitchFile; string fileName = "Temp/" + KTConfigs.kSrcName; string deltaName = "Temp/" + KTConfigs.kDeltaName; Debug.Log("组合补丁文件"); Directory.SetCurrentDirectory(KTPathHelper.DataPath); OctodiffUtil.ExecutePitch(fileName, deltaName, KTConfigs.kSrcName); //把新的src.zip文件拷贝到persistentDataPath/Temp目录下,覆盖掉原来的src.zip if (File.Exists(fileName)) { File.Delete(fileName); } if (File.Exists(KTConfigs.kSrcName)) { File.Move(KTConfigs.kSrcName, fileName); } //删掉除Temp目录之外的所有旧资源,目录直接删掉,文件不需要删,会直接覆盖 Directory.Delete(KTPathHelper.DataPath + "BuildRes", true); Directory.Delete(KTPathHelper.DataPath + "lua", true); Directory.SetCurrentDirectory(Application.dataPath.Replace("/Assets", "")); Debug.Log("解压src.zip"); this.m_updatPhase = UpdatePhase.UnZipFile; ZipTool.unZipFile(KTPathHelper.DataPath + fileName, KTPathHelper.DataPath);//需要时间 yield return(UpdateComplete()); }
private void OnBufferUpdateSettings(Buffer buffer, UpdatePhase phase) { if (phase == UpdatePhase.ChangeCurrentDirectory) { Reload(); } }
public void UpdateSettings(Settings settings, UpdatePhase phase) { for (Nest nestI = list.Head; nestI != null; nestI = nestI.Child) { nestI.UpdateSettings(settings, phase); } }
override protected void DoUpdateSettings(Settings settings, UpdatePhase phase) { if (phase == UpdatePhase.Raw) { settings.ApplySimpleParameters(variantsTextBox, null); settings.ApplySimpleParameters(textBox, null); textBox.SetViMap(settings.viMapSource.Value, settings.viMapResult.Value); SetTextBoxParameters(); if (findInFilesData != null) { settings.ApplySimpleParameters(filterTextBox, null, false); filterTextBox.SetViMap(settings.viMapSource.Value, settings.viMapResult.Value); } } else if (phase == UpdatePhase.Parsed) { BackColor = settings.ParsedScheme.tabsBg.color; variantsTextBox.Scheme = settings.ParsedScheme; textBox.Scheme = settings.ParsedScheme; tabBar.Scheme = settings.ParsedScheme; if (findInFilesData != null) { filterTextBox.Scheme = settings.ParsedScheme; UpdateFilterText(); } } else if (phase == UpdatePhase.FindParams) { UpdateFindParams(); if (ignoreCase != tempSettings.FindParams.ignoreCase) { UpdateVariantsText(); } } }
override protected void DoUpdateSettings(Settings settings, UpdatePhase phase) { if (phase == UpdatePhase.Raw) { settings.ApplySimpleParameters(textBox, null); } else if (phase == UpdatePhase.Parsed) { textBox.Scheme = settings.ParsedScheme; tabBar.Scheme = settings.ParsedScheme; } }
override protected void DoUpdateSettings(Settings settings, UpdatePhase phase) { if (phase == UpdatePhase.Raw) { settings.ApplySimpleParameters(textBox, null); textBox.SetViMap(settings.viMapSource.Value, settings.viMapResult.Value); } else if (phase == UpdatePhase.Parsed) { textBox.Scheme = settings.ParsedScheme; tabBar.Scheme = settings.ParsedScheme; } }
public void UpdateSettings(Settings settings, UpdatePhase phase) { if (phase == UpdatePhase.TempSettingsLoaded) { if (settingsSize != null && !settingsSize.changed) { size = settingsSize.value; } } if (AFrame != null) { AFrame.UpdateSettings(settings, phase); } }
/// <summary> /// 所有文件下载解压完比 /// </summary> private IEnumerator UpdateComplete() { //覆盖旧的files文件,所有文件都更新成功才覆盖files文件,以便在更新失败后重新进入游戏可以重新更新 Debug.Log("覆盖files"); File.WriteAllBytes(KTPathHelper.DataPath + "files.txt", newFileData); newFileData = null; Debug.Log("更新完成!!"); if (hotUpdateComplete != null) { hotUpdateComplete(); } this.m_updatPhase = UpdatePhase.UpdateOver; yield break; }
private void OnDownloadCompleted(object sender, AsyncCompletedEventArgs e, UpdatePhase phase, LocalizedString errorId, LocalizedString errorMessage) { if (e.Cancelled) { this.downloadException = new UpdatableExchangeHelpSystemException(errorId, errorMessage, ErrorCategory.OperationStopped, this, null); } else if (e.Error != null) { this.downloadException = new UpdatableExchangeHelpSystemException(errorId, errorMessage, ErrorCategory.ResourceUnavailable, this, e.Error); } else { this.downloadException = null; } AutoResetEvent autoResetEvent = (AutoResetEvent)e.UserState; autoResetEvent.Set(); }
internal UpdatableExchangeHelpProgressEventArgs(UpdatePhase phase, LocalizedString subTask, int numerator, int denominator) { LocalizedString value = LocalizedString.Empty; switch (phase) { case UpdatePhase.Checking: value = UpdatableHelpStrings.UpdatePhaseChecking; break; case UpdatePhase.Downloading: value = UpdatableHelpStrings.UpdatePhaseDownloading; break; case UpdatePhase.Extracting: value = UpdatableHelpStrings.UpdatePhaseExtracting; break; case UpdatePhase.Validating: value = UpdatableHelpStrings.UpdatePhaseValidating; break; case UpdatePhase.Installing: value = UpdatableHelpStrings.UpdatePhaseInstalling; break; case UpdatePhase.Finalizing: value = UpdatableHelpStrings.UpdatePhaseFinalizing; break; case UpdatePhase.Rollback: value = UpdatableHelpStrings.UpdatePhaseRollback; break; } this.ProgressStatus = ((!subTask.Equals(LocalizedString.Empty)) ? UpdatableHelpStrings.UpdateStatus2(value, subTask) : UpdatableHelpStrings.UpdateStatus1(value)); this.Activity = UpdatableHelpStrings.UpdateModuleName; if (denominator != 0) { this.PercentCompleted = Math.Abs(numerator) * 100 / Math.Abs(denominator); return; } this.PercentCompleted = 0; }
override protected void DoUpdateSettings(Settings settings, UpdatePhase phase) { this.settings = settings; Buffer buffer = buffers.list.Selected; if (phase == UpdatePhase.Raw) { settings.ApplyParameters(textBox, buffer != null ? buffer.settingsMode : SettingsMode.None, buffer); } else if (phase == UpdatePhase.Parsed) { textBox.Scheme = settings.ParsedScheme; tabBar.Scheme = settings.ParsedScheme; if (settings.showEncoding.Value) { tabBar.Text2Of = Buffer.EncodeOf; } else { tabBar.Text2Of = null; } splitLine.Scheme = settings.ParsedScheme; } else if (phase == UpdatePhase.HighlighterChange) { UpdateHighlighter(); } else if (phase == UpdatePhase.FileSaved) { tabBar.Invalidate(); settings.ApplyOnlyFileParameters(textBox, buffer); } else if (phase == UpdatePhase.CustomRemoveTab) { tabBar.Invalidate(); } if (buffer != null && buffer.onUpdateSettings != null) { buffer.onUpdateSettings(buffer, phase); } }
/// <summary> /// 非增量热更新,第一次运行释放文件 /// 第一次运行,把Application.streamingAssetsPath内的文件拷贝到Application.persistentDataPath目录 /// </summary> /// <returns></returns> private IEnumerator ExtractResource() { this.m_updatPhase = UpdatePhase.ExtractFile; //拷贝files.txt到persistentDataPath目录 string srcPath = KTPathHelper.AppContentPath(); //游戏包资源释放和加载目录 string dstPath = KTPathHelper.DataPath; //发布后的游戏数据存储目录 if (Directory.Exists(dstPath)) { Directory.Delete(dstPath, true); } Directory.CreateDirectory(dstPath); string infile = srcPath + "files.txt"; string outfile = dstPath + "files.txt"; yield return(CopyFile(infile, outfile)); this.m_updatPhase = UpdatePhase.ExtractSrc; //拷贝所有资源到persistentDataPath目录,释放所有文件到数据目录 string[] files = File.ReadAllLines(outfile); foreach (var file in files) { string[] fs = file.Split('|'); infile = srcPath + fs[0]; outfile = dstPath + fs[0]; Debug.Log("正在解包文件:>" + fs[0]); string dir = Path.GetDirectoryName(outfile); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } yield return(CopyFile(infile, outfile)); } Debug.Log("解包完成!!!"); yield return(UpdateResource()); }
/// <summary> /// 第一次运行前,在编辑器模式下,需要把src.zip和files文件从NewVersion目录手动拷贝到streamingAssetsPath目录中 /// 第一次运行游戏,增量更新模式,把资源从streamingAssetsPath目录拷贝到Application.persistentDataPath目录 /// 首先要把src.zip拷贝到persistentDataPath/Temp目录下 /// 再把src.zip解压到Application.persistentDataPath下 /// </summary> /// <returns></returns> private IEnumerator DeltaExtractResource() { this.m_updatPhase = UpdatePhase.DeltaExtractFile; //拷贝files.txt到persistentDataPath目录 string srcPath = KTPathHelper.AppContentPath(); //游戏包资源释放和加载目录 string dstPath = KTPathHelper.DataPath; //发布后的游戏数据存储目录 if (Directory.Exists(dstPath)) { Directory.Delete(dstPath, true); } Directory.CreateDirectory(dstPath); string infile = srcPath + "files.txt"; string outfile = dstPath + "files.txt"; yield return(CopyFile(infile, outfile)); this.m_updatPhase = UpdatePhase.DeltaExtractSrc; if (!Directory.Exists(dstPath + "Temp")) { Directory.CreateDirectory(dstPath + "Temp"); } //拷贝src.zip到persistentDataPath目录 infile = srcPath + KTConfigs.kDeltaName; outfile = dstPath + "Temp/" + KTConfigs.kDeltaName; yield return(CopyFile(infile, outfile)); Debug.Log("解压" + KTConfigs.kDeltaName); ZipTool.unZipFile(outfile, dstPath);//同步操作 需要时间 //if (ZipTool.inputStream.Available > 0) // yield return new WaitForEndOfFrame(); Debug.Log("解包完成!!!"); yield return(DeltaUpdateResource()); }
override protected void DoUpdateSettings(Settings settings, UpdatePhase phase) { if (phase == UpdatePhase.Raw) { settings.ApplySimpleParameters(textBox, null); settings.ApplySimpleParameters(replaceTextBox, null); settings.ApplyToLabel(textLabel); settings.ApplyToLabel(replaceTextLabel); textBox.SetViMap(settings.viMapSource.Value, settings.viMapResult.Value); } else if (phase == UpdatePhase.Parsed) { BackColor = settings.ParsedScheme.tabsBg.color; textBox.Scheme = settings.ParsedScheme; replaceTextBox.Scheme = settings.ParsedScheme; tabBar.Scheme = settings.ParsedScheme; settings.ApplySchemeToLabel(textLabel); settings.ApplySchemeToLabel(replaceTextLabel); } else if (phase == UpdatePhase.FindParams) { UpdateFindParams(); } }
public override void Update(GameTime gameTime) { //in this case, this means that Update was called by someone while Update is already running, this is considered BAD if (_updateThread != null) { throw new Exception("Illegal call to Update on EntityManagerComponent."); } base.Update(gameTime); //initialize all all entities and their components _phase = UpdatePhase.InitializingPhase; _updateThread = System.Threading.Thread.CurrentThread; //store a reference to the currently running thread //we keep doing this until we register empty, this catches all entities created during the Initialize call to any component while (_initializeCache.Count > 0) { //lock onto the cache and get all the entities out, this way when Awake and Start are called those messages can create Entities without issue lock (_lock) { var cache = _initializeCache.ToArray(); _initializeCache.Clear(); //Add to the entity list here, entities are only added to the actual list in the main update thread for thread-safety foreach (var entity in cache) { _entities.Add(entity); entity.RegisterManager(this); //this will register any components already on the entity, which will be captured by _componentInitializeCache } } } //we keep doing this until we register empty, this catches all components that are added during the Initialize call to any component while (_componentInitializeCache.Count > 0) { IEntityComponent[] cache; lock (_lock) { cache = _componentInitializeCache.ToArray(); _componentInitializeCache.Clear(); } foreach (var comp in cache) { comp.Initialize(); _startPool.Enqueue(comp); } } //now call start on all that need it, we keep doing this until we register empty incase any components are registered during the call to Start _phase = UpdatePhase.StartingPhase; while (_startPool.Count > 0) { IEntityComponent comp; if (_startPool.TryDequeue(out comp)) { comp.Start(); } } //perform update on all live entities _phase = UpdatePhase.UpdatingPhase; foreach (var entity in _entities) { if (!entity.Disposed) { entity.Update(gameTime); } } //clean dead entity list _phase = UpdatePhase.CleanUp; while (_deadEntityList.Count > 0) { Entity[] cache; lock (_lock) { cache = _deadEntityList.ToArray(); _deadEntityList.Clear(); } foreach (var entity in cache) { _entities.Remove(entity); } } _updateThread = null; _phase = UpdatePhase.None; }
/// <summary> /// Should be called once per frame. /// </summary> /// <param name="gameTime">The amount of time passed since last update.</param> public void Update(GameTime gameTime) { #if DEBUG // Draw cell boundaries. // Int32 size = mNumCells * mCellSize; for (Int32 y = 0; y < mNumCells; y++) { DebugShapeDisplay.pInstance.AddSegment(new Vector2(0, y * mCellSize), new Vector2(size, y * mCellSize), Color.Black); } for (Int32 x = 0; x < mNumCells; x++) { DebugShapeDisplay.pInstance.AddSegment(new Vector2(x * mCellSize, 0), new Vector2(x * mCellSize, size), Color.Black); } #endif DebugMessageDisplay.pInstance.AddDynamicMessage("Objects Rendered: " + mLastNumObjectsRendered); mCurrentUpdateState = UpdatePhase.Update; // Keep track of how many objects were updated this frame. int count = 0; // Some behaviours require some logic to be done prior to the standard update. This is their chance. // for (int i = 0; i < mGameObjects.Count; i++) { if (mGameObjects[i].pDoUpdate) { mGameObjects[i].PreUpdate(gameTime); } } // Update every object we are managing. // for (int i = 0; i < mGameObjects.Count; i++) { if (mGameObjects[i].pDoUpdate) { mGameObjects[i].Update(gameTime); } count++; } // A final chance to update behaviours after all the updates have been completed. // for (int i = 0; i < mGameObjects.Count; i++) { if (mGameObjects[i].pDoUpdate) { mGameObjects[i].PostUpdate(gameTime); } } DebugMessageDisplay.pInstance.AddDynamicMessage("Updated " + count + " GameObjects"); mCurrentUpdateState = UpdatePhase.Remove; // Now loop through our list of objects which need to be removed and // remove them. // for (int i = 0; i < mGameObjectsToRemove.Count; i++) { // If this is a GameObject that was spawned through a Factory then it needs to be // returned to that Factory. if (mGameObjectsToRemove[i].pFactoryInfo.pIsManaged) { GameObjectFactory.pInstance.RecycleTemplate(mGameObjectsToRemove[i]); } // See if this is also going to be referenced in the dynamic objects list. if (!mGameObjectsToRemove[i].pIsStatic) { mDynamicGameObjects.Remove(mGameObjectsToRemove[i]); } // See if this is going to be reference in the static objects list. if (mGameObjectsToRemove[i].pIsStatic) { // Figure out which cell this object would be in. Vector2 index = CellIndexFromPosition(mGameObjectsToRemove[i].pPosition); // Remove it from the cell it should be in. mStaticGameObjects[(Int32)index.X, (Int32)index.Y].Remove(mGameObjectsToRemove[i]); } for (Int32 tag = 0; tag < mGameObjectsToRemove[i].pClassifications.Count; tag++) { mGameObjectsByClassification[(GameObjectDefinition.Classifications)tag].Remove(mGameObjectsToRemove[i]); } // What happens if someone adds and removes an element within the same // update? It would mean we are about to remove an item that hasn't // actually been added yet! To get around this flaw, we will attempt to // remove the item from the main list and if that fails, try to remove it // from the list of items about to be added. if (mGameObjectsToRemove[i] != null && mGameObjects.Remove(mGameObjectsToRemove[i]) == false) { if (mGameObjectsToAdd.Remove(mGameObjectsToRemove[i]) == false) { //System.Diagnostics.Debug.Assert(false, "Attempting to remove a game object which isn't in any of the managed lists."); } } } mCurrentUpdateState = UpdatePhase.Add; // Loop through all the game objects that exist. We want to insert the new game objects // in the order that they were added, based on render priority. If the new object shares // a render priority with another object, it is inserted in front of the first same-priority // object it hits. // // This bit of code assumes that the mGameObjectsToAdd and mGameObjects are both sorted // based on render priority. // int curIndex = 0; for (int i = 0; i < mGameObjectsToAdd.Count; i++) { // Check if this is a dynamic object which isn't already being managed by this list. if (!mGameObjectsToAdd[i].pIsStatic) { System.Diagnostics.Debug.Assert(!mDynamicGameObjects.Contains(mGameObjectsToAdd[i]), "Attempting to add GameObject already in mDynamicGameObjects."); mDynamicGameObjects.Add(mGameObjectsToAdd[i]); } // Has this object been flagged as being static? if (mGameObjectsToAdd[i].pIsStatic) { // Figure out which cell this object would be in. Vector2 index = CellIndexFromPosition(mGameObjectsToAdd[i].pPosition); System.Diagnostics.Debug.Assert(!mStaticGameObjects[(Int32)index.X, (Int32)index.Y].Contains(mGameObjectsToAdd[i]), "Attempting to add GameObject already in mStaticGameObjects."); mStaticGameObjects[(Int32)index.X, (Int32)index.Y].Add(mGameObjectsToAdd[i]); } for (Int32 tagIndex = 0; tagIndex < mGameObjectsToAdd[i].pClassifications.Count; tagIndex++) { GameObjectDefinition.Classifications tag = mGameObjectsToAdd[i].pClassifications[tagIndex]; mGameObjectsByClassification[tag].Add(mGameObjectsToAdd[i]); } // If this game object is already in the list, don't add it again. if (!mGameObjects.Contains(mGameObjectsToAdd[i])) { bool alreadyAdded = false; // Loop through all the currently exisiting game objects. We continue moving // forward even after inserting a new object. This can be done because we assume // the mGameObjectsToAdd is also sorted by render priority, which means the next // element must be placed somewhere after the current one. for (; curIndex < mGameObjects.Count; curIndex++) { if (mGameObjectsToAdd[i].pRenderPriority < mGameObjects[curIndex].pRenderPriority) { // We have found the proper place for this element. mGameObjects.Insert(curIndex, mGameObjectsToAdd[i]); // We don't want to test against the elemt we just added. Since it was // inserted at i, the object we just compared against is actually at i + 1 // now. Let's start the next comparison there. curIndex++; alreadyAdded = true; break; } } if (!alreadyAdded) { // If we make it to this point all the remaining elements have a greater or equal // render priority to the highest priority item already existing. // This will also take care of the cases where this is the first item being added. mGameObjects.Add(mGameObjectsToAdd[i]); // We don't want to test against the element we just added. Since it was // inserted at i, the object we just compared against is actually at i + 1 // now. Let's start the next comparison there. curIndex++; } } } mCurrentUpdateState = UpdatePhase.OnRemove; if (mGameObjectsToRemove.Count != 0) { // At this point all objects for the frame have been removed from // the GameObjectManager. This is an ideal time to give objects // a chance to do some cleanup which requires objects to // be removed (eg. Delete stuff). for (Int32 i = 0; i < mGameObjectsToRemove.Count; i++) { mGameObjectsToRemove[i].OnRemove(); } mGameObjectsToRemove.Clear(); } mCurrentUpdateState = UpdatePhase.OnAdd; if (mGameObjectsToAdd.Count != 0) { // At this point all objects for the frame have been added to // the GameObjectManager. This is an ideal time to give objects // a chance to do some initization which requires objects to // be added (eg. BroadCastMessage). for (Int32 i = 0; i < mGameObjectsToAdd.Count; i++) { mGameObjectsToAdd[i].OnAdd(); } mGameObjectsToAdd.Clear(); } mCurrentUpdateState = UpdatePhase.None; if (mGameObjectsToRemoveNextFrame.Count > 0) { mGameObjectsToRemove.AddRange(mGameObjectsToRemoveNextFrame); mGameObjectsToRemoveNextFrame.Clear(); } if (mGameObjectsToAddNextFrame.Count > 0) { mGameObjectsToAdd.AddRange(mGameObjectsToAddNextFrame); mGameObjectsToAddNextFrame.Clear(); } }
public void DoUpdate(UpdatePhase phase) { if (!valid) { Reset(); return; } var skeleton = hierarchy.skeletonRenderer.skeleton; if (bone == null) { if (string.IsNullOrEmpty(boneName)) { return; } bone = skeleton.FindBone(boneName); if (bone == null) { Debug.LogError("Bone not found: " + boneName, this); return; } } var thisTransform = cachedTransform; float skeletonFlipRotation = Mathf.Sign(skeleton.scaleX * skeleton.scaleY); if (mode == Mode.Follow) { switch (phase) { case UpdatePhase.Local: if (position) { thisTransform.localPosition = new Vector3(bone.x, bone.y, 0); } if (rotation) { if (bone.data.transformMode.InheritsRotation()) { thisTransform.localRotation = Quaternion.Euler(0, 0, bone.rotation); } else { Vector3 euler = skeletonTransform.rotation.eulerAngles; thisTransform.rotation = Quaternion.Euler(euler.x, euler.y, euler.z + (bone.WorldRotationX * skeletonFlipRotation)); } } if (scale) { thisTransform.localScale = new Vector3(bone.scaleX, bone.scaleY, 1f); incompatibleTransformMode = BoneTransformModeIncompatible(bone); } break; case UpdatePhase.World: case UpdatePhase.Complete: // Use Applied transform values (ax, ay, AppliedRotation, ascale) if world values were modified by constraints. if (!bone.appliedValid) { bone.UpdateAppliedTransform(); } if (position) { thisTransform.localPosition = new Vector3(bone.ax, bone.ay, 0); } if (rotation) { if (bone.data.transformMode.InheritsRotation()) { thisTransform.localRotation = Quaternion.Euler(0, 0, bone.AppliedRotation); } else { Vector3 euler = skeletonTransform.rotation.eulerAngles; thisTransform.rotation = Quaternion.Euler(euler.x, euler.y, euler.z + (bone.WorldRotationX * skeletonFlipRotation)); } } if (scale) { thisTransform.localScale = new Vector3(bone.ascaleX, bone.ascaleY, 1f); incompatibleTransformMode = BoneTransformModeIncompatible(bone); } break; } } else if (mode == Mode.Override) { if (transformLerpComplete) { return; } if (parentReference == null) { if (position) { Vector3 clp = thisTransform.localPosition; bone.x = Mathf.Lerp(bone.x, clp.x, overrideAlpha); bone.y = Mathf.Lerp(bone.y, clp.y, overrideAlpha); } if (rotation) { float angle = Mathf.LerpAngle(bone.Rotation, thisTransform.localRotation.eulerAngles.z, overrideAlpha); bone.Rotation = angle; bone.AppliedRotation = angle; } if (scale) { Vector3 cls = thisTransform.localScale; bone.scaleX = Mathf.Lerp(bone.scaleX, cls.x, overrideAlpha); bone.scaleY = Mathf.Lerp(bone.scaleY, cls.y, overrideAlpha); } } else { if (transformLerpComplete) { return; } if (position) { Vector3 pos = parentReference.InverseTransformPoint(thisTransform.position); bone.x = Mathf.Lerp(bone.x, pos.x, overrideAlpha); bone.y = Mathf.Lerp(bone.y, pos.y, overrideAlpha); } if (rotation) { float angle = Mathf.LerpAngle(bone.Rotation, Quaternion.LookRotation(Vector3.forward, parentReference.InverseTransformDirection(thisTransform.up)).eulerAngles.z, overrideAlpha); bone.Rotation = angle; bone.AppliedRotation = angle; } if (scale) { Vector3 cls = thisTransform.localScale; bone.scaleX = Mathf.Lerp(bone.scaleX, cls.x, overrideAlpha); bone.scaleY = Mathf.Lerp(bone.scaleY, cls.y, overrideAlpha); } incompatibleTransformMode = BoneTransformModeIncompatible(bone); } transformLerpComplete = true; } }
internal void UpdateProgress(UpdatePhase phase, LocalizedString subTask, int numerator, int denominator) { UpdatableExchangeHelpProgressEventArgs e = new UpdatableExchangeHelpProgressEventArgs(phase, subTask, numerator, denominator); this.Cmdlet.HandleProgressChanged(null, e); }
private void BroadcastUpdatePhase(UpdatePhase phase) { OnUpdatePhaseChange?.Invoke(this, new OnUpdatePhaseChangeEventArgs(phase)); }
public OnUpdatePhaseChangeEventArgs(UpdatePhase phase) { Phase = phase; }
/// <summary> /// 增量更新 /// 下载files文件到Application.persistentDataPath下,对比本地files文件判断是否需要更新,如果有 /// 下载delta文件到persistentDataPath/Temp目录下 /// 组合delta文件和src.zip文件到persistentDataPath目录下,名称为src.zip /// 把新的src.zip文件拷贝到persistentDataPath/Temp目录下,覆盖掉原来的src.zip /// 解压新的Temp/src.zip到persistentDataPath目录下 /// 把下载的新files文件覆盖掉原来的files /// </summary> /// <returns></returns> private IEnumerator DeltaUpdateResource() { this.m_updatPhase = UpdatePhase.DeltaUpdate; InitUpdate(); //下载新file string dataPath = KTPathHelper.DataPath; var sb = KTStringBuilderCache.Acquire() .Append("file://") .Append(KTPathHelper.AppContentPath()) .Append("files.txt"); var sb2 = KTStringBuilderCache.Acquire() .Append(KTConfigs.kWebUrl) .Append("files.txt?v=") .Append(DateTime.Now.ToString("yyyymmddhhmmss")); string fileUrl = KTConfigs.kDebugMode ? KTStringBuilderCache.GetStringAndRelease(sb) : KTStringBuilderCache.GetStringAndRelease(sb2); this.m_updatPhase = UpdatePhase.DeltaDownloadNewFile; Debug.Log("LoadUpdate---->>>" + fileUrl); yield return(KTDownloadHelper.WWWDownloadRequest(fileUrl, (www) => { www.bytes.CopyTo(newFileData, 0); var newFileLines = www.text.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.None); var oldFileLines = File.ReadAllLines(dataPath + "files.txt"); ExecuteDownloadTask(newFileLines, oldFileLines); if (m_fileToCreate.Count == 0) { Debug.Log("没有可更新资源"); if (hotUpdateComplete != null) { hotUpdateComplete(); } return; } //创建加载任务 string deltaFullPath = dataPath + "Temp/" + KTConfigs.kDeltaName; if (File.Exists(deltaFullPath)) { File.Delete(deltaFullPath); } sb = KTStringBuilderCache.Acquire() .Append("file://") .Append(KTPathHelper.AppContentPath()) .Append(KTConfigs.kDeltaName); sb2 = KTStringBuilderCache.Acquire()//此处因为暂定只需要下载一个zip文件,所以不需要从m_fileToCreate拿到具体文件名,但当多zip分包时就必须遍历m_fileToCreate下载了 .Append(KTConfigs.kWebUrl) .Append(KTConfigs.kDeltaName) .Append("?v=") .Append(DateTime.Now.ToString("yyyymmddhhmmss")); string deltaUrl = KTConfigs.kDebugMode ? KTStringBuilderCache.GetStringAndRelease(sb) : KTStringBuilderCache.GetStringAndRelease(sb2); this.m_updatPhase = UpdatePhase.DownloadDelta; Debug.Log("LoadUpdate---->>>" + deltaUrl); StartCoroutine(KTDownloadHelper.WWWDownloadRequest(deltaUrl, (www2) => { File.WriteAllBytes(deltaFullPath, www2.bytes); StartCoroutine(PitchFile()); } , (www2) => { StartCoroutine(UpdateFail("下载新src.zip.delta文件失败")); })); } , (www) => { StartCoroutine(UpdateFail("下载新file.txt文件失败")); })); }
virtual protected void DoUpdateSettings(Settings settings, UpdatePhase phase) { }
public void UpdateSettings(Settings settings, UpdatePhase phase) { DoUpdateSettings(settings, phase); SetNeedResize(); }
private void OnProgressChanged(object sender, DownloadProgressChangedEventArgs e, UpdatePhase phase, LocalizedString subTask) { }
/// <summary> /// 普通更新 /// </summary> /// <returns></returns> private IEnumerator UpdateResource() { this.m_updatPhase = UpdatePhase.NormalUpdate; InitUpdate(); //下载新file string dataPath = KTPathHelper.DataPath; var sb = KTStringBuilderCache.Acquire() .Append("file://") .Append(KTPathHelper.AppContentPath()) .Append("files.txt"); var sb2 = KTStringBuilderCache.Acquire() .Append(KTConfigs.kWebUrl) .Append("files.txt?v=") .Append(DateTime.Now.ToString("yyyymmddhhmmss")); string fileUrl = KTConfigs.kDebugMode ? KTStringBuilderCache.GetStringAndRelease(sb) : KTStringBuilderCache.GetStringAndRelease(sb2); this.m_updatPhase = UpdatePhase.DeltaDownloadNewFile; Debug.Log("LoadUpdate---->>>" + fileUrl); //下载file this.m_updatPhase = UpdatePhase.DownloadNewFile; yield return(KTDownloadHelper.WWWDownloadRequest(fileUrl, (www) => { www.bytes.CopyTo(newFileData, 0); string[] newFileLines = www.text.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.None); string[] oldFileLines = File.ReadAllLines(dataPath + "files.txt"); ExecuteDownloadTask(newFileLines, oldFileLines); if (m_fileToCreate.Count == 0) { Debug.Log("没有可更新资源"); if (hotUpdateComplete != null) { hotUpdateComplete(); } return; } if (!Directory.Exists(dataPath)) { Directory.CreateDirectory(dataPath); } ExecuteDownloadTask(newFileLines, oldFileLines); //删掉多余的旧资源 for (int i = 0, j = m_fileToDelete.Count; i < j; i++) { string localfile = (dataPath + m_fileToDelete[i]).Trim(); if (File.Exists(localfile)) { File.Delete(localfile); } } //递归删除BuildRes下的所有空文件夹 DeleteDir(dataPath + "BuildRes"); //创建加载任务 for (int i = 0, j = m_fileToCreate.Count; i < j; i++) { string fileFullPath = (dataPath + m_fileToCreate[i]).Trim(); if (File.Exists(fileFullPath)) { File.Delete(fileFullPath); } string path = Path.GetDirectoryName(fileFullPath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } sb = KTStringBuilderCache.Acquire() .Append("file://") .Append(KTPathHelper.AppContentPath()) .Append(m_fileToCreate[i]); sb2 = KTStringBuilderCache.Acquire() .Append(KTConfigs.kWebUrl) .Append(m_fileToCreate[i]) .Append("?v=") .Append(DateTime.Now.ToString("yyyymmddhhmmss")); string srcUrl = KTConfigs.kDebugMode ? KTStringBuilderCache.GetStringAndRelease(sb) : KTStringBuilderCache.GetStringAndRelease(sb2); KTUpdateLoaderManager.It.Add(srcUrl, fileFullPath); //StartCoroutine(KTDownloadHelper.WWWDownloadRequest(srcUrl, (www2) => //{ // File.WriteAllBytes(fileFullPath, www2.bytes); //} //,(www2) => //{ // StartCoroutine(UpdateFail("下载新"+ m_fileToCreate[i] + "文件失败")); //})); //StartCoroutine(UpdateComplete()); } } , (www) => { StartCoroutine(UpdateFail("下载新file.txt文件失败")); })); this.m_updatPhase = UpdatePhase.DownloadSrc; yield return(KTUpdateLoaderManager.It.StartLoadAsync((data) => { StartCoroutine(UpdateComplete()); }, null, (msg) => { StartCoroutine(UpdateFail("下载新" + msg + "文件失败")); })); }
private static void TabsUpdate(XtraTabControl pagesTabControl, bool savingAll, UpdatePhase phase) { if (!savingAll) { return; } switch (phase) { case UpdatePhase.Begin: pagesTabControl.BeginUpdate(); break; case UpdatePhase.End: pagesTabControl.EndUpdate(); break; } }
public void DoUpdate(UpdatePhase phase) { if (!this.valid) { this.Reset(); } else { Skeleton skeleton = this.skeletonUtility.skeletonRenderer.skeleton; if (this.bone == null) { if (string.IsNullOrEmpty(this.boneName)) { return; } this.bone = skeleton.FindBone(this.boneName); if (this.bone == null) { Debug.LogError("Bone not found: " + this.boneName, this); return; } } Transform cachedTransform = this.cachedTransform; float num = !(skeleton.flipX ^ skeleton.flipY) ? 1f : -1f; if (this.mode != Mode.Follow) { if ((this.mode == Mode.Override) && !this.transformLerpComplete) { if (this.parentReference == null) { if (this.position) { Vector3 localPosition = cachedTransform.localPosition; this.bone.x = Mathf.Lerp(this.bone.x, localPosition.x, this.overrideAlpha); this.bone.y = Mathf.Lerp(this.bone.y, localPosition.y, this.overrideAlpha); } if (this.rotation) { float num2 = Mathf.LerpAngle(this.bone.Rotation, cachedTransform.localRotation.eulerAngles.z, this.overrideAlpha); this.bone.Rotation = num2; this.bone.AppliedRotation = num2; } if (this.scale) { Vector3 localScale = cachedTransform.localScale; this.bone.scaleX = Mathf.Lerp(this.bone.scaleX, localScale.x, this.overrideAlpha); this.bone.scaleY = Mathf.Lerp(this.bone.scaleY, localScale.y, this.overrideAlpha); } } else { if (this.transformLerpComplete) { return; } if (this.position) { Vector3 vector6 = this.parentReference.InverseTransformPoint(cachedTransform.position); this.bone.x = Mathf.Lerp(this.bone.x, vector6.x, this.overrideAlpha); this.bone.y = Mathf.Lerp(this.bone.y, vector6.y, this.overrideAlpha); } if (this.rotation) { float num3 = Mathf.LerpAngle(this.bone.Rotation, Quaternion.LookRotation(Vector3.forward, this.parentReference.InverseTransformDirection(cachedTransform.up)).eulerAngles.z, this.overrideAlpha); this.bone.Rotation = num3; this.bone.AppliedRotation = num3; } if (this.scale) { Vector3 localScale = cachedTransform.localScale; this.bone.scaleX = Mathf.Lerp(this.bone.scaleX, localScale.x, this.overrideAlpha); this.bone.scaleY = Mathf.Lerp(this.bone.scaleY, localScale.y, this.overrideAlpha); } this.incompatibleTransformMode = BoneTransformModeIncompatible(this.bone); } this.transformLerpComplete = true; } } else if (phase != UpdatePhase.Local) { if (((phase == UpdatePhase.World) || (phase == UpdatePhase.Complete)) && !this.bone.appliedValid) { this.bone.UpdateAppliedTransform(); if (this.position) { cachedTransform.localPosition = new Vector3(this.bone.ax, this.bone.ay, 0f); } if (this.rotation) { if (this.bone.data.transformMode.InheritsRotation()) { cachedTransform.localRotation = Quaternion.Euler(0f, 0f, this.bone.AppliedRotation); } else { Vector3 eulerAngles = this.skeletonTransform.rotation.eulerAngles; cachedTransform.rotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z + (this.bone.WorldRotationX * num)); } } if (this.scale) { cachedTransform.localScale = new Vector3(this.bone.ascaleX, this.bone.ascaleY, 1f); this.incompatibleTransformMode = BoneTransformModeIncompatible(this.bone); } } } else { if (this.position) { cachedTransform.localPosition = new Vector3(this.bone.x, this.bone.y, 0f); } if (this.rotation) { if (this.bone.data.transformMode.InheritsRotation()) { cachedTransform.localRotation = Quaternion.Euler(0f, 0f, this.bone.rotation); } else { Vector3 eulerAngles = this.skeletonTransform.rotation.eulerAngles; cachedTransform.rotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z + (this.bone.WorldRotationX * num)); } } if (this.scale) { cachedTransform.localScale = new Vector3(this.bone.scaleX, this.bone.scaleY, 1f); this.incompatibleTransformMode = BoneTransformModeIncompatible(this.bone); } } } }
public System(UpdatePhase phase) { this.UpdatePhase = phase; }