Ejemplo n.º 1
0
        // ----------------------------------------------------------------------------------------------------
        #endregion

        #region Initialization
        // ----------------------------------------------------------------------------------------------------
        /// <summary>
        /// Called upon awaking this behavior.
        /// </summary>
        private void Awake()
        {
            this.triggerEventGroup = new TriggerEventGroup(triggerEvents);

            this.interactionTarget = this.GetComponent <InteractionTarget>();
            this.cameraShakeEffect = this.GetComponent <CameraShakeEffect>();
            this.highlightMaterial = this.GetComponent <HighlightMaterialController>();
            this.collisionGravity  = this.GetComponent <CollisionGravity>();

            this.interactionTarget.OnInteraction += (playerController) => {
                var playerStateController = playerController.StateController;
                if (CollisionUtils.IsObjectInsideTile(transform.position, playerStateController.transform.position))
                {
                    this.Toggle();
                }
            };

            this.OnStatusChanged += (toggleSwitch) => {
                if (toggleSwitch.isActivated)
                {
                    this.triggerEventGroup.Invoke();
                }
                else
                {
                    this.triggerEventGroup.Reset();
                }
            };

            this.SetActive(this.activatedByDefault, true);
        }
Ejemplo n.º 2
0
        // ----------------------------------------------------------------------------------------------------
        #endregion

        #region Initialization
        // ----------------------------------------------------------------------------------------------------
        /// <summary>
        /// Called upon awaking this behavior.
        /// </summary>
        private void Awake()
        {
            this.triggerEventGroup = new TriggerEventGroup(triggerEvents);

            this.triggerEventGroup.Reset();

            foreach (var switchController in this.switchControllers)
            {
                switchController.OnActivationChange += (activeSwitchController) => {
                    this.UpdateActivation();
                };
            }
        }