// ----------------------------------------------------------------------------------------------------
        #endregion

        #region Initialization
        // ----------------------------------------------------------------------------------------------------
        /// <summary>
        /// Called upon awaking this behavior.
        /// </summary>
        private void Awake()
        {
            this.interactionTarget = this.GetComponent <InteractionTarget>();

            this.interactionTarget.OnInteraction += (playerController) => {
                var playerStateController = playerController.StateController;
                if (CollisionUtils.IsObjectInsideTile(transform.position, playerStateController.transform.position))
                {
                    StartCoroutine(playerStateController.TeleportTo(targetTeleporter.transform));
                    this.OnTeleport?.Invoke(this);
                }
            };
        }
Exemple #2
0
        // ----------------------------------------------------------------------------------------------------
        #endregion

        #region Initialization
        // ----------------------------------------------------------------------------------------------------
        /// <summary>
        /// Called upon awaking this behavior.
        /// </summary>
        private void Awake()
        {
            this.inputController  = this.GetComponent <InputController>();
            this.playerController = this.GetComponent <PlayerController>();

            this.collisionController = this.GetComponent <ActorCollisionController>();
            this.collisionController.OnTriggerCollision += (collisionTarget) => {
                var target = collisionTarget.GetComponent <InteractionTarget>();
                if (target != null)
                {
                    this.interactionTarget    = target;
                    this.hasInteractionTarget = target.IsActive;
                }
            };

            this.collisionController.OnTriggerCollisionExit += (collisionTarget) => {
                var target = collisionTarget.GetComponent <InteractionTarget>();
                if (this.interactionTarget == target)
                {
                    this.interactionTarget    = null;
                    this.hasInteractionTarget = false;
                }
            };
        }