예제 #1
0
 private void Start()
 {
     _trigger = GetComponent <IBSpriteTrigger>();
     _trigger.onDetectCharacterEnter = OnCharacterEnter;
     _trigger.onDetectCharacterExit  = OnCharacterExit;
     _trigger.Enable();
 }
예제 #2
0
 public virtual void Fire(Vector3 velocity)
 {
     this.velocity           = velocity;
     _fired                  = true;
     _startTime              = Time.time;
     _trailRenderer.emitting = true;
     _ibSpriteTrigger.Enable();
 }
    protected IEnumerator ExeAttackCoroutine()
    {
        _isFollowing = false;
        _isAttacking = true;
        ResetPositionAndRotation();
        EnableTrail(attackTrailSettings);
        EnterCharacterSyncState();
        while (_commandBufferCount > 0)
        {
            _ibSpriteTrigger.Enable();
            if (attackSound)
            {
                _audioSource.PlayOneShot(attackSound.Source);
            }
            float timeStart = Time.time;
            float timeDiff;
            float lerp;
            do
            {
                yield return(null);

                timeDiff           = Time.time - timeStart;
                lerp               = timeDiff / thrustDuration;
                transform.position = Vector3.Lerp(InitialPosition, ThrustPosition, lerp);
            } while (timeDiff < thrustDuration);

            if (thrustBackMode == ThrustBackMode.Immediate)
            {
                yield return(null);

                ResetPositionAndRotation();
            }
            else
            {
                timeStart = Time.time;
                do
                {
                    yield return(null);

                    timeDiff           = Time.time - timeStart;
                    lerp               = timeDiff / thrustDuration;
                    transform.position = Vector3.Lerp(ThrustPosition, InitialPosition, lerp);
                } while (timeDiff < thrustDuration);
                ResetPositionAndRotation();
            }

            _ibSpriteTrigger.Disable();
            _commandBufferCount--;
        }
        _isCommandBufferFull = false;
        ExitCharacterSyncState();
        DisableTrail();
        _attackCoroutine = null;
        _isAttacking     = false;

        characterController.StartStaminaRecovery();
    }