Beispiel #1
0
        private float _attackVariable_2; // Used for multiple things such as charge and rotation etc...

        public override void _Ready()
        {
            _armStatus = new ArmStatus()
            {
                firstArmAlive  = true,
                secondArmAlive = true,

                firstArmHealth  = 1,
                secondArmHealth = 1
            };

            _firstArmHealthSetter  = GetNode <HealthSetter>(firstArmNodePath);
            _secondArmHealthSetter = GetNode <HealthSetter>(secondArmNodePath);

            _firstArmSingleController  = GetNode <BossSingleArmController>(firstArmSingleControllerNodePath);
            _secondArmSingleController = GetNode <BossSingleArmController>(secondArmSingleControllerNodePath);

            _firstArmAttackPosition  = GetNode <Node2D>(firstArmAttackNodePath);
            _secondArmAttackPosition = GetNode <Node2D>(secondArmAttackNodePath);
            _dualArmAttackPosition   = GetNode <Node2D>(dualArmAttackNodePath);

            _bulletHolder = GetNode <Node2D>(bulletHolderNodePath);

            _firstArmHealthSetter.healthChanged  += HandleFirstArmHealthChange;
            _secondArmHealthSetter.healthChanged += HandleSecondArmHealthChange;
            // This is done as all child nodes fire their ready before the parent
            HandleFirstArmHealthChange(_firstArmHealthSetter.GetCurrentHealth(), _firstArmHealthSetter.GetMaxHealth());
            HandleSecondArmHealthChange(_secondArmHealthSetter.GetCurrentHealth(), _secondArmHealthSetter.GetMaxHealth());
        }
        private void SetSmokeBasedOnHealth()
        {
            float healthRatio = _healthSetter.GetCurrentHealth() / _healthSetter.maxHealthAmount;

            if (healthRatio > thresholdHealthRatio)
            {
                return;
            }

            if (_smokeParticles.Count == 0)
            {
                GameObject smokeInstance = Instantiate(droneDamageSmoke,
                                                       smokeSpawnPoint.position, droneDamageSmoke.transform.rotation);
                smokeInstance.transform.SetParent(smokeSpawnPoint);

                _smokeParticles = smokeInstance.GetComponentsInChildren <ParticleSystem>().ToList();
            }

            foreach (ParticleSystem particle in _smokeParticles)
            {
                float mappedEmissionRate = ExtensionFunctions.Map(
                    healthRatio,
                    thresholdHealthRatio, 0,
                    minParticles, maxParticles
                    );

                ParticleSystem.EmissionModule emission = particle.emission;
                emission.rateOverTime = mappedEmissionRate;
            }
        }
Beispiel #3
0
        public override void _Ready()
        {
            _bodyStatus = new BodyStatus()
            {
                bodyDestroyed = false,
                bodyHealth    = 1
            };

            _bossBodyHealthSetter = GetNode <HealthSetter>(bossBodyNodePath);
            _bossBodyHealthSetter.healthChanged += HandleBodyHealthChanged;

            HandleBodyHealthChanged(_bossBodyHealthSetter.GetCurrentHealth(), _bossBodyHealthSetter.GetMaxHealth());
        }
Beispiel #4
0
        private BossState GetRandomAttack()
        {
            if (_currentBossState == BossState.Dead)
            {
                return(BossState.Dead);
            }

            float frenzyAttackChance = (float)GD.Randf();
            float currentHealth      = _bossTotalHealthSetter.GetCurrentHealth();

            if (frenzyAttackChance <= frenzyAttackChancePercent &&
                currentHealth <= frenzyAttackHealthPercent)
            {
                return(BossState.FrenzySpinningShot);
            }

            float     randomNumber = (float)GD.Randf();
            BossState bossState    = BossState.FrenzySpinningShot;

            if (randomNumber > minSingleArmAttackPercent && randomNumber < maxSingleArmAttackPercent)
            {
                bossState = BossState.SingleArmShot;
            }
            else if (randomNumber > minDualArmAttackPercent && randomNumber < maxDualArmAttackPercent)
            {
                bossState = BossState.DualArmShot;
            }
            else if (randomNumber > minAbilityAttackPercent && randomNumber < maxAbilityArmAttackPercent)
            {
                bossState = BossState.AbilityAttack;
            }

            if (bossState == BossState.SingleArmShot && !_bossHealthBodyStatus.singleArmAvailable)
            {
                bossState = BossState.AbilityAttack;
            }
            else if (bossState == BossState.DualArmShot && !_bossHealthBodyStatus.doubleArmAvailable)
            {
                bossState = BossState.AbilityAttack;
            }

            // This is very important.
            // Probably should not be hidden like this
            if (bossState == BossState.AbilityAttack)
            {
                _abilityAttackIndex = (int)(GD.Randi() % _bossAttacks.Count);
                _abilityAttackIndex = Mathf.Abs(_abilityAttackIndex); // This is added so as to prevent an overflow
            }

            return(bossState);
        }
Beispiel #5
0
        private void DisplayDamageEffect()
        {
            var currentHealth = _healthSetter.GetCurrentHealth();

            if (currentHealth <= _oneThirdHealth && !_smokeInstantiated)
            {
                var smokeInstance = Instantiate(smokeEffect, instancePoint.position,
                                                smokeEffect.transform.rotation);
                smokeInstance.transform.SetParent(instancePoint);
                _smokeEmission     = smokeInstance.GetComponent <ParticleSystem>().emission;
                _smokeInstantiated = true;
            }

            if (_smokeInstantiated)
            {
                var emissionRate = ExtensionFunctions.Map(currentHealth, 0, _oneThirdHealth,
                                                          MaxSmokeParticles, MinSmokeParticles);
                _smokeEmission.rateOverTime = emissionRate;
            }
        }
Beispiel #6
0
        private void DisplayHealthToUI()
        {
            if (_healthSetter == null)
            {
                return;
            }

            float currentHealth = _healthSetter.GetCurrentHealth();
            float maxHealth     = _healthSetter.maxHealthAmount;

            float healthRatio = currentHealth / maxHealth;

            if (healthRatio > 0.5f)
            {
                healthFiller.color = Color.Lerp(halfHealthColor, maxHealthColor, (healthRatio - 0.5f) * 2);
            }
            else
            {
                healthFiller.color = Color.Lerp(minHealthColor, halfHealthColor, healthRatio * 2);
            }

            healthSlider.value = healthRatio;
        }
        private void DisplayHealthToUI()
        {
            var currentHealthAmount = playerHealthSetter.GetCurrentHealth();
            var maxHealthAmount     = playerHealthSetter.maxHealthAmount;
            var healthRatio         = currentHealthAmount / maxHealthAmount;

            if (healthRatio <= 0.5f)
            {
                if (!_postProcessOverrideApplied)
                {
                    CreateOverrideVignetteEffect();
                    _postProcessVolume = PostProcessManager.instance.QuickVolume(
                        PostProcessLayer,
                        PostProcessOverridePriority,
                        _healthVignette
                        );
                    _postProcessOverrideApplied = true;
                }

                _healthVignette.color.value = Color.Lerp(
                    Color.black,
                    minHealthColor,
                    ExtensionFunctions.Map(healthRatio, 0, 0.5f, 1, 0.25f)
                    );
            }
            else if (healthRatio > 0.5f && _postProcessOverrideApplied)
            {
                RuntimeUtilities.DestroyVolume(_postProcessVolume, true);
                _postProcessOverrideApplied = false;
            }

            healthFiller.color = healthRatio <= 0.5f
                ? Color.Lerp(minHealthColor, halfHealthColor, healthRatio * 2)
                : Color.Lerp(halfHealthColor, maxHealthColor, (healthRatio - 0.5f) * 2);

            healthSlider.value = healthRatio;
        }