Esempio n. 1
0
        private void ExecuteNextAbilityFromList(long tick)
        {
            // This contains the list of abilities that can possibly be executed.
            var rand = StaticRandom.Instance.Next(1, 100);

            foreach (var keyValuePair in AbilityTracker)
            {
                _logger.Debug($"tick = {tick} ");
                if (keyValuePair.Value < tick)
                {
                    if (keyValuePair.Key.ExecuteChance >= rand)
                    {
                        var method = ExecutionManager.GetType().GetMethod(keyValuePair.Key.Execution);
                        if (method == null)
                        {
                            _logger.Warn($"Could not locate method for execution : {keyValuePair.Key.Execution}");
                            return;
                        }

                        _logger.Trace($"Executing  : {keyValuePair.Key.Name} => {keyValuePair.Value} ");

                        PerformSpeech(keyValuePair.Key);

                        PerformSound(keyValuePair.Key);

                        _logger.Debug($"Executing  : {keyValuePair.Key.Name} => {keyValuePair.Value} ");

                        lock (AbilityTracker)
                        {
                            // TODO : See if this is required, or can use ability cool down instead
                            AbilityTracker[keyValuePair.Key] = tick + keyValuePair.Key.CoolDown * 1000;
                            _logger.Debug($"Next kv tick = {tick + keyValuePair.Key.CoolDown * 1000} ");
                        }

                        try
                        {
                            method.Invoke(ExecutionManager, null);
                        }
                        catch (Exception e)
                        {
                            _logger.Error($"{e.Message} {e.StackTrace}");
                            throw;
                        }

                        _logger.Trace(
                            $"Updating the tracker : {keyValuePair.Key.Name} => {tick + keyValuePair.Key.CoolDown * 1000} ");
                        _logger.Debug($"CoolDowns : {_unit.AbtInterface.Cooldowns.Count}");
                        break; // Leave the loop, come back on next tick
                    }

                    _logger.Debug($"Skipping : {keyValuePair.Key.Name} => {keyValuePair.Value} (random)");
                }
            }
        }
Esempio n. 2
0
        private void ExecuteNextAbilityFromList(long tick, List <KeyValuePair <BossSpawnAbilities, long> > myList)
        {
            // This contains the list of abilities that can possibly be executed.
            var rand = StaticRandom.Instance.Next(1, 100);

            lock (myList)
            {
                foreach (var keyValuePair in myList)
                {
                    if (keyValuePair.Value < tick)
                    {
                        if (keyValuePair.Key.ExecuteChance >= rand)
                        {
                            var method = ExecutionManager.GetType().GetMethod(keyValuePair.Key.Execution);

                            _logger.Trace($"Executing  : {keyValuePair.Key.Name} => {keyValuePair.Value} ");

                            PerformSpeech(keyValuePair.Key);

                            PerformSound(keyValuePair.Key);

                            _logger.Debug($"Executing  : {keyValuePair.Key.Name} => {keyValuePair.Value} ");

                            NextTryCastTime = TCPManager.GetTimeStampMS() + NEXT_ATTACK_COOLDOWN;

                            lock (AbilityTracker)
                            {
                                // TODO : See if this is required, or can use ability cool down instead
                                AbilityTracker[keyValuePair.Key] = tick + keyValuePair.Key.CoolDown * 1000;
                            }

                            try
                            {
                                method.Invoke(ExecutionManager, null);
                            }
                            catch (Exception e)
                            {
                                _logger.Error($"{e.Message} {e.StackTrace}");
                                throw;
                            }

                            _logger.Trace(
                                $"Updating the tracker : {keyValuePair.Key.Name} => {tick + keyValuePair.Key.CoolDown * 1000} ");
                            _logger.Debug($"CoolDowns : {_unit.AbtInterface.Cooldowns.Count}");
                            break; // Leave the loop, come back on next tick
                        }

                        _logger.Debug($"Skipping : {keyValuePair.Key.Name} => {keyValuePair.Value} (random)");
                    }
                }
            }
        }