예제 #1
0
        public void PlayWalkAnimation()
        {
            letter.SetState(LLAnimationStates.LL_walking);
            letter.SetWalkingSpeed(LivingLetterController.WALKING_SPEED);

            //livingLetterTransform.localPosition = normalPosition;
        }
예제 #2
0
 private void AnturaReachedLetter()
 {
     m_LetterObjectView.SetState(LLAnimationStates.LL_walking);
     m_LetterObjectView.HasFear = true;
     m_LetterObjectView.SetWalkingSpeed(1);
     game.Context.GetAudioManager().PlaySound(Sfx.LetterFear);
     //m_LetterObjectView.Crouching = true;
 }
예제 #3
0
        /// <summary>
        /// change the position in the current scene
        /// </summary>
        /// <param name="_idxPos"> my new position </param>
        /// <param name="_length"> number of LL </param>
        /// <param name="_duration"> duration of action </param>
        public void ChangePos(int _idxPos, int _length, float _duration)
        {
            mCollider.enabled = false;
            Vector3 newPos = CalculatePos(_idxPos, _length);

            Vector3 dist = (gameObject.transform.position - newPos) / 2;

            Vector3 pivot = gameObject.transform.position - dist;

            //dist is only on x
            float radius = dist.x + 0.1f;

            float accuracy = 4f;

            for (int i = 1; i <= accuracy; ++i)
            {
                Vector3 p = Vector3.zero;
                p   += pivot;
                p.x += Mathf.Cos(3.14f * (i / accuracy)) * radius;
                p.z += Mathf.Sin(3.14f * (i / accuracy)) * radius;

                positions.Add(p);
            }


            PlayAnimation(LLAnimationStates.LL_walking);
            mLetter.SetWalkingSpeed(1);
            mLetter.HasFear = true;

            transform.DOLookAt(positions[0], 1f);

            TweenerCore <Vector3, Path, PathOptions> value = transform.DOPath(positions.ToArray(), _duration, PathType.CatmullRom);

            value.OnWaypointChange(delegate(int wayPoint) {
                if (wayPoint < positions.Count)
                {
                    transform.DOLookAt(positions[wayPoint], 1f);
                }
            });
            value.OnComplete(delegate {
                transform.DOLookAt(transform.position + Vector3.back, 1f);
                positions.Clear();
                PlayAnimation(m_oDefaultIdleAnimation);
                mCollider.enabled = true;
            });
        }
예제 #4
0
        /// <summary>
        /// Move the object from the current position to the final destination withe the setted speed.
        /// </summary>
        /// <param name="v3Destination">The final world position</param>
        private void MoveTo(Vector3 v3Destination)
        {
            Vector3 _v3MaxMovement     = v3Destination - gameObject.transform.position;
            Vector3 _v3PartialMovement = _v3MaxMovement.normalized * m_fMovementSpeed * Time.deltaTime;

            if (_v3PartialMovement.sqrMagnitude >= _v3MaxMovement.sqrMagnitude) //if we reached the destination
            {
                //position on the destination
                //gameObject.transform.position = v3Destination;
                gameObject.transform.Translate(_v3MaxMovement, Space.World);
                m_bMovingToDestination = false;

                //change animation and play sound
                m_oLetter.SetWalkingSpeed(0);
                m_oLetter.SetState(m_eAnimationOnDestReached);
                //AudioManager.I.PlayLetter(m_oLetter.Data.Id);

                if (OnDestinationReached != null) //launch event
                {
                    OnDestinationReached();
                }
            }
            else   //make the progress for this frame
            {
                m_oLetter.SetWalkingSpeed(1);

                m_oLetter.SetState(m_eAnimationOnMoving);
                gameObject.transform.Translate(_v3PartialMovement, Space.World);

                if (_v3MaxMovement.sqrMagnitude == 0)
                {
                    gameObject.transform.rotation = Quaternion.RotateTowards(gameObject.transform.rotation, Quaternion.LookRotation(Vector3.back), m_fRotationSpeed * Time.deltaTime);
                }
                else
                {
                    gameObject.transform.rotation = Quaternion.RotateTowards(gameObject.transform.rotation, Quaternion.LookRotation(_v3MaxMovement), m_fRotationSpeed * Time.deltaTime);
                }

                //gameObject.transform.position += _v3PartialMovement;
                //m_bMovingToDestination = true;
            }
        }
예제 #5
0
        private IEnumerator Walk_Coroutine(WalkParameters parameters)
        {
            isWalking = true;
            var from               = parameters.from;
            var to                 = parameters.to;
            var rotation           = parameters.rotation;
            var duration           = parameters.duration;
            var delay              = parameters.delay;
            var walkAnimation      = parameters.walkAnimation;
            var walkSpeed          = parameters.walkSpeed;
            var afterWalkAnimation = parameters.afterWalkAnimation;
            var afterWalkSpeed     = parameters.afterWalkSpeed;
            var speak              = parameters.speak;
            var rotateAfterWalk    = parameters.rotateAfterWalk;
            var afterWalkRotation  = parameters.afterWalkRotation;

            if (delay > 0)
            {
                yield return(new WaitForSeconds(delay));
            }

            transform.rotation = Quaternion.Euler(rotation);
            //animator.SetTrigger(walkAnimation);
            LLPrefab.SetState(walkAnimation);
            LLPrefab.SetWalkingSpeed(walkSpeed);

            var interpolant  = 0f;
            var lerpProgress = 0f;
            var lerpLength   = duration;

            while (lerpProgress < lerpLength)
            {
                transform.localPosition = Vector3.Lerp(from, to, interpolant);
                lerpProgress           += Time.deltaTime;
                interpolant             = lerpProgress / lerpLength;
                interpolant             = Mathf.Sin(interpolant * Mathf.PI * 0.5f);
                yield return(new WaitForFixedUpdate());
            }

            //animator.SetTrigger(afterWalkAnimation);
            LLPrefab.SetState(afterWalkAnimation);
            LLPrefab.SetWalkingSpeed(afterWalkSpeed);

            if (speak)
            {
                yield return(new WaitForSeconds(0.25f));

                // Dirty Hack to fix an audio synch bug
                while (MakeFriendsGame.Instance.IsIntroducingLetter)
                {
                    yield return(null);
                }

                MakeFriendsGame.Instance.IsIntroducingLetter = true;
                var audioSource = SpeakWord();
                while (!audioSource.IsLoaded)
                {
                    yield return(null);
                }

                while (audioSource.IsPlaying)
                {
                    yield return(null);
                }
                MakeFriendsGame.Instance.IsIntroducingLetter = false;
                yield return(new WaitForSeconds(0.25f));

                MakeFriendsGame.Instance.SpokenWords++;
            }

            if (rotateAfterWalk)
            {
                var initialRotation = transform.rotation.eulerAngles;
                var finalRotation   = afterWalkRotation;

                var rotationInterpolant  = 0f;
                var rotationLerpProgress = 0f;
                var rotationLerpLength   = 0.5f;

                while (rotationLerpProgress < rotationLerpLength)
                {
                    transform.rotation    = Quaternion.Euler(Vector3.Lerp(initialRotation, finalRotation, rotationInterpolant));
                    rotationLerpProgress += Time.deltaTime;
                    rotationInterpolant   = rotationLerpProgress / rotationLerpLength;
                    rotationInterpolant   = Mathf.Sin(rotationInterpolant * Mathf.PI * 0.5f);
                    yield return(new WaitForFixedUpdate());
                }
            }
            isWalking = false;
        }
예제 #6
0
        void Update()
        {
            letter.HasFear = fear;
            letter.SetWalkingSpeed(walkSpeed);
            letter.SetDancingSpeed(danceSpeed);

            if (doTransition)
            {
                doTransition = false;
                letter.SetState(targetState);
            }

            if (doHooray)
            {
                doHooray = false;
                letter.DoHorray();
            }


            if (doAngry)
            {
                doAngry = false;
                letter.DoAngry();
            }


            if (doHighFive)
            {
                doHighFive = false;
                letter.DoHighFive();
            }


            if (onJumpStart)
            {
                onJumpStart = false;
                letter.OnJumpStart();
            }


            if (onJumpMiddle)
            {
                onJumpMiddle = false;
                letter.OnJumpMaximumHeightReached();
            }



            if (onJumpEnd)
            {
                onJumpEnd = false;
                letter.OnJumpEnded();
            }

            if (doSmallJump)
            {
                doSmallJump = false;
                letter.DoSmallJump();
            }

            if (doDanceWin)
            {
                doDanceWin = false;
                letter.DoDancingWin();
            }

            if (doDanceLose)
            {
                doDanceLose = false;
                letter.DoDancingLose();
            }

            if (doTwirl)
            {
                doTwirl = false;
                letter.DoTwirl(() => { Debug.Log("BACK!"); });
            }

            if (doToggleDance)
            {
                doToggleDance = false;
                letter.ToggleDance();
            }
        }
예제 #7
0
 void PlayRunAnimation()
 {
     letterObject.SetState(LLAnimationStates.LL_walking);
     letterObject.SetWalkingSpeed(LivingLetterController.RUN_SPEED);
 }