public void SetTarget(Ray ray, LayerMask layerMask, ILocomotionSystem.TargetRotation rotation,
                       float stopThreshold, UnityAction callback = null)
 {
     this.ChangeLocomotionSystem <LocomotionSystemTarget>();
     ((LocomotionSystemTarget)this.currentLocomotionSystem)
     .SetTarget(ray, layerMask, rotation, stopThreshold, callback);
 }
 public void SetTarget(Vector3 position, ILocomotionSystem.TargetRotation rotation,
                       float stopThreshold, UnityAction callback = null)
 {
     this.ChangeLocomotionSystem <LocomotionSystemTarget>();
     ((LocomotionSystemTarget)this.currentLocomotionSystem)
     .SetTarget(position, rotation, stopThreshold, callback);
 }
        private void GetTarget(Character targetCharacter, GameObject invoker,
                               ref Vector3 cPosition, ref ILocomotionSystem.TargetRotation cRotation, ref float cStopThresh)
        {
            cStopThresh = 0.0f;
            switch (this.moveTo)
            {
            case MOVE_TO.Position: cPosition = this.position; break;

            case MOVE_TO.Transform: cPosition = this.transform.position; break;

            case MOVE_TO.Marker:
                cPosition   = this.marker.transform.position;
                cRotation   = new ILocomotionSystem.TargetRotation(true, this.marker.transform.forward);
                cStopThresh = this.marker.stopThreshold;
                break;

            case MOVE_TO.Variable:
                object valueVariable = this.variable.Get(invoker);
                switch (this.variable.GetVariableDataType())
                {
                case Variable.DataType.GameObject:
                    GameObject variableGo = valueVariable as GameObject;
                    if (variableGo == null)
                    {
                        if (targetCharacter != null)
                        {
                            cPosition = targetCharacter.transform.position;
                        }
                        return;
                    }

                    NavigationMarker varMarker = variableGo.GetComponent <NavigationMarker>();
                    if (varMarker != null)
                    {
                        cPosition   = varMarker.transform.position;
                        cRotation   = new ILocomotionSystem.TargetRotation(true, varMarker.transform.forward);
                        cStopThresh = varMarker.stopThreshold;
                    }
                    else
                    {
                        cPosition = variableGo.transform.position;
                    }
                    break;

                case Variable.DataType.Vector3:
                    cPosition = (Vector3)valueVariable;
                    break;
                }
                break;
            }
        }
Example #4
0
        private void GetTarget(ref Vector3 cPosition, ref ILocomotionSystem.TargetRotation cRotation)
        {
            switch (this.moveTo)
            {
            case MOVE_TO.Position: cPosition = this.position; break;

            case MOVE_TO.Transform: cPosition = this.transform.position; break;

            case MOVE_TO.Marker:
                cPosition = this.marker.transform.position;
                cRotation = new ILocomotionSystem.TargetRotation(true, this.marker.transform.forward);
                break;
            }
        }
Example #5
0
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            if (this.waitUntilArrives)
            {
                return(false);
            }
            Character charTarget = this.target.GetCharacter(target);

            Vector3 cPosition = Vector3.zero;

            ILocomotionSystem.TargetRotation cRotation = null;
            this.GetTarget(ref cPosition, ref cRotation);

            charTarget.characterLocomotion.SetTarget(cPosition, cRotation);
            return(true);
        }
        public override IEnumerator Execute(GameObject target, IAction[] actions, int index)
        {
            this.forceStop = false;
            this.character = this.target.GetCharacter(target);

            Vector3 cPosition = Vector3.zero;

            ILocomotionSystem.TargetRotation cRotation = null;
            float cStopThresh = this.stopThreshold;

            this.GetTarget(character, target, ref cPosition, ref cRotation, ref cStopThresh);
            cStopThresh = Mathf.Max(cStopThresh, this.stopThreshold);

            this.isCharacterMoving = true;
            this.wasControllable   = this.character.characterLocomotion.isControllable;
            this.character.characterLocomotion.SetIsControllable(false);

            this.character.characterLocomotion.SetTarget(cPosition, cRotation, cStopThresh, this.CharacterArrivedCallback);

            bool  canceled = false;
            float initTime = Time.time;

            while (this.isCharacterMoving && !canceled && !forceStop)
            {
                if (this.cancelable && (Time.time - initTime) >= this.cancelDelay)
                {
                    canceled = Input.anyKey;
                }

                yield return(null);
            }

            this.character.characterLocomotion.SetIsControllable(this.wasControllable);

            if (canceled)
            {
                yield return(int.MaxValue);
            }
            else
            {
                yield return(0);
            }
        }
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            if (this.waitUntilArrives)
            {
                return(false);
            }
            this.character = this.target.GetCharacter(target);

            Vector3 cPosition = Vector3.zero;

            ILocomotionSystem.TargetRotation cRotation = null;
            float cStopThresh = 0f;

            this.GetTarget(this.character, target, ref cPosition, ref cRotation, ref cStopThresh);
            cStopThresh = Mathf.Max(cStopThresh, this.stopThreshold);

            this.character.characterLocomotion.SetTarget(cPosition, cRotation, cStopThresh);
            return(true);
        }
Example #8
0
        public override IEnumerator Execute(GameObject target, IAction[] actions, int index)
        {
            Character charTarget = this.target.GetCharacter(target);

            Vector3 cPosition = Vector3.zero;

            ILocomotionSystem.TargetRotation cRotation = null;
            this.GetTarget(ref cPosition, ref cRotation);

            this.isCharacterMoving = true;
            bool previousIsControllable = charTarget.characterLocomotion.isControllable;

            charTarget.characterLocomotion.SetIsControllable(false);

            charTarget.characterLocomotion.SetTarget(cPosition, cRotation, this.CharacterArrivedCallback);

            bool  canceled = false;
            float initTime = Time.time;

            while (this.isCharacterMoving && !canceled)
            {
                if (this.cancelable && (Time.time - initTime) >= this.cancelDelay)
                {
                    canceled = Input.anyKey;
                }

                yield return(null);
            }

            charTarget.characterLocomotion.SetIsControllable(previousIsControllable);

            if (canceled)
            {
                yield return(int.MaxValue);
            }
            else
            {
                yield return(0);
            }
        }
 public void Stop(ILocomotionSystem.TargetRotation rotation = null, UnityAction callback = null)
 {
     this.ChangeLocomotionSystem <LocomotionSystemTarget>();
     ((LocomotionSystemTarget)this.currentLocomotionSystem).Stop(rotation, callback);
 }
        // PUBLIC LOCOMOTION METHODS: -------------------------------------------------------------

        public void SetDirectionalDirection(Vector3 direction, ILocomotionSystem.TargetRotation rotation = null)
        {
            this.ChangeLocomotionSystem <LocomotionSystemDirectional>();
            ((LocomotionSystemDirectional)this.currentLocomotionSystem).SetDirection(direction, rotation);
        }