Exemple #1
0
        protected override IEnumerator TraverseSpecial(RichSpecial rs)
        {
            traversingSpecialPath = true;
            velocity = Vector3.zero;

            var al = rs.nodeLink as AnimationLink;

            if (al == null)
            {
                Debug.LogError("Unhandled RichSpecial");
                yield break;
            }

            //Rotate character to face the correct direction
            while (!RotateTowards(rs.first.forward))
            {
                yield return(null);
            }

            //Reposition
            tr.parent.position = tr.position;

            tr.parent.rotation = tr.rotation;
            tr.localPosition   = Vector3.zero;
            tr.localRotation   = Quaternion.identity;

            //Set up animation speeds
            if (rs.reverse && al.reverseAnim)
            {
                anim[al.clip].speed          = -al.animSpeed;
                anim[al.clip].normalizedTime = 1;
                anim.Play(al.clip);
                anim.Sample();
            }
            else
            {
                anim[al.clip].speed = al.animSpeed;
                anim.Rewind(al.clip);
                anim.Play(al.clip);
            }

            //Fix required for animations in reverse direction
            tr.parent.position -= tr.position - tr.parent.position;

            //Wait for the animation to finish
            yield return(new WaitForSeconds(Mathf.Abs(anim[al.clip].length / al.animSpeed)));

            traversingSpecialPath = false;
            NextPart();

            //If a path completed during the time we traversed the special connection, we need to recalculate it
            if (delayUpdatePath)
            {
                delayUpdatePath = false;
                UpdatePath();
            }
        }
Exemple #2
0
        IEnumerator TraverseOffMeshLink(RichSpecial link)
        {
            // Traverse the link over 1 second
            float startTime = Time.time;

            this.pathFinder.canMove = false;
            yield return(new WaitForSeconds(.1f));

            transform.position      = link.second.position;
            this.pathFinder.canMove = true;
        }
        protected virtual IEnumerator TraverseOffMeshLink(RichSpecial rs)
        {
            var link = rs.nodeLink as AnimationLink;

            if (link == null)
            {
                Debug.LogError("Unhandled RichSpecial");
                yield break;
            }

            // Rotate character to face the correct direction
            while (true)
            {
                var origRotation  = ai.rotation;
                var finalRotation = ai.SimulateRotationTowards(rs.first.forward, ai.rotationSpeed * Time.deltaTime);
                // Rotate until the rotation does not change anymore
                if (origRotation == finalRotation)
                {
                    break;
                }
                ai.FinalizeMovement(ai.position, finalRotation);
                yield return(null);
            }

            // Reposition
            transform.parent.position = transform.position;

            transform.parent.rotation = transform.rotation;
            transform.localPosition   = Vector3.zero;
            transform.localRotation   = Quaternion.identity;

            // Set up animation speeds
            if (rs.reverse && link.reverseAnim)
            {
                anim[link.clip].speed          = -link.animSpeed;
                anim[link.clip].normalizedTime = 1;
                anim.Play(link.clip);
                anim.Sample();
            }
            else
            {
                anim[link.clip].speed = link.animSpeed;
                anim.Rewind(link.clip);
                anim.Play(link.clip);
            }

            // Fix required for animations in reverse direction
            transform.parent.position -= transform.position - transform.parent.position;

            // Wait for the animation to finish
            yield return(new WaitForSeconds(Mathf.Abs(anim[link.clip].length / link.animSpeed)));
        }
Exemple #4
0
        protected override IEnumerator TraverseSpecial(RichSpecial rs)
        {
            this.traversingSpecialPath = true;
            this.velocity = Vector3.zero;
            AnimationLink al = rs.nodeLink as AnimationLink;

            if (al == null)
            {
                Debug.LogError("Unhandled RichSpecial");
                yield break;
            }
            while (!this.RotateTowards(rs.first.forward))
            {
                yield return(null);
            }
            this.tr.parent.position = this.tr.position;
            this.tr.parent.rotation = this.tr.rotation;
            this.tr.localPosition   = Vector3.zero;
            this.tr.localRotation   = Quaternion.identity;
            if (rs.reverse && al.reverseAnim)
            {
                this.anim[al.clip].speed          = -al.animSpeed;
                this.anim[al.clip].normalizedTime = 1f;
                this.anim.Play(al.clip);
                this.anim.Sample();
            }
            else
            {
                this.anim[al.clip].speed = al.animSpeed;
                this.anim.Rewind(al.clip);
                this.anim.Play(al.clip);
            }
            this.tr.parent.position -= this.tr.position - this.tr.parent.position;
            yield return(new WaitForSeconds(Mathf.Abs(this.anim[al.clip].length / al.animSpeed)));

            this.traversingSpecialPath = false;
            base.NextPart();
            if (this.delayUpdatePath)
            {
                this.delayUpdatePath = false;
                this.UpdatePath();
            }
            yield break;
            yield break;
        }
        // Token: 0x06002A05 RID: 10757 RVA: 0x001C2AA3 File Offset: 0x001C0CA3
        protected virtual IEnumerator TraverseOffMeshLink(RichSpecial rs)
        {
            AnimationLink link = rs.nodeLink as AnimationLink;

            if (link == null)
            {
                Debug.LogError("Unhandled RichSpecial");
                yield break;
            }
            for (;;)
            {
                Quaternion rotation   = this.ai.rotation;
                Quaternion quaternion = this.ai.SimulateRotationTowards(rs.first.forward, this.ai.rotationSpeed * Time.deltaTime);
                if (rotation == quaternion)
                {
                    break;
                }
                this.ai.FinalizeMovement(this.ai.position, quaternion);
                yield return(null);
            }
            base.transform.parent.position = base.transform.position;
            base.transform.parent.rotation = base.transform.rotation;
            base.transform.localPosition   = Vector3.zero;
            base.transform.localRotation   = Quaternion.identity;
            if (rs.reverse && link.reverseAnim)
            {
                this.anim[link.clip].speed          = -link.animSpeed;
                this.anim[link.clip].normalizedTime = 1f;
                this.anim.Play(link.clip);
                this.anim.Sample();
            }
            else
            {
                this.anim[link.clip].speed = link.animSpeed;
                this.anim.Rewind(link.clip);
                this.anim.Play(link.clip);
            }
            base.transform.parent.position -= base.transform.position - base.transform.parent.position;
            yield return(new WaitForSeconds(Mathf.Abs(this.anim[link.clip].length / link.animSpeed)));

            yield break;
        }