Ejemplo n.º 1
0
        private IEnumerator TestRoutine()
        {
            startPos = base.transform.position;
            startRot = base.transform.rotation;
            RunController.ControllerBehaviour behaviourRun = controller.Behaviour;
            behaviourRun.Style = PlayerLocoStyle.Style.Run;
            RunController.ControllerBehaviour behaviourWalk = controller.Behaviour;
            behaviourWalk.Style = PlayerLocoStyle.Style.Walk;
            while (true)
            {
                controller.Behaviour.SetStyle(PlayerLocoStyle.Style.Run);
                controller.Steer(Vector2.up);
                yield return(new WaitForSeconds(RunTime));

                controller.DoAction(LocomotionController.LocomotionAction.Jump);
                yield return(new WaitForSeconds(JumpTime));

                controller.DoAction(LocomotionController.LocomotionAction.Jump);
                yield return(new WaitForSeconds(Jump2Time));

                controller.Behaviour.SetStyle(PlayerLocoStyle.Style.Walk);
                yield return(new WaitForSeconds(WalkTime));

                controller.DoAction(LocomotionController.LocomotionAction.Jump);
                yield return(new WaitForSeconds(Jump3Time));

                controller.Steer(Vector2.zero);
                yield return(new WaitForSeconds(StopTime));

                base.transform.position = startPos;
                base.transform.rotation = startRot;
            }
        }
Ejemplo n.º 2
0
        private IEnumerator TestRoutine()
        {
            startPos = base.transform.position;
            startRot = base.transform.rotation;
            Vector2 downleft  = (Vector2.down + Vector2.left).normalized;
            Vector2 downright = (Vector2.down + Vector2.right).normalized;

            while (true)
            {
                controller.Steer(Vector2.up);
                yield return(new WaitForSeconds(MoveTime));

                controller.Steer(downleft);
                yield return(new WaitForSeconds(MoveTime));

                controller.Steer(Vector2.up);
                yield return(new WaitForSeconds(MoveTime));

                controller.Steer(downright);
                yield return(new WaitForSeconds(MoveTime));

                controller.Steer(Vector2.zero);
                yield return(new WaitForSeconds(StopTime));

                base.transform.position = startPos;
                base.transform.rotation = startRot;
            }
        }
Ejemplo n.º 3
0
        public void MoveToTarget(Transform target, float distanceThreshold = 0.15f, PlayerLocoStyle.Style locomotionStyle = PlayerLocoStyle.Style.Walk, float timeoutTime = 15f, bool autoDestroy = true)
        {
            targetDestination = target;
            actorRadius       = 0f;
            actorHalfHeight   = 0.1f;
            this.timeoutTime  = timeoutTime;
            this.autoDestroy  = autoDestroy;
            CharacterController component = GetComponent <CharacterController>();

            if (component != null)
            {
                actorRadius     = component.radius;
                actorHalfHeight = component.height / 2f;
            }
            LocomotionTracker component2 = GetComponent <LocomotionTracker>();

            if (component2.SetCurrentController <RunController>())
            {
                runController = GetComponent <RunController>();
                if (!runControllerBehaviourWasSet)
                {
                    oldRunBehaviour         = runController.Behaviour;
                    runController.Behaviour = new RunController.ControllerBehaviour
                    {
                        IgnoreCollisions   = false,
                        IgnoreGravity      = false,
                        IgnoreRotation     = false,
                        IgnoreTranslation  = false,
                        IgnoreJumpRequests = true,
                        IgnoreStickInput   = true,
                        Style = locomotionStyle
                    };
                    runControllerBehaviourWasSet = true;
                }
                runController.ResetMomentum();
                dest = targetDestination.transform.position;
                Vector3 vector = dest - base.transform.position;
                if (vector == Vector3.zero)
                {
                    vector = base.transform.forward;
                }
                distThresholdSq = distanceThreshold * distanceThreshold;
                vector.y        = 0f;
                elapsedTime     = 0f;
                done            = false;
            }
            if (!CanReachWaypoint())
            {
                if (this.OnComplete != null)
                {
                    this.OnComplete();
                }
                runController.Steer(Vector3.zero);
                runController.SnapToPosition(dest);
                runController.SnapToFacing(targetDestination.transform.forward);
                if (autoDestroy)
                {
                    UnityEngine.Object.Destroy(this);
                }
            }
        }
Ejemplo n.º 4
0
        public void Update()
        {
            Vector2 steerInput = new Vector2(agent.desiredVelocity.x, agent.desiredVelocity.z);

            runController.Steer(steerInput);
        }