コード例 #1
0
 public void ParseMovements(XmlNodeList xmlNodes)
 {
     for (int i = 0; i < xmlNodes.Count; i++)
     {
         PPMovementInfo movementInfo = new PPMovementInfo();
         movementInfo.Parse(xmlNodes[i]);
         movements.Add(movementInfo);
     }
 }
コード例 #2
0
        protected void ProcessSpline(PPMovementInfo movement, float speed, bool withAnim = true)
        {
            if (!withAnim)
            {
                mTarget.GetComponentInChildren <IPBSplineAnimator>().SetKeyframe(movement.destKeyframe);
                return;
            }

            IPBSplineAnimator animator = mTarget.GetComponentInChildren <IPBSplineAnimator>();

            animSequence = animator.Play(movement.destKeyframe, speed, null);
        }
コード例 #3
0
        protected void ProcessNormal(PPMovementInfo movement, float speed, bool withAnim = true)
        {
            if (!withAnim)
            {
                mTarget.transform.localPosition    = movement.destPosition;
                mTarget.transform.localEulerAngles = movement.destAngle;
                return;
            }

            animSequence = DOTween.Sequence();
            animSequence.Append(mTarget.transform.DOLocalMove(movement.destPosition, speed).SetEase(Ease.OutCubic))
            .Join(mTarget.transform.DOLocalRotate(movement.destAngle, speed));
        }
コード例 #4
0
        /// <summary>
        /// fully play
        /// </summary>
        public virtual IEnumerator Play()
        {
            int moveIndex = 0;

            mStopped = false;
            bool completeSequence;

            while (moveIndex < mInfo.movements.Count)
            {
                PPMovementInfo movement = mInfo.movements[moveIndex];

                //相机跟随
                if (PBCamManager.Instance.IsCameraFollow)
                {
                    if (moveIndex == 0)
                    {
                        if (mInfo.targetId != 0)
                        {
                            if (IsUnit)
                            {
                                MoveCamera();
                                yield return(new WaitForSeconds(0.5f * mBlockMoveSpeed));
                            }
                            else
                            {
                                PBCamManager.Instance.MoveToShowAllInPlay();
                            }
                        }
                    }
                }

                if (mStopped)
                {
                    yield break;
                }

                //零件动画
                completeSequence = false;
                switch (movement.type)
                {
                case PPMovementType.Normal:
                    ProcessNormal(movement, mBlockMoveSpeed * movement.duration);
                    break;

                case PPMovementType.Spline:
                    ProcessSpline(movement, mBlockMoveSpeed * movement.duration);
                    break;
                }
                animSequence.OnComplete(() => completeSequence = true);
                if (!animSequence.IsPlaying())
                {
                    animSequence.Play();//ensure to play, because DoTween.defaultAutoplay are not certain.
                }
                while (!completeSequence && !mStopped)
                {
                    yield return(null);
                }

                if (mStopped)
                {
                    yield break;
                }

                moveIndex++;
            }

            mIsComplete = true;
            OnComplete.Invoke(this);
        }