예제 #1
0
파일: Weapon.cs 프로젝트: ze0nni/OneRogue
    IEnumerator HitPaseTask(WeaponHitTaskPhase phase, WeaponHitTask msg, float waitMs, float min, float max)
    {
        var wait  = waitMs / 1000f;
        var range = max - min;

        SendMessage("OnWeaponHitTask", msg, SendMessageOptions.DontRequireReceiver);
        yield return(new WaitForEndOfFrame());

        wait -= Time.deltaTime;
        while (wait > 0)
        {
            msg.update(
                min + (1f - (wait / waitMs * 1000f)) * range,
                phase
                );

            SendMessage("OnWeaponHitTask", msg, SendMessageOptions.DontRequireReceiver);
            yield return(new WaitForEndOfFrame());

            wait -= Time.deltaTime;
        }

        msg.update(
            max,
            phase
            );

        SendMessage("OnWeaponHitTask", msg, SendMessageOptions.DontRequireReceiver);
    }
예제 #2
0
파일: Weapon.cs 프로젝트: ze0nni/OneRogue
    IEnumerator HitTask(WeaponData currentWeapon)
    {
        isHitTaskInProgress = true;

        var wait = currentWeapon.Prepare / 1000f;

        var msg = new WeaponHitTask(currentWeapon);

        #region Prepare
        while (wait > 0 && isTriggered)
        {
            msg.update(1f - (wait / currentWeapon.Prepare * 1000f), WeaponHitTaskPhase.Prepare);

            SendMessage("OnWeaponHitTask", msg, SendMessageOptions.DontRequireReceiver);
            yield return(new WaitForEndOfFrame());

            wait -= Time.deltaTime;
        }
        #endregion

        yield return(new WaitWhile(() => isTriggered));

        yield return(HitPaseTask(
                         WeaponHitTaskPhase.Hit, msg, currentWeapon.Release,
                         //If player not prepare
                         1 - (1 - msg.ratio),
                         2));

        ApplyHit(currentWeapon);

        SendMessage("OnWeaponHit", currentWeapon, SendMessageOptions.DontRequireReceiver);

        yield return(HitPaseTask(WeaponHitTaskPhase.Reload, msg, currentWeapon.Reload, 2, 3));

        isHitTaskInProgress = false;
    }