コード例 #1
0
    void HandleScores(Dictionary <PlayerData, ScoreData> serverScores)
    {
        var scores = new GameFinalScores(serverScores, x => x.Score);
        var likes  = new GameFinalScores(serverScores, x => x.Likes);

        // Show values on UI
        View.Show(scores, likes);
    }
コード例 #2
0
    void HandleScores(Dictionary<PlayerData, ScoreData> serverScores)
    {
        var scores = new GameFinalScores(serverScores, x => x.Score);
        var likes = new GameFinalScores(serverScores, x => x.Likes);

        // Show values on UI
        View.Show(scores, likes);
    }
コード例 #3
0
ファイル: UiMostLikes.cs プロジェクト: Trainfire/Drawesome
    public void Show(GameFinalScores likes)
    {
        var mostLikes = likes.Values.Aggregate((current, next) => next.Key > current.Key ? next : current);

        var view = UiUtility.AddChild(Rows, RowPrototype, true);
        view.Name.text = string.Join(", ", likes.GetPlayerNames(mostLikes.Key));
        view.Points.text = mostLikes.Key.ToString();

        var animController = gameObject.GetOrAddComponent<UiAnimationController>();
        gameObject.SetActive(true);
        animController.AddAnim(new UiAnimationFade(gameObject, 0.25f, UiAnimationFade.FadeType.In));
        animController.PlayAnimations();
    }
コード例 #4
0
    public void Show(GameFinalScores scores, GameFinalScores likes)
    {
        var animController = gameObject.GetOrAddComponent <UiAnimationController>();

        var views = new List <UiFinalScoreRow>();

        // Add rows
        foreach (var score in scores.Values.Take(3).ToList())
        {
            var instance = UiUtility.AddChild(RowContainer, RowProtoype, true);

            instance.PlayerName.text = string.Join(", ", scores.GetPlayerNames(score.Key));
            instance.Points.text     = score.Key.ToString();

            views.Add(instance);
        }

        // Reverse order so it plays out from 3rd to 1st
        views.Reverse();

        // Show rows
        for (int i = 0; i < views.Count; i++)
        {
            views[i].Position.text = (views.Count - i).ToString();

            var delay = i == (views.Count - 1) ? TimeBeforeFirst : TimeBetweenPlayers;

            animController.AddDelay(delay);

            animController.AddAnim(new UiAnimationFade(views[i].gameObject, 0.2f, UiAnimationFade.FadeType.In), false);

            // If showing final player...
            if (i == (views.Count - 1))
            {
                views[i].Position.text = Strings.Winner;
                animController.AddAnim(new UiAnimationScale(views[i].gameObject, Vector3.one * 5, Vector3.one, 0.5f));
            }
        }

        // Show likes if any were made
        if (likes.Values.Any(x => x.Key != 0))
        {
            animController.AddDelay(TimeBeforeMostLikes);
            animController.AddAction("Show Most Likes", () => MostLikes.Show(likes));
        }

        animController.AddDelay(TimeBeforeShowButton);
        animController.AddAnim(new UiAnimationFade(StartNewGame.gameObject, 0.2f, UiAnimationFade.FadeType.In));

        animController.PlayAnimations();
    }
コード例 #5
0
    public void Show(GameFinalScores scores, GameFinalScores likes)
    {
        var animController = gameObject.GetOrAddComponent<UiAnimationController>();

        var views = new List<UiFinalScoreRow>();

        // Add rows
        foreach (var score in scores.Values.Take(3).ToList())
        {
            var instance = UiUtility.AddChild(RowContainer, RowProtoype, true);

            instance.PlayerName.text = string.Join(", ", scores.GetPlayerNames(score.Key));
            instance.Points.text = score.Key.ToString();

            views.Add(instance);
        }

        // Reverse order so it plays out from 3rd to 1st
        views.Reverse();

        // Show rows
        for (int i = 0; i < views.Count; i++)
        {
            views[i].Position.text = (views.Count - i).ToString();

            var delay = i == (views.Count - 1) ? TimeBeforeFirst : TimeBetweenPlayers;

            animController.AddDelay(delay);

            animController.AddAnim(new UiAnimationFade(views[i].gameObject, 0.2f, UiAnimationFade.FadeType.In), false);

            // If showing final player...
            if (i == (views.Count - 1))
            {
                views[i].Position.text = Strings.Winner;
                animController.AddAnim(new UiAnimationScale(views[i].gameObject, Vector3.one * 5, Vector3.one, 0.5f));
            }
        }

        // Show likes if any were made
        if (likes.Values.Any(x => x.Key != 0))
        {
            animController.AddDelay(TimeBeforeMostLikes);
            animController.AddAction("Show Most Likes", () => MostLikes.Show(likes));
        }

        animController.AddDelay(TimeBeforeShowButton);
        animController.AddAnim(new UiAnimationFade(StartNewGame.gameObject, 0.2f, UiAnimationFade.FadeType.In));

        animController.PlayAnimations();
    }
コード例 #6
0
    protected override void OnMessage(string json)
    {
        Message.IsType<ServerMessage.Game.SendScores>(json, (data) =>
        {
            // Make dictionary mapping players to scores.
            var dict = Enumerable.Range(0, data.Players.Count)
            .ToDictionary(i => data.Players[i], i => data.Scores[i]);

            // Tier players with identical scores and likes
            var scores = new GameFinalScores(dict, x => x.Score);
            var likes = new GameFinalScores(dict, x => x.Likes);

            GetView<UiGameStateFinalScores>().Show(scores, likes);
        });
    }
コード例 #7
0
    protected override void OnMessage(string json)
    {
        Message.IsType <ServerMessage.Game.SendScores>(json, (data) =>
        {
            // Make dictionary mapping players to scores.
            var dict = Enumerable.Range(0, data.Players.Count)
                       .ToDictionary(i => data.Players[i], i => data.Scores[i]);

            // Tier players with identical scores and likes
            var scores = new GameFinalScores(dict, x => x.Score);
            var likes  = new GameFinalScores(dict, x => x.Likes);

            GetView <UiGameStateFinalScores>().Show(scores, likes);
        });
    }
コード例 #8
0
    public void Show(GameFinalScores likes)
    {
        var mostLikes = likes.Values.Aggregate((current, next) => next.Key > current.Key ? next : current);

        var view = UiUtility.AddChild(Rows, RowPrototype, true);

        view.Name.text   = string.Join(", ", likes.GetPlayerNames(mostLikes.Key));
        view.Points.text = mostLikes.Key.ToString();

        var animController = gameObject.GetOrAddComponent <UiAnimationController>();

        gameObject.SetActive(true);
        animController.AddAnim(new UiAnimationFade(gameObject, 0.25f, UiAnimationFade.FadeType.In));
        animController.PlayAnimations();
    }