public async Task <IActionResult> Index()
        {
            LeaderboardProxy proxy = new LeaderboardProxy(settings.Value.LeaderboardWebApiBaseUrl, logger);
            var leaderboard        = await proxy.GetLeaderboardAsync();

            return(View(leaderboard));
        }
Beispiel #2
0
        public void OnSuccess(LeaderboardProxy leaderboardProxy)
        {
            var msg = "get leader board data succeed. \n";

            msg += string.Format("leaderboard Id: {0}, display name: {1}, score order:{2}",
                                 leaderboardProxy.LeaderboardId, leaderboardProxy.LeaderboardDisplayName,
                                 leaderboardProxy.LeaderboardScoreOrder);
            Show(msg);
        }
Beispiel #3
0
        public void StateUpdated(string serializedWordFromServer)
        {
            var state = JsonConvert.DeserializeObject <StateDTO>(serializedWordFromServer, new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.Auto
            });

            numSquaresX = state.Objects.GetLength(0);
            numSquaresY = state.Objects[0].Length;

            if (state.AlivePlayersIds.Count == 1 &&
                state.DeadPlayersIds.Count > 0 &&
                state.AlivePlayersIds.Any(alivePlayer => alivePlayer == Id))
            {
                this.winnerLabel.Visible   = true;
                this.buttonRestart.Visible = true;
            }
            else if (state.DeadPlayersIds.Any(deadPlayer => deadPlayer == Id))
            {
                this.textGameOver.Visible = true;
                if (state.AlivePlayersIds.Count == 1)
                {
                    this.buttonRestart.Visible = true;
                }
            }
            else
            {
                this.textGameOver.Visible  = false;
                this.buttonRestart.Visible = false;
                this.winnerLabel.Visible   = false;
            }

            //this.score.Text = $"Score: {state.PlayerScores.Where(playerScore => playerScore.Id == Id).Select(playerScore => playerScore.score).First().ToString()}";
            var proxy = new LeaderboardProxy {
                Id = Id, _realLeaderboard = state.PlayerScores
            };

            score.Text = BuildLeaderBoard(proxy.GetLeaderBoard());

            img      = new Bitmap(squareSize * numSquaresX, squareSize * numSquaresY);
            imgGraph = Graphics.FromImage(img);

            world = state.Objects;
            Draw();
        }