//play soundclip on gameobject public void play(bool loop, OnFinished onfinished){ onFinished = onfinished; isActivated = true; source.Play(); source.volume = 1; source.loop = loop; }
//register functions to be called when action finishes public void register(OnFinished func){ if (onFinished == null) { onFinished = func; } else { onFinished += func; } }
public static void Load(string name, OnFinished onFinished) { switch (loadType) { case LoadType.LoadWithAssetBundleCreateFromFile: if (null != onFinished) { string file = PathUtils.GetAssetBundlesPath () + PathUtils.GetExportedName (name); Object asset = AssetBundleManager.LoadAssetBundleWithFile (file).mainAsset; TryToAddAsset (name, asset); onFinished (asset); } break; case LoadType.LoadWithAssetBundleManager: if (null != onFinished) { Instance.StartCoroutine (Instance.DownloadAB (name, onFinished)); } break; case LoadType.LoadResources: default: if (null != onFinished) { string path = PathUtils.TrimSuffix(name); Object asset = Resources.Load (path); TryToAddAsset (name, asset); onFinished (asset); } break; } }
/// <summary> /// 压缩单个文件 /// </summary> /// <param name="fileToZip">要进行压缩的文件名</param> /// <param name="zipedFile">压缩后生成的压缩文件名</param> /// <param name="level">压缩等级</param> /// <param name="password">密码</param> /// <param name="onFinished">压缩完成后的代理</param> public static void ZipFile(string fileToZip, string zipedFile, string password = "", int level = 5, OnFinished onFinished = null) { //如果文件没有找到,则报错 if (!File.Exists(fileToZip)) throw new FileNotFoundException("指定要压缩的文件: " + fileToZip + " 不存在!"); using (FileStream fs = File.OpenRead(fileToZip)) { byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); fs.Close(); using (FileStream ZipFile = File.Create(zipedFile)) { using (ZipOutputStream ZipStream = new ZipOutputStream(ZipFile)) { string fileName = fileToZip.Substring(fileToZip.LastIndexOf("/") + 1); ZipEntry ZipEntry = new ZipEntry(fileName); ZipStream.PutNextEntry(ZipEntry); ZipStream.SetLevel(level); ZipStream.Password = password; ZipStream.Write(buffer, 0, buffer.Length); ZipStream.Finish(); ZipStream.Close(); if (null != onFinished) onFinished(); } } } }
public void updateText(string text, float dur, OnFinished onFinished = null) { duration = dur; startingTime = Time.time; dialogue = text; this.onFinished = onFinished; SoundManager.Instance.startSound ("gibberish", true, null); }
//Given a sound name, start it and register func to be callled when finished public void startSound(String name, bool loop, OnFinished onFinished){ bool present = false; foreach (Sound sound in sounds) { if (sound.getName () == name) { present = true; if(loop){ if(onFinished != null) onFinished() ; sound.play (loop, null); } sound.play (loop, onFinished); } } }
//Given a sound name, start it and register func to be callled when finished public void startSound(String name, bool loop, OnFinished onFinished){ foreach (Sound sound in sounds) { if (sound.getName () == name) { if(loop){ if(onFinished != null) onFinished() ; sound.play (loop, null); } sound.play (loop, onFinished); return; } } Debug.LogError("Sound " + name + " not found!"); }
public SizeAnimation(int startDelay, int keepTime, int fromSize, int toSize, Cell x, OnFinished onFinished) { this.startDelay = startDelay; this.keepTime = keepTime; this.curTime = 0; this.fromSize = fromSize; this.toSize = toSize; this.x = x; this.onFinished = onFinished; this.Interval = 20; this.Tick += new System.EventHandler(this.Update); this.Enabled = true; x.pic.Size = new System.Drawing.Size(0, 0); }
/// <summary> /// Create a new web request for the following URL, providing the specified parameter. /// </summary> static public void Create (string url, OnFinished callback, object param) { if (Application.isPlaying) { GameObject go = new GameObject("_Game Web Request"); DontDestroyOnLoad(go); GameWebRequest req = go.AddComponent<GameWebRequest>(); #if UNITY_EDITOR Debug.Log(url); #endif req.mURL = url; req.mCallback = callback; req.mParam = param; } }
/// <summary> /// 压缩单个文件 /// </summary> /// <param name="fileToZip">要压缩的文件</param> /// <param name="zipedFile">压缩后的文件</param> /// <param name="compressionLevel">压缩等级</param> /// <param name="blockSize">每次写入大小</param> /// <param name="onFinished">压缩完成后的委托</param> public static void ZipFile(string fileToZip, string zipedFile, int compressionLevel, int blockSize, string password, OnFinished onFinished) { //如果文件没有找到,则报错 if (File.Exists(fileToZip)) throw new FileNotFoundException("指定要压缩的文件: " + fileToZip + " 不存在!"); using (FileStream zipFile = File.Create(zipedFile)) { using (ZipOutputStream zipStream = new ZipOutputStream(zipFile)) { using (FileStream streamToZip = new FileStream(fileToZip, FileMode.Open, FileAccess.Read)) { string fileName = fileToZip.Substring(fileToZip.LastIndexOf("/") + 1); ZipEntry zipEntry = new ZipEntry(fileName); zipStream.PutNextEntry(zipEntry); zipStream.SetLevel(compressionLevel); byte[] buffer = new byte[blockSize]; int sizeRead = 0; try { do { sizeRead = streamToZip.Read(buffer, 0, buffer.Length); zipStream.Write(buffer, 0, sizeRead); } while (sizeRead > 0); } catch (System.Exception ex) { throw ex; } streamToZip.Close(); } zipStream.Finish(); zipStream.Close(); } zipFile.Close(); if (null != onFinished) onFinished(); } }
public IEnumerator Downland(string[] text, UnityAction <float> onProgressChanged, Params paramss = null) { if (paramss == null) { paramss = DefulParams; } List <string> needDownLand = new List <string>(); foreach (var item in text) { if (!localAudio.audioKey.Contains(AudioFileName(item, paramss))) { needDownLand.Add(item); } } float totalCount = text.Length; float currentCount = totalCount - needDownLand.Count; if (currentCount > 0 && onProgressChanged != null) { onProgressChanged(currentCount / totalCount); } if (needDownLand.Count > 0) { OnFinished finishEvent = (result, data) => { currentCount++; }; OnError errorEvent = (err) => { currentCount++; }; TCore.onFinishEvent += finishEvent; TCore.onErrorEvent += errorEvent; foreach (var item in needDownLand.ToArray()) { waitAudioQueue.Enqueue(new KeyValuePair <string, Params>(item, paramss)); } if (downLoadThread == null || !downLoadThread.IsAlive) { downLoadThread = new Thread(ThreadDownLoad); downLoadThread.Start(AudioPath); } var countTemp = currentCount; while (currentCount != totalCount && !connectError) { if (countTemp != currentCount) { if (onProgressChanged != null) { onProgressChanged(currentCount / totalCount); } countTemp = currentCount; } yield return(null); } for (int i = 0; i < needDownLand.Count; i++) { RecordToText(AudioFileName(needDownLand[i], paramss)); } TCore.onFinishEvent -= finishEvent; TCore.onErrorEvent -= errorEvent; } }
//public void Begin(Vector3 pos, int soul, OnFinished onFinished) //{ // transform.position = pos; // mSoulValue = soul; // mTarget = UnitManager.Instance.LocalPlayer; // mMoveState = EMoveState.Rise; // mOnFinished = onFinished; // iTween.MoveTo(gameObject, iTween.Hash( // "y", transform.position.y + RiseHeight, // "time", RiseTime, // "easetype", iTween.EaseType.easeOutCubic, // "oncomplete", "RiseComplete")); //} public void ldaBegin(MeteorUnit attacker, Vector3 pos, int soul, GameObject coin, OnFinished onFinished) { //mCoin = coin; transform.position = pos; mSoulValue = soul; mTarget = attacker; mMoveState = EMoveState.Rise; mOnFinished = onFinished; float rvalue = Random.value * 0.2f; if (Random.Range(0, 10) > 5) { MovingTime += rvalue; } else { MovingTime -= rvalue; } iTween.MoveTo(gameObject, iTween.Hash( "y", transform.position.y, //+ RiseHeight, "time", 0, //RiseTime, "easetype", iTween.EaseType.easeOutCubic, "oncomplete", "RiseComplete")); }
private void CallFinishFunc() { bool?s = OnFinished?.Invoke(); }
private IEnumerator FinishedPlaying(float clipLength) { yield return(new WaitForSeconds(clipLength)); OnFinished?.Invoke(this); }
protected void RaiseOnFinished() => OnFinished?.Invoke(this);
protected void Finish(object args) => OnFinished?.Invoke(args);
/// <summary> /// Invokes the OnFinished event. /// </summary> private void InvokeFinished(TValue value) { OnFinished?.Invoke(value); }
protected void AnimationFinished() { OnFinished?.Invoke(this, null); }
public static IEnumerator GenerateSkin(Mesh p_mesh, SkinnedMeshRenderer p_parent, GameObject p_targetGO, Material p_material, OnFinished p_onFinished, Single BONE_OFFSET, Single MAX_Y_FOR_BONES, Single WEIGHT_FACTOR, Single p_maxBoneAxisOffset) { Transform[] bones = p_parent.bones; Single maxY = p_targetGO.transform.position.y + MAX_Y_FOR_BONES; List <Transform> possibleBonesList = new List <Transform>(); List <Int32> possibleBonesIndeciesList = new List <Int32>(); for (Int32 i = 0; i < bones.Length; i++) { if (maxY >= bones[i].transform.position.y) { possibleBonesList.Add(bones[i]); possibleBonesIndeciesList.Add(i); } } Transform[] possibleBones = possibleBonesList.ToArray(); Int32[] possibleBonesIndecies = possibleBonesIndeciesList.ToArray(); Int32 rootBoneIndex = Array.IndexOf <Transform>(bones, p_parent.rootBone); if (rootBoneIndex < 0) { rootBoneIndex = 0; } Int32[] tris = p_mesh.triangles; Vector3[] vertices = p_mesh.vertices; Int32 waitCounter = 0; for (Int32 j = 0; j < tris.Length; j += 6) { waitCounter++; if (waitCounter > 50) { waitCounter = 0; yield return(WAIT_FOR_END_OF_FRAME); } Vector3 quadStart = vertices[tris[j]]; Int32 nearestBoneIndexStart = 0; Single minBoneDistStart = -1f; for (Int32 k = 0; k < possibleBones.Length; k++) { Vector3 bonePos = possibleBones[k].position; Single distStart = (quadStart - bonePos).magnitude; distStart += Mathf.Abs(quadStart.y - bonePos.y); if (minBoneDistStart == -1f || distStart < minBoneDistStart) { nearestBoneIndexStart = possibleBonesIndecies[k]; minBoneDistStart = distStart; } } Vector3 bonePosStart = bones[nearestBoneIndexStart].position; quadStart = bonePosStart * BONE_OFFSET + quadStart * (1f - BONE_OFFSET); Vector3 distBone = bonePosStart - quadStart; Vector3 move = Vector3.zero; if (Mathf.Abs(distBone.x) > p_maxBoneAxisOffset) { move.x = Mathf.Sign(distBone.x) * (Mathf.Abs(distBone.x) - p_maxBoneAxisOffset); quadStart.x += move.x; distBone = bonePosStart - quadStart; } if (Mathf.Abs(distBone.z) > p_maxBoneAxisOffset) { move.z = Mathf.Sign(distBone.z) * (Mathf.Abs(distBone.z) - p_maxBoneAxisOffset); quadStart.z += move.z; } vertices[tris[j + 1]] += quadStart - vertices[tris[j]]; vertices[tris[j]] = quadStart; } p_mesh.vertices = vertices; yield break; }
/// <summary> /// Sends the finished events to all registered event handlers. /// </summary> /// <param name="dataStream">The data stream that shall be passed to all event handlers.</param> public void SendFinishedEvent(MemoryStream dataStream) { OnFinished?.Invoke(this, Info, dataStream); }
IEnumerator DownloadAB(string name, OnFinished onFinished) { string url = PathUtils.GetAssetBundlesPathURL () + PathUtils.GetExportedName (name); yield return StartCoroutine (AssetBundleManager.downloadAssetBundle (url, 1)); AssetBundle bundle = AssetBundleManager.getAssetBundle (url, 1); TryToAddAsset (name, bundle.mainAsset); onFinished (bundle.mainAsset); }
/// <summary> /// Create a web request for the following URL. /// </summary> static public void Create (string url, OnFinished callback) { Create(url, callback, null); }
/// <summary> /// 压缩多层目录 /// </summary> /// <param name="directory">文件夹目录</param> /// <param name="saveFolder">压缩后的文件</param> public static void ZipFileDirectory(string directory, string zipedFile, IList filters = null, OnFinished onFinished = null) { using (FileStream ZipFile = File.Create(zipedFile)) { using (ZipOutputStream zipStream = new ZipOutputStream(ZipFile)) { ZipSetp(directory, zipStream, "", filters); } } }
private void ImporterRun(Object Status) { Thread.CurrentThread.Priority = ThreadPriority.BelowNormal; if (Monitor.TryEnter(ImporterRunLock)) { #region Debug info #if DEBUG DebugX.LogT("WWCP importer '" + Id + "' started!"); var StartTime = DateTime.UtcNow; #endif #endregion try { #region Remove ForwardingInfos older than 7 days... //var Now = DateTime.UtcNow; //var ToRemove = _AllForwardingInfos. // Where (ForwardingInfo => ForwardingInfo.Value.LastTimeSeen + TimeSpan.FromDays(7) < Now). // Select(ForwardingInfo => ForwardingInfo.Key). // ToList(); //ToRemove.ForEach(ForwardingInfo => _AllForwardingInfos.Remove(ForwardingInfo)); #endregion GetData(DateTime.UtcNow, this, DateTime.UtcNow, _LastRunId++, DNSClient). ContinueWith(ImporterTask => { // Check for null... if (!EqualityComparer <T> .Default.Equals(ImporterTask.Result, default(T))) { //ToDo: Handle XML parser exceptions... AddOrUpdateForwardingInfos(CreateForwardingTable(this, ImporterTask.Result, AllChargingStationOperators, GetChargingStationOperators, GetDefaultChargingStationOperator)); } return(ImporterTask.Result); }). ContinueWith(ImporterTask => { // Check for null... if (!EqualityComparer <T> .Default.Equals(ImporterTask.Result, default(T))) { //if (_ImportedData.Count >= MaxNumberOfCachedDataImports) //{ // var succ = _ImportedData.Remove(_ImportedData[0]); // DebugX.LogT("Importer Count = " + _ImportedData.Count + " " + succ); //} //// Save the imported data for later review... //_ImportedData.Add(new Timestamped<T>(ImporterTask.Result)); // Update ForwardingInfos OnEveryRun?.Invoke(this, ImporterTask); } }). Wait(); #region Debug info #if DEBUG OnFinished?.Invoke(DateTime.UtcNow, this, "WWCP importer '" + Id + "' finished after " + (DateTime.UtcNow - StartTime).TotalSeconds + " seconds!"); #endif #endregion } catch (Exception e) { while (e.InnerException != null) { e = e.InnerException; } DebugX.LogT("WWCP importer '" + Id + "' led to an exception: " + e.Message + Environment.NewLine + e.StackTrace); } finally { Monitor.Exit(ImporterRunLock); } } else { DebugX.LogT("WWCP importer '" + Id + "' skipped!"); } }
public static void UnZip(byte[] bytes, string directory, string password = "", bool overWrite = true, OnFinished onFinished = null) { UnZip(new MemoryStream(bytes), directory, overWrite); }
private IEnumerator DelayEnd() { yield return(new WaitForSeconds(_time)); OnFinished?.Invoke(this); }
public void Stop() { StopAllCoroutines(); _actionSequence.Clear(); OnFinished?.Invoke(this); }
void Update() { if (paused) { return; } var delta = Time.deltaTime; var time = Time.time; if (!started) { started = true; startTime = time + startDelay; } if (time < startTime) { return; } factor += AmountPerDelta * delta; switch (tweenStyle) { case Style.Loop: if (factor > 1f) { factor -= Mathf.Floor(factor); elapsedСycle++; } break; case Style.PingPong: if (factor > 1f) { factor = 1f - (factor - Mathf.Floor(factor)); amountPerDelta = -AmountPerDelta; elapsedСycle++; break; } if (factor < 0f) { factor = -factor; factor -= Mathf.Floor(factor); amountPerDelta = -AmountPerDelta; elapsedСycle++; break; } break; } var isDone = (tweenDuration == 0f) || (tweenStyle.Equals(Style.Once) && ((factor > 1f) || (factor < 0f))) || (!tweenStyle.Equals(Style.Once) && ((cycleCount > 0) && (elapsedСycle >= cycleCount))); if (isDone) { elapsedСycle = 0; if ((factor < 1f) && (factor > 0f)) { factor = Mathf.Round(factor); } else { factor = Mathf.Clamp01(factor); } enabled = started = paused = false; } Sample(factor, isDone); if (isDone) { OnFinished.SafeInvoke(this); } }
internal void RaiseOnFinished() { OnFinished?.Invoke(this); }
public override void OnPopped() { OnFinished.Invoke(success, exception); base.OnPopped(); }
internal void Finished() { OnFinished?.Invoke(this); OnFinished = null; }
public static void InvokeOnFinished(FinishedArgs args) { OnFinished?.Invoke(null, args); }
public void Finish() { OnFinished?.Invoke(CurrentTime); }
public void RaiseOnFinished() { isOn = false; OnFinished?.Invoke(dclAction); }
/// <summary> /// Create a web request for the following URL. /// </summary> static public void Create(string url, OnFinished callback) { Create(url, callback, null); }
public void SetCountDownEndTime(float end, string prefix = "", string suffix = "", bool formated = true, OnStarted onStarted = null, OnFinished onFinished = null) { endTime = end; m_OnStarted = onStarted; m_OnFinished = onFinished; m_Prefix = prefix; m_Suffix = suffix; m_Formated = formated; Singleton._DelayUtil.CancelDelayCall(m_DelayCall); if (m_Label != null && enabled) { CountDown();//call it once immediately } m_DelayCall = Singleton._DelayUtil.DelayCall(1.0f, CountDown, true); }
protected void NotifyPhaseFinished() { OnFinished?.Invoke(); }
private void Finish() { Log.Info($"{Job.Name} finished"); OnFinished?.Invoke(this); }
/// <summary> /// Invokes OnFinished event. /// </summary> private void InvokeFinished() { OnFinished?.Invoke(); }
public void ldaBegin(int index, MeteorUnit target, Vector3 initpos, GameObject dropthing, OnFinished onFinished) { //debug 调速 _fly_rotation_speed = 2; _center_object = target.gameObject; if (_center_round_its_init_pos) { _center_pos = transform.localPosition; } if (_center_object != null) { _center_pos = _center_object.transform.position; } _raiseing_its_y_time = _raise_its_y_time; _going_center_time = _go_center_time; _cur_radius_length = _radius_length; ObjectXZFaceToTarget(this.gameObject, _center_object); //_arrived_effect = GameObject.Instantiate(Resources.Load(_arrived_effect_name), Vector3.zero, Quaternion.identity) as GameObject; //_arrived_effect.transform.parent = this.transform; //_arrived_effect.transform.localPosition = Vector3.zero; //_arrived_effect.transform.localRotation = Quaternion.identity; //_arrived_effect.transform.localScale = Vector3.one; //if (_arrived_effect != null) // _arrived_effect.SetActive(false); //_toptip_effect = GameObject.Instantiate(Resources.Load(_toptip_effect_name), Vector3.zero, Quaternion.identity) as GameObject; //_toptip_effect.transform.parent = this.transform; //_toptip_effect.transform.localPosition = Vector3.zero; //_toptip_effect.transform.localRotation = Quaternion.identity; //_toptip_effect.transform.localScale = Vector3.one; //if (_toptip_effect != null) // _toptip_effect.SetActive(false); mTarget = target; DropThing = dropthing; transform.position = initpos; //_center_object = target; mOnFinished = onFinished; _flying_to_target_time = _fly_to_target_time; //随机一个时间物品飞行时长不一 //float rvalue = Random.value * 2; //if (Random.Range(0, 10) > 5) // _flying_to_target_time += rvalue; //else // _flying_to_target_time -= rvalue; //随机一个时间物品分开起飞 //rvalue = Random.value * 5; Invoke("FlyStart", index * 0.2f); }
public bool Finish() { OnFinished?.Invoke(); UnityEngine.Object.Destroy(GetPlacementGraphic()); return(true); }
/// <summary> /// Invokes OnFinished event. /// </summary> protected void InvokeFinished() { OnFinished?.Invoke(); }
public void SetState(State state) { switch (state) { case State.Start: ShowObjectsOnly(startObj); username.text = password.text = email.text = passwordRepeat.text = ""; termsConsent.isOn = emailConsent.isOn = askAgain.isOn = false; skipButton.image.sprite = greyButtonSprite; backButton.interactable = false; if (_state == State.GDPR) { errorText.gameObject.SetActive(true); errorText.text = "Account deleted!"; } break; case State.Register: ShowObjectsOnly(idObj); forgotGoto.gameObject.SetActive(false); email.gameObject.SetActive(true); loginSubmit.interactable = false; loginText.gameObject.SetActive(false); registerText.gameObject.SetActive(true); passwordRepeat.gameObject.SetActive(true); break; case State.Login: ShowObjectsOnly(idObj); email.gameObject.SetActive(false); loginText.gameObject.SetActive(true); registerText.gameObject.SetActive(false); passwordRepeat.gameObject.SetActive(false); break; case State.GDPR: ShowObjectsOnly(gdprObj); skipButton.interactable = false; backButton.interactable = false; emailConsent.gameObject.SetActive(email.text != ""); navObj.SetActive(false); break; case State.Reset: ShowObjectsOnly(resetObj); skipButton.interactable = false; break; case State.Demographics: ShowObjectsOnly(demoObj); backButton.interactable = false; break; case State.Skip: if (_state == State.Skip || _state == State.Demographics) { if (askAgain.isOn) { GameManager.Instance.DontAskAgainForLogin(); } SetState(State.End); } else { ShowObjectsOnly(skipObj); skipButton.image.sprite = redButtonSprite; } break; case State.End: OnFinished?.Invoke(); StartCoroutine(TweenY(1, transform.localPosition.y, -1000, false)); break; } _state = state; }
private void Finished(TaskResult result, String message, params object[] args) { log.WriteToLog(LogMsgType.Debug, "{0} tasks finished", startNumOfTasks); OnFinished?.Invoke(this, new FinishedArgs(String.Format(message, args), result)); }