// ---------------------------------------------------------------------------------------------------- #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); }
// ---------------------------------------------------------------------------------------------------- #endregion #region Initialization // ---------------------------------------------------------------------------------------------------- /// <summary> /// Called upon awaking this behavior. /// </summary> private void Awake() { this.playerController = this.GetComponent <PlayerController>(); this.collisionController = this.GetComponent <ActorCollisionController>(); this.cameraShakeEffect = this.GetComponent <CameraShakeEffect>(); this.collisionController.OnTriggerCollision += (collisionTarget) => { var collisionDamage = collisionTarget.GetComponent <CollisionDamage>(); if (collisionDamage != null) { this.playerController.Damage(collisionDamage.Damage); this.OnReceivedDamage?.Invoke(collisionDamage); this.cameraShakeEffect.Shake(); } }; }