/// <summary>
		/// Activates the Teleport function to a specific point.
		/// </summary>
		/// <param name="targetPoint">the point to teleport to</param>
		/// 
		public void Activate(Vector3 targetPoint)
		{
			if (!IsReady()) return;

			// calculate target point
			Vector3 startPoint = this.transform.position;
			Vector3 offset = targetPoint - this.transform.position;
			offset.y = 0;
			Vector3 endPoint = startPoint + offset;

			// activate transition
			switch (transitionType)
			{
				case TransitionType.Fade:
					transition = new Transition_Fade(endPoint, transitionTime, this.gameObject);
					break;

				case TransitionType.MoveLinear:
					transition = new Transition_Move(startPoint, endPoint, transitionTime, false);
					break;

				case TransitionType.MoveSmooth:
					transition = new Transition_Move(startPoint, endPoint, transitionTime, true);
					break;
			}
		}
Esempio n. 2
0
        /// <summary>
        /// Activates the Teleport function to a specific point.
        /// </summary>
        /// <param name="originPoint">the point to teleport from</param>
        /// <param name="targetPoint">the point to teleport to</param>
        ///
        public void Activate(Vector3 originPoint, Vector3 targetPoint)
        {
            if (!IsReady())
            {
                return;
            }

            if (teleportSound != null)
            {
                teleportSound.pitch = UnityEngine.Random.Range(0.9f, 1.1f);
                teleportSound.Play();
            }

            // calculate offset to target point (relativ to floor level, not camera height)
            originPoint.y = this.transform.position.y;
            Vector3 offset = targetPoint - originPoint;

            if (!allowVerticalMovement)
            {
                offset.y = 0;
            }

            Vector3 startPoint = this.transform.position;
            Vector3 endPoint   = startPoint + offset;

            // activate transition
            switch (transitionType)
            {
            case TransitionType.Fade:
                transition = new Transition_Fade(endPoint, transitionTime, this.gameObject);
                break;

            case TransitionType.MoveLinear:
                transition = new Transition_Move(startPoint, endPoint, transitionTime, false);
                break;

            case TransitionType.MoveSmooth:
                transition = new Transition_Move(startPoint, endPoint, transitionTime, true);
                break;
            }
        }