/// <summary> /// /// </summary> /// <param name="_duration"></param> /// <param name="_mode"> /// 0 : FadeIn /// 1 : FadeOut /// </param> public static void FadeMask(float _duration, int _mode, OnFinishDelegate _onFinish) { CoroutineMgr.Start(Fade_Mask(_duration, _mode, () => { _onFinish(); })); }
private static IEnumerator Fade_Mask(float _duration, int _mode, OnFinishDelegate _onFinish) { mask_.type = Image.Type.Simple; yield return(new WaitForEndOfFrame()); float time = 0; while (true) { yield return(new WaitForEndOfFrame()); time += Time.deltaTime; float amount = time / _duration; float alpha = Mathf.Abs(_mode - amount); Color color = mask_.color; color.a = alpha; mask_.color = color; if (time > _duration) { break; } } if (time > _duration) { _onFinish(); } }
private static void execute(OnFinishDelegate _onFinish) { if (tasks.Count == 0) { if (null != _onFinish) { _onFinish(); } return; } Task task = tasks.Dequeue(); if (Task.TYPE_BUNDLE == task.type) { resOp = ResBundle.AsyncLoadBundle(task.bundle, (_ab) => { task.onBundleFinish(_ab); execute(_onFinish); }); } else if (Task.TYPE_RES == task.type) { resOp = ResBundle.AsyncLoadRes <Object> (task.bundle, task.res, (_asset) => { task.onResFinish(_asset); execute(_onFinish); }); } else if (Task.TYPE_INVOKE == task.type) { task.invoke(); execute(_onFinish); } }
private static IEnumerator ShakeCamera(float _duration, OnFinishDelegate _onFinish) { Quaternion rot = camera_.GetComponent <Transform>().rotation; float shakelevel = 2f; yield return(new WaitForEndOfFrame()); float time = 0; while (time < _duration) { yield return(new WaitForEndOfFrame()); time += Time.deltaTime; Vector3 vet = rot.eulerAngles + Random.insideUnitSphere * shakelevel; camera_.GetComponent <Transform>().rotation = Quaternion.Euler(vet); } camera_.GetComponent <Transform>().rotation = rot; //Transform c = camera_.GetComponent<Transform>(); //Vector3 originPosition = c.position; //Quaternion originRotation = c.rotation; //float x = c.position.x; //float y = c.position.y; //float z = c.position.z; //float _x = c.rotation.x; //float _y = c.rotation.y; //float _z = c.rotation.z; //float _w = c.rotation.w; //float shake_intensity = 0.2f; //float shake_decay = 0.0006f; //yield return new WaitForEndOfFrame(); //float time = 0; //while (time < _duration) //{ // yield return new WaitForEndOfFrame(); // time += Time.deltaTime; // c.position = originPosition + Random.insideUnitSphere * shake_intensity; // c.rotation = new Quaternion( // originRotation.x + Random.Range(-shake_intensity, shake_intensity) * 0.2f, // originRotation.y + Random.Range(-shake_intensity, shake_intensity) * 0.2f, // originRotation.z + Random.Range(-shake_intensity, shake_intensity) * 0.2f, // originRotation.w + Random.Range(-shake_intensity, shake_intensity) * 0.2f); // shake_intensity -= shake_decay; //} //camera_.position = new Vector3(x, y, z); //camera_.rotation = new Quaternion(_x, _y, _z, _w); //_onFinish(); }
public Timer(int counter, OnFinishDelegate onFinish, UpdateDelegate update = null) { _counter = counter; OnFinish = onFinish; if (update != null) { Update = update; } else { Update = DefaultUpdate; } _id = GameManager.instance.GetNewTimerId(); GameManager.instance.TimerList.Add(_id, this); }
public void setFinishDelegate(OnFinishDelegate finishDelegate) { this.finishDelegate = finishDelegate; }
public static void Execute(OnFinishDelegate _onFinish) { execute(_onFinish); }
private static IEnumerator move(Vector3 _position, Vector3 _rotation, float _duration, OnFinishDelegate _onFinish) { Vector3 camerapos = camera_.position; Quaternion camerarot = camera_.rotation; float timer = 0f; while (timer < _duration) { camera_.position = Vector3.Lerp(camerapos, _position, timer / _duration); camera_.rotation = Quaternion.Lerp(camerarot, Quaternion.Euler(_rotation), timer / _duration); //TODO Use Lerp // camera_.LookAt(_position); yield return(new WaitForEndOfFrame()); timer += Time.deltaTime; } if (null != _onFinish) { _onFinish(); } }
public static void Move(Vector3 _position, Vector3 _rotation, float _duration, OnFinishDelegate _onFinis) { CoroutineMgr.Start(move(_position, _rotation, _duration, _onFinis)); }
public static void Shake(float _duration, OnFinishDelegate _onFinish) { CoroutineMgr.Start(ShakeCamera(_duration, _onFinish)); }
protected IEnumerator PlayAttackAnimation(string trigger, string animation, Animator animator, GameObject instWeapon, OnFinishDelegate OnFinish = null) { animationLocked = true; animator.SetTrigger(trigger); //turn on hitbox HitBox hitBox = instWeapon.GetComponentInChildren <HitBox>(); Debug.Log("got to hitbox"); hitBox.onTriggerActivatedCallback += HitTarget; while (animator.GetCurrentAnimatorStateInfo(0).fullPathHash != Animator.StringToHash("Base Layer." + animation)) { yield return(null); } float counter = 0; float waitTime = animator.GetCurrentAnimatorStateInfo(0).length; while (counter < (waitTime)) { counter += Time.deltaTime; yield return(null); } animationLocked = false; if (OnFinish != null) { OnFinish.Invoke(); } }