コード例 #1
0
    private void Start()
    {
        if (leaderboard == null)
        {
            return;
        }

        float delay = 0.6f;
        int   index = 0;

        solver = leaderboard.SoloSolver;

        IEnumerable <Leaderboard.LeaderboardEntry> entries = (solver == null) ?
                                                             leaderboard.GetSortedSoloEntries(maximumRowCount) :
                                                             leaderboard.GetSortedSoloEntriesIncluding(solver.UserName, maximumRowCount);

        foreach (Leaderboard.LeaderboardEntry entry in entries)
        {
            TwitchLeaderboardSoloRow row = Instantiate <TwitchLeaderboardSoloRow>(index < specialRows.Length ? specialRows[index] : normalRow);

            row.position         = entry.SoloRank;
            row.leaderboardEntry = entry;
            row.delay            = delay;
            row.transform.SetParent(tableTransform, false);

            _instancedRows.Add(row);

            delay += 0.1f;
            index++;
        }
    }
コード例 #2
0
 protected override void OnMessageReceived(string userNickName, string userColorCode, string text)
 {
     if (text.Equals("!cancel", StringComparison.InvariantCultureIgnoreCase))
     {
         _coroutineCanceller.SetCancel();
         return;
     }
     else if (text.Equals("!stop", StringComparison.InvariantCultureIgnoreCase))
     {
         _coroutineCanceller.SetCancel();
         _coroutineQueue.CancelFutureSubcoroutines();
         return;
     }
     else if (text.Equals("!manual", StringComparison.InvariantCultureIgnoreCase))
     {
         _ircConnection.SendMessage(string.Format("!{0} manual [link to module {0}'s manual] | Go to {1} to get the vanilla manual for KTaNE", UnityEngine.Random.Range(1, 100), TwitchPlaysService.urlHelper.VanillaManual));
         return;
     }
     else if (text.Equals("!help", StringComparison.InvariantCultureIgnoreCase))
     {
         _ircConnection.SendMessage(string.Format("!{0} help [commands for module {0}] | Go to {1} to get the command reference for TP:KTaNE (multiple pages, see the menu on the right)", UnityEngine.Random.Range(1, 100), TwitchPlaysService.urlHelper.CommandReference));
         return;
     }
     else if (text.StartsWith("!rank", StringComparison.InvariantCultureIgnoreCase))
     {
         Leaderboard.LeaderboardEntry entry = null;
         if (text.Length > 6)
         {
             string[] parts = text.Split(' ');
             int      desiredRank;
             if (parts[1].Equals("solo", StringComparison.InvariantCultureIgnoreCase) && int.TryParse(parts[2], out desiredRank))
             {
                 leaderboard.GetSoloRank(desiredRank, out entry);
             }
             else if (int.TryParse(parts[1], out desiredRank))
             {
                 leaderboard.GetRank(desiredRank, out entry);
             }
             else
             {
                 return;
             }
             if (entry == null)
             {
                 _ircConnection.SendMessage("Nobody here with that rank!");
                 return;
             }
         }
         if (entry == null)
         {
             leaderboard.GetRank(userNickName, out entry);
         }
         if (entry != null)
         {
             string txtSolver = "";
             string txtSolo   = ".";
             if (entry.TotalSoloClears > 0)
             {
                 TimeSpan recordTimeSpan = TimeSpan.FromSeconds(entry.RecordSoloTime);
                 txtSolver = "solver ";
                 txtSolo   = string.Format(", and #{0} solo with a best time of {1}:{2:00.0}", entry.SoloRank, (int)recordTimeSpan.TotalMinutes, recordTimeSpan.Seconds);
             }
             _ircConnection.SendMessage(string.Format("SeemsGood {0} is #{1} {4}with {2} solves and {3} strikes{5}", entry.UserName, entry.Rank, entry.SolveCount, entry.StrikeCount, txtSolver, txtSolo));
         }
         else
         {
             _ircConnection.SendMessage(string.Format("FailFish {0}, do you even play this game?", userNickName));
         }
         return;
     }
     else if ((text.Equals("!log", StringComparison.InvariantCultureIgnoreCase)) ||
              (text.Equals("!analysis", StringComparison.InvariantCultureIgnoreCase)))
     {
         TwitchPlaysService.logUploader.PostToChat("Analysis for the previous bomb: {0}");
         return;
     }
     else if (text.Equals("!shorturl", StringComparison.InvariantCultureIgnoreCase))
     {
         _ircConnection.SendMessage(
             (TwitchPlaysService.urlHelper.ToggleMode()) ?
             "Enabling shortened URLs" :
             "Disabling shortened URLs"
             );
     }
     else if (text.Equals("!about", StringComparison.InvariantCultureIgnoreCase))
     {
         _ircConnection.SendMessage("Twitch Plays: KTaNE is an alternative way of playing !ktane. Unlike the original game, you play as both defuser and expert, and defuse the bomb by sending special commands to the chat room. Try !help for more information!");
         return;
     }
     else if (text.Equals("!ktane", StringComparison.InvariantCultureIgnoreCase))
     {
         _ircConnection.SendMessage("Keep Talking and Nobody Explodes is developed by Steel Crate Games. It's available for Windows PC, Mac OS X, PlayStation VR, Samsung Gear VR and Google Daydream. See http://www.keeptalkinggame.com/ for more information!");
         return;
     }
 }
コード例 #3
0
    protected override void OnMessageReceived(string userNickName, string userColorCode, string text)
    {
        if (!text.StartsWith("!") || text.Equals("!"))
        {
            return;
        }
        text = text.Substring(1);

        string[] split     = text.ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        string   textAfter = split.Skip(1).Join();

        if (text.Equals("cancel", StringComparison.InvariantCultureIgnoreCase))
        {
            if (!IsAuthorizedDefuser(userNickName))
            {
                return;
            }
            _coroutineCanceller.SetCancel();
            return;
        }
        else if (text.Equals("stop", StringComparison.InvariantCultureIgnoreCase))
        {
            if (!IsAuthorizedDefuser(userNickName))
            {
                return;
            }
            _coroutineCanceller.SetCancel();
            _coroutineQueue.CancelFutureSubcoroutines();
            return;
        }
        else if (text.Equals("manual", StringComparison.InvariantCultureIgnoreCase) ||
                 text.Equals("help", StringComparison.InvariantCultureIgnoreCase))
        {
            _ircConnection.SendMessage("!{0} manual [link to module {0}'s manual] | Go to {1} to get the vanilla manual for KTaNE", UnityEngine.Random.Range(1, 100), TwitchPlaysService.urlHelper.VanillaManual);
            _ircConnection.SendMessage("!{0} help [commands for module {0}] | Go to {1} to get the command reference for TP:KTaNE (multiple pages, see the menu on the right)", UnityEngine.Random.Range(1, 100), TwitchPlaysService.urlHelper.CommandReference);
            return;
        }
        else if (text.StartsWith("bonusscore", StringComparison.InvariantCultureIgnoreCase))
        {
            if (!IsAuthorizedDefuser(userNickName))
            {
                return;
            }
            if (split.Length < 3)
            {
                return;
            }
            string playerrewarded = split[1];
            if (!int.TryParse(split[2], out int scorerewarded))
            {
                return;
            }
            if (UserAccess.HasAccess(userNickName, AccessLevel.SuperUser, true))
            {
                _ircConnection.SendMessage(TwitchPlaySettings.data.GiveBonusPoints, split[1], split[2], userNickName);
                Color usedColor = new Color(.31f, .31f, .31f);
                leaderboard.AddScore(playerrewarded, usedColor, scorerewarded);
            }
            return;
        }
        else if (text.StartsWith("reward", StringComparison.InvariantCultureIgnoreCase))
        {
            if (!IsAuthorizedDefuser(userNickName))
            {
                return;
            }
            if (UserAccess.HasAccess(userNickName, AccessLevel.SuperUser, true))
            {
                moduleCountBonus = Int32.Parse(split[1]);
                TwitchPlaySettings.SetRewardBonus(moduleCountBonus);
            }
        }
        else if (text.Equals("timemode", StringComparison.InvariantCultureIgnoreCase))
        {
            if (UserAccess.HasAccess(userNickName, AccessLevel.Mod, true))
            {
                OtherModes.toggleTimedMode();
                _ircConnection.SendMessage(OtherModes.timedModeCheck() ? "Time Mode Enabled" : "Time Mode Disabled");
            }
        }
        else if (text.StartsWith("rank", StringComparison.InvariantCultureIgnoreCase))
        {
            Leaderboard.LeaderboardEntry entry = null;
            if (split.Length > 1)
            {
                int desiredRank;
                switch (split.Length)
                {
                case 3 when split[1].Equals("solo", StringComparison.InvariantCultureIgnoreCase) && int.TryParse(split[2], out desiredRank):