コード例 #1
0
        private void Subscribe()
        {
            try
            {
                if (Client != null && Client.IsRunning)
                {
                    Client.ReconnectionHappened.Subscribe(type =>
                    {
                        Debug.WriteLine($"Reconnection happened, type: {type}, url: {Client.Url}");
                    });

                    Client.DisconnectionHappened.Subscribe(info =>
                    {
                        Debug.WriteLine($"Disconnection happened, type: {info.Type}");
                    });

                    Client.MessageReceived.Subscribe(msg =>
                    {
                        Debug.WriteLine($"Message received: {msg}");
                        var jObject = JObject.Parse(msg.Text);
                        if ((string)jObject["type"] == "MESSAGE" && jObject["data"] != null)
                        {
                            var newReward = JsonParser.ParseReward(((string)jObject["data"]["message"]).Replace('\\', Char.MinValue));
                            OnReward?.Invoke("twitch", newReward);
                        }
                    });
                }
            }
            catch { }
        }
コード例 #2
0
ファイル: AdButton.cs プロジェクト: stencil-ltd/Stencil-Ads
 private void _OnResult(bool obj)
 {
     OnResult?.Invoke(obj);
     if (obj && Reward.Currency != null)
     {
         Reward.Receive().AndSave();
         OnReward?.Invoke(this, Reward);
     }
 }
コード例 #3
0
        public byte Reward(byte OrbId, Keys victim)
        {
            byte temp;

            lock (MVP.RecordsLock) {
                lock (lock_reward) {
                    if (killed.Contains(victim) || HEADS[victim].Died)
                    {
                        return(0);
                    }
                    else if (!KingOfTheHill)
                    {
                        killed.Add(victim);
                    }

                    if (ChaosMode && Leader == victim)
                    {
                        Leader = this.KeyCode;
                    }

                    OnReward?.Invoke();
                    temp = this.Points;
                    Kills++;
                    this.Points += KingOfTheHill? (byte)1 : Kills;
                    if (HEADS[victim].isBounty)
                    {
                        this.Points++;
                    }
                    if (HEADS[victim].isDoubleBounty)
                    {
                        this.Points++;
                    }
                    this.Points += Orb.All[OrbId].KillStreak++;
                    key.Add(this.Points - temp);
                    key.points = Points;

                    if (Orb.All[OrbId].KillStreak > 1)
                    {
                        if (KingOfTheHill)
                        {
                            MVP.Flash("Collateral!");
                        }
                        else
                        {
                            MVP.Add(MVPTypes.COLLATERAL, DisplayKey, Orb.All[OrbId].KillStreak.ToString());
                        }
                    }

                    if (Died)
                    {
                        if (KingOfTheHill)
                        {
                            MVP.Flash("GhostKill!");
                        }
                        else
                        {
                            MVP.Add(MVPTypes.GHOSTKILL, DisplayKey);
                        }
                    }
                }
            }

            if (KingOfTheHill)
            {
                Map.Sort();
                IKey.UpdateAll();
                bool leader = true;
                int  second = 0;

                lock (ActiveLock)
                    foreach (Head head in HEADS.Values)
                    {
                        if (head.KeyCode == KeyCode)
                        {
                            continue;
                        }
                        if (this.Points < head.Points)
                        {
                            leader = false;
                        }
                        if (second < head.Points)
                        {
                            second = head.Points;
                        }
                    }

                if (leader)
                {
                    Leader = this.KeyCode;
                }

                if (this.Points >= Map.MaxPoints && Points - second > 1 && Map.phase != Phases.ENDGAME)
                {
                    MVP.Show(MVP.WinMessage(this.DisplayKey));
                    new Thread(Map.EndGame).Start();
                }
                else if (Kills >= 5 && !isBounty)
                {
                    MVP.Flash($"{DisplayKey} killstreak");
                    this.isBounty = true;
                }
                else if (this.Points >= Map.MaxPoints - 1 && !isBounty)
                {
                    this.isBounty = true;
                    MVP.Flash("Matchpoint!");
                }

                else if (isBounty && Kills >= 5 && this.Points >= Map.MaxPoints - 1 && !isDoubleBounty)
                {
                    MVP.Flash("Double Bounty!");
                    this.isDoubleBounty = true;
                }
            }
            return((byte)(Points - temp));
        }