Example #1
0
        public bool TriggerInteraction(int index, bool interrupt, out InteractionTarget interactionTarget)
        {
            interactionTarget = null;
            if (!this.IsValid(true))
            {
                return(false);
            }
            if (!this.TriggerIndexIsValid(index))
            {
                return(false);
            }
            bool result = true;

            InteractionTrigger.Range range = this.triggersInRange[index].ranges[this.bestRangeIndexes[index]];
            for (int i = 0; i < range.interactions.Length; i++)
            {
                for (int j = 0; j < range.interactions[i].effectors.Length; j++)
                {
                    InteractionObject interactionObject = range.interactions[i].interactionObject;
                    Transform         target            = interactionObject.GetTarget(range.interactions[i].effectors[j], base.tag);
                    if (target != null)
                    {
                        interactionTarget = target.GetComponent <InteractionTarget>();
                    }
                    if (!this.StartInteraction(range.interactions[i].effectors[j], interactionObject, interrupt))
                    {
                        result = false;
                    }
                }
            }
            return(result);
        }
 public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
 {
     if (!this.inInteraction)
     {
         this.effector.position = this.effector.bone.position;
         this.effector.rotation = this.effector.bone.rotation;
     }
     else if (!interrupt)
     {
         return(false);
     }
     this.target = interactionObject.GetTarget(this.effectorType, tag);
     if (this.target == null)
     {
         return(false);
     }
     this.interactionTarget = this.target.GetComponent <InteractionTarget>();
     this.interactionObject = interactionObject;
     if (this.interactionSystem.OnInteractionStart != null)
     {
         this.interactionSystem.OnInteractionStart(this.effectorType, interactionObject);
     }
     interactionObject.OnStartInteraction(this.interactionSystem);
     this.triggered.Clear();
     for (int i = 0; i < interactionObject.events.Length; i++)
     {
         this.triggered.Add(false);
     }
     if (this.poser != null)
     {
         if (this.poser.poseRoot == null)
         {
             this.poser.weight = 0f;
         }
         if (this.interactionTarget != null)
         {
             this.poser.poseRoot = this.target.transform;
         }
         else
         {
             this.poser.poseRoot = null;
         }
         this.poser.AutoMapping();
     }
     this.timer          = 0f;
     this.weight         = 0f;
     this.fadeInSpeed    = ((fadeInTime <= 0f) ? 1000f : (1f / fadeInTime));
     this.length         = interactionObject.length;
     this.isPaused       = false;
     this.pickedUp       = false;
     this.pickUpPosition = Vector3.zero;
     this.pickUpRotation = Quaternion.identity;
     if (this.interactionTarget != null)
     {
         this.interactionTarget.RotateTo(this.effector.bone.position);
     }
     return(true);
 }
Example #3
0
        // Start interaction
        public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null)
            {
                return(false);
            }
            interactionTarget = target.GetComponent <InteractionTarget>();

            return(Start(interactionObject, interactionTarget, fadeInTime, interrupt));
        }
        // Start interaction
        public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // If not in interaction, set effector positions to their bones
            if (!inInteraction)
            {
                effector.position = effector.bone.position;;
                effector.rotation = effector.bone.rotation;;
            }
            else
            {
                if (!interrupt)
                {
                    return(false);
                }
            }

            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null)
            {
                return(false);
            }
            interactionTarget = target.GetComponent <InteractionTarget>();

            // Start the interaction
            this.interactionObject = interactionObject;
            if (interactionSystem.OnInteractionStart != null)
            {
                interactionSystem.OnInteractionStart(effectorType, interactionObject);
            }
            interactionObject.OnStartInteraction(interactionSystem);

            // Cleared triggered events
            triggered.Clear();

            for (int i = 0; i < interactionObject.events.Length; i++)
            {
                triggered.Add(false);
            }

            // Posing the hand/foot
            if (poser != null)
            {
                if (poser.poseRoot == null)
                {
                    poser.weight = 0f;
                }

                if (interactionTarget != null)
                {
                    poser.poseRoot = target.transform;
                }
                else
                {
                    poser.poseRoot = null;
                }

                poser.AutoMapping();
            }

            // See which InteractionObject.WeightCurve.Types are used
            //private bool positionWeightUsed, rotationWeightUsed, pullUsed, reachUsed, pushUsed, pushParentUsed, poserUsed;
            positionWeightUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PositionWeight);
            rotationWeightUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.RotationWeight);
            pullUsed           = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Pull);
            reachUsed          = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Reach);
            pushUsed           = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Push);
            pushParentUsed     = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PushParent);
            //poserUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PoserWeight);
            StoreDefaults();

            // Reset internal values
            timer       = 0f;
            weight      = 0f;
            fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
            length      = interactionObject.length;

            isPaused       = false;
            pickedUp       = false;
            pickUpPosition = Vector3.zero;
            pickUpRotation = Quaternion.identity;

            if (interactionTarget != null)
            {
                interactionTarget.RotateTo(effector.bone.position);
            }

            started = true;

            return(true);
        }
Example #5
0
        // Start interaction
        public void Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // If not in interaction, set effector positions to their bones
            if (!inInteraction)
            {
                effector.position = effector.bone.position;
                effector.rotation = effector.bone.rotation;
            }
            else if (!interrupt)
            {
                return;
            }

            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null)
            {
                return;
            }
            interactionTarget = target.GetComponent <InteractionTarget>();

            // Start the interaction
            this.interactionObject = interactionObject;
            if (OnStart != null)
            {
                OnStart(effectorType, interactionObject);
            }

            // Posing the hand/foot
            if (poser != null)
            {
                if (poser.poseRoot == null)
                {
                    poser.weight = 0f;
                }

                if (interactionTarget != null)
                {
                    poser.poseRoot = target.transform;
                }
                else
                {
                    poser.poseRoot = null;
                }

                poser.AutoMapping();
            }

            // Reset internal values
            timer       = 0f;
            weight      = 0f;
            fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
            length      = interactionObject.length;

            triggered = false;
            released  = false;
            isPaused  = false;

            pickedUp       = false;
            pickUpPosition = Vector3.zero;
            pickUpRotation = Quaternion.identity;

            // Call StartInteraction on the InteractionObject
            interactionObject.StartInteraction(effector.bone);
            if (interactionTarget != null)
            {
                interactionTarget.RotateTo(effector.bone.position);
            }
        }
		// Start interaction
		public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt) {
			// If not in interaction, set effector positions to their bones
			if (!inInteraction) {
				effector.position = effector.bone.position;;
				effector.rotation = effector.bone.rotation;;
			} else {
				if (!interrupt) return false;
			}

			// Get the InteractionTarget
			target = interactionObject.GetTarget(effectorType, tag);
			if (target == null) return false;
			interactionTarget = target.GetComponent<InteractionTarget>();

			// Start the interaction
			this.interactionObject = interactionObject;
			if (interactionSystem.OnInteractionStart != null) interactionSystem.OnInteractionStart(effectorType, interactionObject);
			interactionObject.OnStartInteraction(interactionSystem);
			
			// Cleared triggered events
			triggered.Clear();

			for (int i = 0; i < interactionObject.events.Length; i++) {
				triggered.Add(false);
			}

			// Posing the hand/foot
			if (poser != null) {
				if (poser.poseRoot == null) poser.weight = 0f;

				if (interactionTarget != null) poser.poseRoot = target.transform;
				else poser.poseRoot = null;

				poser.AutoMapping();
			}

			// Reset internal values
			timer = 0f;
			weight = 0f;
			fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
			length = interactionObject.length;
			
			isPaused = false;
			pickedUp = false;
			pickUpPosition = Vector3.zero;
			pickUpRotation = Quaternion.identity;

			if (interactionTarget != null) interactionTarget.RotateTo(effector.bone.position);

			started = true;

			return true;
		}
Example #7
0
        // Start interaction
        public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // If not in interaction, set effector positions to their bones
            if (!inInteraction)
            {
                effector.position = effector.bone.position;;
                effector.rotation = effector.bone.rotation;;
            }
            else
            {
                if (!interrupt)
                {
                    return(false);
                }
            }

            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null)
            {
                return(false);
            }
            interactionTarget = target.GetComponent <InteractionTarget>();

            // Start the interaction
            this.interactionObject = interactionObject;
            if (interactionSystem.OnInteractionStart != null)
            {
                interactionSystem.OnInteractionStart(effectorType, interactionObject);
            }

            // Cleared triggered events
            triggered.Clear();

            for (int i = 0; i < interactionObject.events.Length; i++)
            {
                triggered.Add(false);
            }

            // Posing the hand/foot
            if (poser != null)
            {
                if (poser.poseRoot == null)
                {
                    poser.weight = 0f;
                }

                if (interactionTarget != null)
                {
                    poser.poseRoot = target.transform;
                }
                else
                {
                    poser.poseRoot = null;
                }

                poser.AutoMapping();
            }

            // Reset internal values
            timer       = 0f;
            weight      = 0f;
            fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
            length      = interactionObject.length;

            isPaused       = false;
            pickedUp       = false;
            pickUpPosition = Vector3.zero;
            pickUpRotation = Quaternion.identity;

            if (interactionTarget != null)
            {
                interactionTarget.RotateTo(effector.bone.position);
            }

            return(true);
        }
        // Start interaction
        public void Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // If not in interaction, set effector positions to their bones
            if (!inInteraction) {
                effector.position = effector.bone.position;
                effector.rotation = effector.bone.rotation;
            } else if (!interrupt) return;

            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null) return;
            interactionTarget = target.GetComponent<InteractionTarget>();

            // Start the interaction
            this.interactionObject = interactionObject;
            if (OnStart != null) OnStart(effectorType, interactionObject);

            // Posing the hand/foot
            if (poser != null) {
                if (poser.poseRoot == null) poser.weight = 0f;

                if (interactionTarget != null) poser.poseRoot = target.transform;
                else poser.poseRoot = null;

                poser.AutoMapping();
            }

            // Reset internal values
            timer = 0f;
            weight = 0f;
            fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
            length = interactionObject.length;

            triggered = false;
            released = false;
            isPaused = false;

            pickedUp = false;
            pickUpPosition = Vector3.zero;
            pickUpRotation = Quaternion.identity;

            // Call StartInteraction on the InteractionObject
            interactionObject.StartInteraction(effector.bone);
            if (interactionTarget != null) interactionTarget.RotateTo(effector.bone.position);
        }