void EntityDamaged(int sender, DamageInfo damageInfo)
        {
            var node = nodesDB.QueryNode<EnemyNode>(sender);

            node.vfxComponent.hitParticles.transform.position = damageInfo.damagePoint;
            node.vfxComponent.hitParticles.Play();
        }
        public void Tick(float deltaSec)
        {
            var enemiesAttackList = nodesDB.QueryNodes<EnemyNode>();

            for (int enemyIndex = enemiesAttackList.Count - 1; enemyIndex >= 0 ; --enemyIndex)
            {
                var enemyAttackNode = enemiesAttackList[enemyIndex];

                if (enemyAttackNode.attackComponent.targetInRange == true)
                {
                    var attackDamageComponent = enemyAttackNode.attackDamageComponent;
                        attackDamageComponent.timer += deltaSec;

                    if (attackDamageComponent.timer >= attackDamageComponent.attackInterval)
                    {
                        attackDamageComponent.timer = 0.0f;

                        if (_targetNode != null)
                        {
                            var damageInfo = new DamageInfo(attackDamageComponent.damage, Vector3.zero);

                            _targetNode.damageEventComponent.damageReceived.Dispatch(ref damageInfo);
                        }
                    }
                }
            }
        }
Example #3
0
        void OnDamageEvent(int sender, DamageInfo damaged)
        {
            var damageComponent = _guiNode.damageImageComponent;
            var damageImage = damageComponent.damageImage;

            damageImage.color = damageComponent.flashColor;

            _guiNode.healthSliderComponent.healthSlider.value = nodesDB.QueryNode<HUDDamageEventNode>(sender).healthComponent.currentHealth;
        }
        void Shoot()
        {
            RaycastHit shootHit;
            var playerGunComponent = _playerGunNode.gunComponent;
            var playerGunHitComponent = _playerGunNode.gunHitTargetComponent;

            playerGunComponent.timer = 0;

            if (Physics.Raycast(playerGunComponent.shootRay, out shootHit, playerGunComponent.range, SHOOTABLE_MASK | ENEMY_MASK))
            {
                var hitGO = shootHit.collider.gameObject;

                PlayerTargetNode targetComponent = null;

                if (hitGO.layer == ENEMY_LAYER && nodesDB.QueryNode<PlayerTargetNode>(hitGO.GetInstanceID(), out targetComponent))
                {
                    var damageInfo = new DamageInfo(playerGunComponent.damagePerShot, shootHit.point);
                    targetComponent.damageEventComponent.damageReceived.Dispatch(ref damageInfo);

                    playerGunComponent.lastTargetPosition = shootHit.point;
                    playerGunHitComponent.targetHit.value = true;

                    return;
                }
            }

            playerGunHitComponent.targetHit.value = false;
        }