private void OnTriggerEnter2D(Collider2D other)
        {
            TagBehaviour tagBehaviour = other.GetComponent <TagBehaviour>();

            if (tagBehaviour == null)
            {
                return;
            }

            // Destroy when impacting solid objects
            if (tagBehaviour.HasTag("Solid"))
            {
                Sparks();
                Destroy(gameObject);
            }

            // Damage target
            if (tagBehaviour.HasTag(TargetTag))
            {
                HealthBehaviour healthBehaviour = other.GetComponent <HealthBehaviour>();
                if (healthBehaviour != null)
                {
                    healthBehaviour.Value -= Damage;
                    Destroy(gameObject);
                }
            }
        }
        public override void OnUpdateItem(InventorySlotBehaviour inventorySlotBehaviour)
        {
            IEnumerable <GameObject> enemies = TagBehaviour.FindWithTag("Enemy");

            foreach (GameObject enemy in enemies)
            {
                _enemyHealthBehaviour = enemy.GetComponent <HealthBehaviour>();
                if (_enemyHealthBehaviour.Value <= 0)
                {
                    if (_healthBehaviour.Value < _healthBehaviour.MaxHealth)
                    {
                        _healthBehaviour.Value += IncreaseValue;
                        AudioManager.Play(HealthSFX, AudioCategory.Effect);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void OnHealthChanged(HealthChangedEventArgs eventArgs)
        {
            if (eventArgs.GameObject.name == "Player" && eventArgs.NewValue < eventArgs.OldValue)
            {
                DamageTaken += eventArgs.OldValue - eventArgs.NewValue;
            }

            TagBehaviour tagBehaviour = eventArgs.GameObject.GetComponent <TagBehaviour>();

            if (tagBehaviour != null && tagBehaviour.HasTag("Enemy") && eventArgs.NewValue < eventArgs.OldValue)
            {
                DamageDealt += eventArgs.OldValue - eventArgs.NewValue;
                if (eventArgs.NewValue <= 0)
                {
                    EnemiesDefeated++;
                }
            }
        }
        private void OnHealthChanged(HealthChangedEventArgs eventArgs)
        {
            TagBehaviour tagBehaviour = eventArgs.GameObject.GetComponent <TagBehaviour>();

            bool isEnemy      = tagBehaviour != null && tagBehaviour.HasTag("Enemy");
            bool isDead       = eventArgs.NewValue == 0;
            bool isWithinRoom = eventArgs.GameObject.transform.parent == transform;

            if (isEnemy && isDead && isWithinRoom)
            {
                _enemyCount -= 1;

                if (_enemyCount <= 0)
                {
                    OnRoomCleared();
                    EventManager.Unregister(_healthChangedEventId);
                }
            }
        }
Ejemplo n.º 5
0
    void Start()
    {
        tcb = GameObject.Find("Timeline").GetComponent <TimelineCoordinatorBehaviour>();
        tb  = GetComponent <TagBehaviour> ();
        movementBehaviour = GetComponent <MovementBehaviour> ();
        if (tb != null)
        {
            if (tb.owner != null)
            {
                tbOwner = tb.owner.GetComponent <MovementBehaviour> ();
            }
        }

        if (detailsPanel == null)
        {
            detailsPanel = GetComponent <DetailPanelBehaviour> ();
        }

        if (detailsPanel != null)
        {
            detailsPanelRect = detailsPanel.GetComponent <RectTransform> ();
            detailsPanel.gameObject.SetActive(false);
        }
    }