Beispiel #1
0
        public void Resume()
        {
            Unpause();

            if (!_pendingTeleport)
            {
                return;
            }

            Teleport(_pendingTeleport, true);

            _pendingTeleport = null;
        }
Beispiel #2
0
        public TeleportPortal CalculatePortal(TeleportPortal destination)
        {
            if (destination.dropZoneLookAt == InputButton.None && Movement.PreviousDirection != null)
            {
                destination.calculatedDropZoneLookAt = Movement.PreviousDirection.Value;
            }
            else
            {
                destination.calculatedDropZoneLookAt = GameManager.Input.ButtonToVector2(destination.dropZoneLookAt);
            }

            destination.calculatedDropZone = (Vector2)destination.dropZone.position + destination.dropZoneOffset;

            return(destination);
        }
Beispiel #3
0
        public TeleportPortal CalculatePortal(TeleportPortal destination)
        {
            if (destination.dropZoneLookAt == GameButton.None)
            {
                destination.calculatedDropZoneLookAt = PlayerMove.Director.Path.Move.GetDirectionVector();
            }
            else
            {
                destination.calculatedDropZoneLookAt = GameManager.Input.ButtonToVector2(destination.dropZoneLookAt);
            }

            destination.calculatedDropZone = (Vector2)destination.dropZone.position + destination.dropZoneOffset;

            return(destination);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="destination">Calculated destination</param>
        /// <param name="isCalculated">If true, the destination won't be recalculated</param>
        /// <returns></returns>
        public bool Teleport(TeleportPortal destination, bool isCalculated = false)
        {
            if (!isCalculated)
            {
                destination = CalculatePortal(destination);
            }

            // first, move to the drop zone immediately, without animation
            if (!Teleport(destination.calculatedDropZone, destination.calculatedDropZoneLookAt))
            {
                Debug.LogError("Teleport not possible...");
                return(false);
            }

            if (destination.calculatedDropZoneLookAt == Vector2.zero)
            {
                //Debug.Log("dir = Vector2.zero");
                return(true);
            }

            // turn around if necessary, to avoid turn around timeout
            if (destination.dropZoneLookAt != InputButton.None)
            {
                Movement.LookAt(destination.calculatedDropZoneLookAt,
                                destination.dropZoneSteps > 0 ? 0 : _stairsWaitTime);
            }

            if (destination.dropZoneSteps == 0)
            {
                //Debug.Log("destination.moveSteps = 0");
                return(true);
            }

            // move the necessary steps in that direction

            // TODO: refactor into a separate function to be able to delay it too (door enter animation cannot be seen on fade in)
            if (!Movement.Move(destination.calculatedDropZoneLookAt, destination.dropZoneSteps))
            {
                Debug.LogWarning("Moving dropzone steps FAILED...");
            }

            return(true);
        }
Beispiel #5
0
        // For the OnTriggerStay2D event to be fired while the object is in contact, the Rigid2D body Sleep Mode
        // has to be on "Never Sleep", otherwise this is only triggered once
        void OnTriggerEnter2D(Collider2D other)
        {
            if (!IsPortal(other) || IsTeleporting() || IsPaused())
            {
                return;
            }

            var calculatedPortal = CalculatePortal(GetPortal(other));

            _pendingTeleport = calculatedPortal;
            if (_pendingTeleport.soundEffect)
            {
                GameManager.Audio.PlaySfx(_pendingTeleport.soundEffect);
            }

            if (!(transitionController is null))
            {
                transitionController.TransitionOutIn();
            }
Beispiel #6
0
        void OnTriggerEnter2D(Collider2D other)
        {
//            Debug.Log("OnTriggerEnter2D");
            // For the OnTriggerStay2D event to be fired while the object is in contact, the Rigid2D body Sleep Mode
            // has to be on "Never Sleep", otherwise this is only triggered once

//            if (IsPaused())
//            {
//                Debug.Log("Is paused...");
//            }
//
//            if (IsTeleporting())
//            {
//                Debug.Log("Is teleporting...");
//            }
//
//            if (!IsPortal(other))
//            {
//                Debug.Log("Is not portal...");
//                return;
//            }
//
//            Debug.Log("Is OK, scheduling teleport...");

            if (!IsPortal(other) || IsTeleporting() || IsPaused())
            {
                return;
            }

            var calculatedPortal = CalculatePortal(GetPortal(other));

            onTeleportStart.Invoke();
            _pendingTeleport = calculatedPortal;
            if (_pendingTeleport.soundEffect)
            {
                GameManager.Audio.PlaySfx(_pendingTeleport.soundEffect);
            }
        }