예제 #1
0
 protected virtual void OnFirstBlood(LeagueEventArgs args) => FirstBlood?.Invoke(this, args);
예제 #2
0
 protected virtual void OnGameEnd(LeagueEventArgs args) => GameEnd?.Invoke(this, args);
예제 #3
0
 protected virtual void OnMultiKill(LeagueEventArgs args) => MultiKill?.Invoke(this, args);
예제 #4
0
 protected virtual void OnAce(LeagueEventArgs args) => Ace?.Invoke(this, args);
예제 #5
0
 protected virtual void OnBaronKill(LeagueEventArgs args) => BaronKill?.Invoke(this, args);
예제 #6
0
 protected virtual void OnChampionKill(LeagueEventArgs args) => ChampionKill?.Invoke(this, args);
예제 #7
0
 protected virtual void OnInhibKill(LeagueEventArgs args) => InhibKill?.Invoke(this, args);
예제 #8
0
 protected virtual void OnHeraldKill(LeagueEventArgs args) => HeraldKill?.Invoke(this, args);
예제 #9
0
 protected virtual void OnTurretKill(LeagueEventArgs args) => TurretKill?.Invoke(this, args);
예제 #10
0
 protected virtual void OnMinionsFirstSpawn(LeagueEventArgs args) => MinionsFirstSpawn?.Invoke(this, args);
예제 #11
0
 protected virtual void OnGameStart(LeagueEventArgs args) => GameStart?.Invoke(this, args);
예제 #12
0
 protected virtual void OnLeagueEventHappened(LeagueEventArgs args) => LeagueEventHappened?.Invoke(this, args);
예제 #13
0
        private async void ListenLeagueEvent(object sender, DoWorkEventArgs e)
        {
            while (!workerLeagueEvent.CancellationPending)
            {
                Task endLoop = Task.Delay(delayLeagueEvent);

                LeagueEvent leagueEvent = await api.GetLastEvent();

                if (leagueEvent != null && leagueEvent.id != lastLeagueEventIndex)
                {
                    int thisEventIndex = leagueEvent.id;
                    //If only one event has happened since the last check.
                    if (thisEventIndex == lastLeagueEventIndex + 1)
                    {
                        RaiseEvent(leagueEvent);
                    }
                    //If more than one event happened since the last check, get all events and trigger all events from [last + 1] until the last one.
                    else
                    {
                        LeagueEvent[] allGameEvents = await api.GetEvents();

                        for (int i = lastLeagueEventIndex + 1; i <= thisEventIndex; i++)
                        {
                            RaiseEvent(allGameEvents[i]);
                        }
                    }

                    lastLeagueEventIndex = leagueEvent.id;
                }

                await endLoop;
            }

            void RaiseEvent(LeagueEvent thisEvent)
            {
                LeagueEventArgs args = new LeagueEventArgs(thisEvent);

                OnLeagueEventHappened(args);
                if (thisEvent is Event_GameStart)
                {
                    OnGameStart(args);
                }
                else if (thisEvent is Event_MinionsFirstSpawn)
                {
                    OnMinionsFirstSpawn(args);
                }
                else if (thisEvent is Event_FirstTurretKill)
                {
                    OnFirstTurretKill(args);
                }
                else if (thisEvent is Event_TurretKill)
                {
                    OnTurretKill(args);
                }
                else if (thisEvent is Event_InhibKill)
                {
                    OnInhibKill(args);
                }
                else if (thisEvent is Event_DragonKill)
                {
                    OnDragonKill(args);
                }
                else if (thisEvent is Event_HeraldKill)
                {
                    OnHeraldKill(args);
                }
                else if (thisEvent is Event_BaronKill)
                {
                    OnBaronKill(args);
                }
                else if (thisEvent is Event_ChampionKill)
                {
                    OnChampionKill(args);
                }
                else if (thisEvent is Event_MultiKill)
                {
                    OnMultiKill(args);
                }
                else if (thisEvent is Event_Ace)
                {
                    OnAce(args);
                }
                else if (thisEvent is Event_FirstBlood)
                {
                    OnFirstBlood(args);
                }
                else if (thisEvent is Event_GameEnd)
                {
                    OnGameEnd(args);
                }
            }
        }