Пример #1
0
 /// <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();
     }));
 }
Пример #2
0
        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();
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        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();
        }
Пример #5
0
 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);
 }
Пример #6
0
 public void setFinishDelegate(OnFinishDelegate finishDelegate)
 {
     this.finishDelegate = finishDelegate;
 }
Пример #7
0
 public static void Execute(OnFinishDelegate _onFinish)
 {
     execute(_onFinish);
 }
Пример #8
0
        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();
            }
        }
Пример #9
0
 public static void Move(Vector3 _position, Vector3 _rotation, float _duration, OnFinishDelegate _onFinis)
 {
     CoroutineMgr.Start(move(_position, _rotation, _duration, _onFinis));
 }
Пример #10
0
 public static void Shake(float _duration, OnFinishDelegate _onFinish)
 {
     CoroutineMgr.Start(ShakeCamera(_duration, _onFinish));
 }
Пример #11
0
    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();
        }
    }