Example #1
0
        private async Task OnGameInitialized()      // TODO: Handle summoner spells
        {
            animationModule.StopCurrentAnimation(); // stops the current anim

            // Queries the game information
            await QueryPlayerInfo(true);

            // Set trinket initial cooldowns
            double avgChampLevel = ItemCooldownController.GetAverageChampionLevel(this.gameState);

            // note: this assumes the program is run BEFORE the game starts, or else it won't be very accurate.
            ItemCooldownController.SetCooldown(OracleLensModule.ITEM_ID, OracleLensModule.GetCooldownDuration(avgChampLevel));
            ItemCooldownController.SetCooldown(FarsightAlterationModule.ITEM_ID, FarsightAlterationModule.GetCooldownDuration(avgChampLevel));

            // Load champion module. Different modules will be loaded depending on the champion.
            // If there is no suitable module for the selected champion, just the health bar will be displayed.

            string champName = gameState.PlayerChampion.RawChampionName.ToLower();

            Type champType = ChampionControllers.FirstOrDefault(
                x => champName.ToLower()
                .Contains((x.GetCustomAttribute(typeof(ChampionAttribute)) as ChampionAttribute)
                          .ChampionName.ToLower()));                    // find champion module

            if (champType != null)
            {
                championModule = champType.GetMethod("Create")
                                 .Invoke(null, new object[] { this.leds.Length, this.gameState, this.lightingMode, this.preferredCastMode })
                                 as ChampionModule;
                championModule.NewFrameReady        += OnNewFrameReceived;
                championModule.TriedToCastOutOfMana += OnAbilityCastNoMana;
            }
            CurrentLEDSource = championModule;

            // Sets up a task to always check for updated player info
            _ = Task.Run(async() =>
            {
                while (true)
                {
                    if (masterCancelToken.IsCancellationRequested)
                    {
                        return;
                    }
                    await QueryPlayerInfo();
                    await Task.Delay(150);
                }
            });

            // start frame timer
            _ = Task.Run(FrameTimer);
        }
Example #2
0
 /// <summary>
 /// Called when a key is pressed;
 /// </summary>
 private void OnKeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 'q')
     {
         if (qCastInProgress)
         {
             qCastInProgress = false;
             if (!rCastInProgress)
             {
                 animator.RunAnimationOnce(@"Animations/Vel'Koz/q_recast.txt");
             }
             StartCooldownTimer(AbilityKey.Q);
         }
         else if (CanCastAbility(AbilityKey.Q))
         {
             SelectedAbility = AbilityKey.Q;
         }
     }
     if (e.KeyChar == 'w')
     {
         if (CanCastAbility(AbilityKey.W))
         {
             SelectedAbility = AbilityKey.W;
         }
     }
     if (e.KeyChar == 'e')
     {
         if (CanCastAbility(AbilityKey.E))
         {
             SelectedAbility = AbilityKey.E;
         }
     }
     if (e.KeyChar == 'r')
     {
         if (rCastInProgress)
         {
             animator.StopCurrentAnimation();
             rCastInProgress = false;
             StartCooldownTimer(AbilityKey.R);
         }
         else
         {
             if (CanCastAbility(AbilityKey.R))
             {
                 animator.StopCurrentAnimation();
                 animator.RunAnimationInLoop(@"Animations/Vel'Koz/r_loop.txt", 2300, 0.15f);
                 rCastInProgress = true;
                 Task.Run(async() =>
                 {
                     await Task.Delay(2300);
                     if (rCastInProgress)
                     {
                         StartCooldownTimer(AbilityKey.R);
                         rCastInProgress = false;
                     }
                 });
             }
         }
     }
     if (e.KeyChar == 'f') // TODO: Refactor this into LeagueOfLegendsModule, or a new SummonerSpells module. Also take cooldown into consideration.
     {
         animator.ColorBurst(HSVColor.FromRGB(255, 237, 41), 0.1f);
     }
 }
 public void StopAnimations()
 {
     animator.StopCurrentAnimation();
 }