Exemple #1
0
    private void StartFLPunch(GhostController caughtGhost)
    {
        _fflAvailable    = false;
        FFLTarget.parent = null;
        float   distToGrabBottom = Vector3.Distance(FFLRaycastOrigin.position, caughtGhost.GrabPointBottom.position);
        float   distToGrabTop    = Vector3.Distance(FFLRaycastOrigin.position, caughtGhost.GrabPointTop.position);
        Vector3 position         = (distToGrabBottom < distToGrabTop) ? caughtGhost.GrabPointBottom.position : caughtGhost.GrabPointTop.position;

        position = new Vector3(position.x, position.y, -3.0f);
        if (_fflTweener != null && _fflTweener.IsPlaying())
        {
            _fflTweener.Kill();
        }

        _fflTweener = FFLTarget.DOMove(position, 0.15f).SetEase(Ease.InBack).OnStart(() =>
        {
            if (distToGrabBottom < distToGrabTop)
            {
                FFLTarget.DORotate(caughtGhost.GrabPointBottom.eulerAngles, 0.15f);
            }
            else
            {
                FFLTarget.DORotate(caughtGhost.GrabPointTop.eulerAngles, 0.15f);
            }
        }).OnComplete(() => {
            FFLTarget.SetParent(Bug.transform, true);
            caughtGhost.Caught();
            caughtGhost.PlayerPiece1.GetComponent <Rigidbody>().AddExplosionForce(20.0f, FFLTarget.transform.position, 10.0f);
            caughtGhost.PlayerPiece2.GetComponent <Rigidbody>().AddExplosionForce(20.0f, FFLTarget.transform.position, 10.0f);
            _fflAvailable = true;
            if (_punchQueue.Count == 0 && _eatQueue.Count == 0)
            {
                FFLTarget.DOLocalMove(_fflTargetOGPosition, 0.15f);
                FFLTarget.DOLocalRotate(_fflTargetOGRotation, 0.15f);
            }
        });
    }