コード例 #1
0
ファイル: GameBrowserEntry.cs プロジェクト: garion30/FFBUnity
    public void SetMatchDetails(Current details)
    {
        if (details.teams.Count == 2)
        {
            Team t1 = details.teams[0];
            Team t2 = details.teams[1];
            matchDetails       = details;
            team1.text         = t1.name;
            team2.text         = t2.name;
            team1Score.text    = t1.score.ToString();
            team2Score.text    = t2.score.ToString();
            team1Info.text     = $"({t1.rating}) {t1.coach} TV {t1.tv / 1000}k {t1.race}";
            team2Info.text     = $"{t2.race} TV {t2.tv / 1000}k {t2.coach} ({t2.rating})";
            turnIndicator.text = $"h{details.half}t{details.turn}";

            float progress = (float)((((float)details.half - 1) * 8) + (float)details.turn) / 16f;
            progressBar.fillAmount = progress;

            FumbblApi.GetImage(t1.logo, team1Image);
            FumbblApi.GetImage(t2.logo, team2Image);
        }
        else
        {
            Debug.LogError("Invalid number of teams found when parsing match details");
        }
    }
コード例 #2
0
ファイル: FFB.cs プロジェクト: rlegendi/FFBUnity
 private FFB()
 {
     Settings = new Settings();
     Settings.Load();
     SpriteCache        = new Lib.Cache <Sprite>(url => FumbblApi.GetSpriteAsync(url));
     LogText            = new List <Report>();
     ChatText           = new List <ChatEntry>();
     Network            = new Networking();
     Model              = new Core();
     Api                = new FumbblApi();
     CommandFactory     = new ReflectedFactory <CommandHandler <NetCommand>, Type>();
     ReportFactory      = new ReflectedFactory <Report, string>();
     ModelChangeFactory = new ReflectedFactory <ModelChange, string>();
 }
コード例 #3
0
ファイル: GameBrowserEntry.cs プロジェクト: rlegendi/FFBUnity
    public void SetMatchDetails(Current details, System.Collections.Generic.HashSet <string> friends)
    {
        if (details.teams.Count == 2)
        {
            Team t1 = details.teams[0];
            Team t2 = details.teams[1];
            matchDetails = details;
            team1.text   = t1.name;
            team2.text   = t2.name;

            var coach1 = TextPanelHandler.SanitizeText(t1.coach);
            var coach2 = TextPanelHandler.SanitizeText(t2.coach);

            if (friends.Contains(t1.coach))
            {
                coach1 = $"<#00F324>{coach1}</color>";
            }
            if (friends.Contains(t2.coach))
            {
                coach2 = $"<#00F324>{coach2}</color>";
            }

            team1Score.text    = t1.score.ToString();
            team2Score.text    = t2.score.ToString();
            team1Info.text     = $"({t1.rating}) {coach1} TV {t1.tv / 1000}k {t1.race}";
            team2Info.text     = $"{t2.race} TV {t2.tv / 1000}k {coach2} ({t2.rating})";
            turnIndicator.text = $"h{details.half}t{details.turn}";

            float progress = (float)((((float)details.half - 1) * 8) + (float)details.turn) / 16f;
            progressBar.fillAmount = progress;

            FumbblApi.GetImage(t1.logolarge, team1Image);
            FumbblApi.GetImage(t2.logolarge, team2Image);
        }
        else
        {
            LogManager.Error("Invalid number of teams found when parsing match details");
        }
    }
コード例 #4
0
    private async void Start()
    {
        Matches = new ViewObjectList <BrowserRecord>(
            r =>
        {
            GameObject newButton = Instantiate(button);
            newButton.transform.SetParent(pane.transform, false);

            var div = r.Record.division;
            // Find position of new game
            bool foundSection = false;
            int position      = -1;
            for (int i = 0; i < pane.transform.childCount; i++)
            {
                var currentMatch = pane.transform.GetChild(i).GetComponent <GameBrowserEntry>()?.matchDetails;

                if (currentMatch != null)
                {
                    if (!foundSection)
                    {
                        if (string.Equals(currentMatch.division, div))
                        {
                            foundSection = true;
                        }
                    }
                    else
                    {
                        if (!string.Equals(currentMatch.division, div))
                        {
                            position = i;
                            break;
                        }
                    }
                }
                else
                {
                    // This is a division divider
                    if (foundSection)
                    {
                        position = i;
                        break;
                    }
                }
            }
            if (position >= 0)
            {
                newButton.transform.SetSiblingIndex(position);
            }
            else if (!foundSection)
            {
                GameObject divider = Instantiate(this.divider);
                divider.transform.SetParent(pane.transform, false);
                divider.transform.SetSiblingIndex(pane.transform.childCount - 2);
                divider.transform.GetChild(1).gameObject.GetComponent <TMPro.TextMeshProUGUI>().text = div;
            }

            newButton.GetComponent <GameBrowserEntry>().SetMatchDetails(r.Record, Friends);
            return(newButton);
        },
            r =>
        {
            r.GameObject.GetComponent <GameBrowserEntry>().SetMatchDetails(r.ModelObject.Record, Friends);
        },
            r =>
        {
            Destroy(r.GameObject);
        }
            );

        LogManager.Debug("Initialise Game Browser");
        api = FFB.Instance.Api;
        RefreshMatches();
        gameIdInputField.onValidateInput += (text, charIndex, addedChar) =>
        {
            if (addedChar < '0' || addedChar > '9')
            {
                return('\0');
            }
            return(addedChar);
        };

        Friends = await LoadFriends();

        InvokeRepeating("RefreshMatches", 3f, 3f);
    }
コード例 #5
0
 void Start()
 {
     Debug.Log("Initialise Game Browser");
     api = new FumbblApi();
     RefreshMatches();
 }