Пример #1
0
    private void WallSplat(WallSplatForce _force, Vector3 _normalDirection)
    {
        if (currentPawnState != null && currentPawnState.name == "WallSplatted")
        {
            return;
        }
        Vector3 i_normalDirectionNormalized = _normalDirection.normalized;

        if (Mathf.Abs(i_normalDirectionNormalized.y) > (Mathf.Abs(i_normalDirectionNormalized.x) + Mathf.Abs(i_normalDirectionNormalized.z)))
        {
            Debug.Log("Tried wallsplat on ground: Return"); return;
        }
        ChangePawnState("WallSplatted", WallSplat_C(_force, _normalDirection), CancelWallSplat_C());
    }
Пример #2
0
    private IEnumerator WallSplat_C(WallSplatForce _force, Vector3 _normalDirection)
    {
        animator.SetTrigger("FallingTrigger");
        moveState = MoveState.Pushed;
        if (isPlayer)
        {
            FeedbackManager.SendFeedback("event.PlayerWallSplatHit", this);
        }
        else
        {
            FeedbackManager.SendFeedback("event.EnemyWallSplatHit", this);
        }
        if (_normalDirection != Vector3.zero)
        {
            transform.forward = _normalDirection;
        }
        Vector3 i_initialPosition = transform.position;
        float   i_damages         = pushDatas.wallSplatDamages;

        if (isPlayer)
        {
            i_damages = pushDatas.wallSplatPlayerDamages;
        }
        Damage(i_damages);
        switch (_force)
        {
        case WallSplatForce.Light:
            animator.SetTrigger("WallSplatTrigger");
            animator.SetTrigger("StandingUpTrigger");
            float i_wallSplatLightRecoverTime = pushDatas.wallSplatLightRecoverTime + Random.Range(pushDatas.randomWallSplatLightRecoverTimeAddition.x, pushDatas.randomWallSplatLightRecoverTimeAddition.y);
            if (isPlayer)
            {
                i_wallSplatLightRecoverTime = pushDatas.wallSplatPlayerLightRecoverTime;
            }
            yield return(new WaitForSeconds(i_wallSplatLightRecoverTime));

            break;

        case WallSplatForce.Heavy:
            animator.SetTrigger("WallSplatTrigger");
            float          i_wallSplatForward          = pushDatas.wallSplatHeavyForwardPush;
            float          i_wallSplatFallSpeed        = pushDatas.wallSplatHeavyFallSpeed;
            float          i_wallSplatHeavyRecoverTime = pushDatas.wallSplatHeavyRecoverTime + Random.Range(pushDatas.randomWallSplatHeavyRecoverTimeAddition.x, pushDatas.randomWallSplatHeavyRecoverTimeAddition.y);
            AnimationCurve i_wallSplatSpeedCurve       = pushDatas.wallSplatHeavySpeedCurve;
            AnimationCurve i_wallSplatHeightCurve      = pushDatas.wallSplatHeavyHeightCurve;
            if (isPlayer)
            {
                i_wallSplatForward          = pushDatas.wallSplatPlayerHeavyForwardPush;
                i_wallSplatFallSpeed        = pushDatas.wallSplatPlayerHeavyFallSpeed;
                i_wallSplatHeavyRecoverTime = pushDatas.wallSplatPlayerHeavyRecoverTime;
                i_wallSplatSpeedCurve       = pushDatas.wallSplatPlayerHeavySpeedCurve;
                i_wallSplatHeightCurve      = pushDatas.wallSplatPlayerHeavyHeightCurve;
            }
            Vector3    i_endPosition = transform.position + (_normalDirection * i_wallSplatForward);
            RaycastHit i_hit;
            if (Physics.Raycast(i_endPosition, Vector3.down, out i_hit, 1000, LayerMask.GetMask("Environment")))
            {
                i_endPosition = i_hit.point;
            }
            for (float i = 0; i < 1f; i += Time.deltaTime * i_wallSplatFallSpeed)
            {
                moveState = MoveState.Pushed;
                Vector3 i_newPosition = Vector3.Lerp(i_initialPosition, i_endPosition, i_wallSplatSpeedCurve.Evaluate(i / 1f));
                i_newPosition.y    = Mathf.Lerp(i_initialPosition.y, i_endPosition.y, 1f - i_wallSplatHeightCurve.Evaluate(i / 1f));
                transform.position = i_newPosition;
                yield return(null);
            }
            transform.position = i_endPosition;
            animator.SetTrigger("StandingUpTrigger");
            moveState = MoveState.Idle;
            yield return(new WaitForSeconds(i_wallSplatHeavyRecoverTime));

            break;
        }
        moveState = MoveState.Idle;
        animator.ResetTrigger("FallingTrigger");
        animator.ResetTrigger("StandingUpTrigger");
        yield return(null);
    }