void UpdateAbilityState()
    {
        if (_cooldownTimer > 0)
        {
            // Segmenting this timner allows for abilities to be expressly canceled by damage/other systems
            if (_cooldownTimer > _cooldownMinusCast)
            {
                _cooldownTimer = BasicCounter.TowardsTarget(_cooldownTimer, _cooldownMinusCast, 1f);

                if (_cooldownTimer == _cooldownMinusCast)
                {
                    UseAbilityStop?.Invoke();
                    EquippedAbility.Use(transform, CurrentTarget);
                }
            }

            // finished countdown
            else if (_cooldownTimer <= _cooldownMinusCast)
            {
                _cooldownTimer = BasicCounter.TowardsTarget(_cooldownTimer, 0, 1f);
            }

            Cooldown?.Invoke(_cooldownTimer, EquippedAbility.cooldown);
        }
    }
Example #2
0
        public void Consists_of_a_single_monitor()
        {
            var counter = new BasicCounter(MonitorConfig.Build("Test"));

            counter.GetAllMonitors().Should().HaveCount(1);
            counter.GetAllMonitors().Single().Should().BeSameAs(counter);
        }
Example #3
0
    IEnumerator PulseHealthWindow(Vector3 currentScale, float beatModifier)
    {
        float minX = currentScale.x;
        float minY = currentScale.y;

        while (true)
        {
            AudioHelper.PlayClip2D(_heartbeatAudio, 0.25f * beatModifier);
            Debug.Log("Running");
            while (currentScale.x < _maxWindowXScale && currentScale.y < _maxWindowYScale)
            {
                currentScale.x = BasicCounter.TowardsTarget(currentScale.x, _maxWindowXScale, _windowXScaleMargin * beatModifier * 3f);
                currentScale.y = BasicCounter.TowardsTarget(currentScale.y, _maxWindowYScale, _windowYScaleMargin * beatModifier * 3f);

                _damageWindow.gameObject.transform.localScale = new Vector3(currentScale.x, currentScale.y, 1);
                yield return(null);
            }

            yield return(new WaitForSeconds(0.25f - (0.05f * beatModifier)));

            while (currentScale.x > minX && currentScale.y > minY)
            {
                currentScale.x = BasicCounter.TowardsTarget(currentScale.x, minX, _windowXScaleMargin * beatModifier * 3f);
                currentScale.y = BasicCounter.TowardsTarget(currentScale.y, minY, _windowYScaleMargin * beatModifier * 3f);

                _damageWindow.gameObject.transform.localScale = new Vector3(currentScale.x, currentScale.y, 1);
                yield return(null);
            }
        }
    }
    // flashes the object for a short time
    IEnumerator FlashCycle()
    {
        float timer = 0;

        // animates towards full opacity
        while (timer < _flashTime)
        {
            timer = BasicCounter.TowardsTarget(timer, _flashTime, 1f);

            _childRenderer.SetAlpha(timer / _flashTime);

            yield return(null);
        }

        // animates towards full transparency
        while (timer > 0)
        {
            timer = BasicCounter.TowardsTarget(timer, 0f, 1f);

            _childRenderer.SetAlpha(timer / _flashTime);

            yield return(null);
        }

        _flashRoutine = null;
    }
Example #5
0
        public void Incrementing_the_counters_works_as_expected(int amount)
        {
            var counter = new BasicCounter(MonitorConfig.Build("Test"));

            counter.Increment(amount);

            counter.GetValue().Should().Be(amount);
        }
Example #6
0
        public void Get_and_reset_returns_the_value(int amount)
        {
            var counter = new BasicCounter(MonitorConfig.Build("Test"));

            counter.Increment(amount);

            var value = counter.GetValueAndReset();

            value.Should().Be(amount);
        }
        public void TestMaxCount()
        {
            // Given
            var counter = new BasicCounter(BasicCounter.MaxCount);

            // When
            counter.Increment();

            // Then
            Assert.AreEqual(BasicCounter.MaxCount, counter.Count);
        }
    // pulses indefinitely based on designer control
    private IEnumerator LightRoutine()
    {
        while (true)
        {
            while (_objectLight.intensity < _pulseMax)
            {
                _objectLight.intensity = BasicCounter.TowardsTarget(_objectLight.intensity, _pulseMax, _pulseSpeed);
                yield return(null);
            }

            while (_objectLight.intensity > _pulseMin)
            {
                _objectLight.intensity = BasicCounter.TowardsTarget(_objectLight.intensity, _pulseMin, _pulseSpeed);
                yield return(null);
            }
        }
    }
    // adjusts speed by ramping up or down towards a target based on current sprint flag
    private void CalculateSpeed()
    {
        if (!IsRunning && Grounded())
        {
            _speed = _defaultSpeed;
        }

        if (!IsJumping && IsRunning && _canBasic)     // speed stays static in mid-air, forces the player to be more mindful
        {
            if (_speed < _sprintSpeed && IsSprinting)
            {
                _speed = BasicCounter.TowardsTarget(_speed, _sprintSpeed, _sprintAcceleration);
            }

            if (_speed > _defaultSpeed && !IsSprinting)
            {
                _speed = BasicCounter.TowardsTarget(_speed, _defaultSpeed, _sprintAcceleration);
            }
        }
    }
    // applies recoil with a basic timer system according to designer-determined deceleration
    private void CalculateRecoil()
    {
        if (_currentRecoil > 0)
        {
            _controller.Move(new Vector3
                                 (_recoilDirection.x * _currentRecoil, Physics.gravity.y * Time.deltaTime, _recoilDirection.z * _currentRecoil) * Time.deltaTime);

            _currentRecoil = BasicCounter.TowardsTarget(_currentRecoil, 0, _recoilDecel);
            if (_currentRecoil == 0)
            {
                if (IsDead)
                {
                    return;
                }
                else
                {
                    _recoilDirection = Vector3.zero;
                    StopRecoil?.Invoke();
                    OnAbilityComplete();
                }
            }
        }
    }
Example #11
0
        public void Initial_value_is_zero()
        {
            var counter = new BasicCounter(MonitorConfig.Build("Test"));

            counter.GetValue().Should().Be(0);
        }