Example #1
0
        public override void RefreshPlayer(PlayerViewModel viewModel)
        {
            base.RefreshPlayer(viewModel);

            if (viewModel.IsSelf == false)
            {
                // ready 按钮
                bool is_ready = false;
                if (viewModel.LBPlayer.CustomProperties.ContainsKey("is_ready"))
                {
                    is_ready = Convert.ToBoolean(viewModel.LBPlayer.CustomProperties ["is_ready"]);
                }
                if (is_ready && viewModel.Status is Ready == false)
                {
                    viewModel.ExecutePlayerReady();
                }
                else if (is_ready == false && viewModel.Status is Wait == false)
                {
                    viewModel.ExecutePlayerCancel();
                }
            }

            // turn
            object my_turn = false;

            if (viewModel.LBPlayer.CustomProperties.TryGetValue("my_turn", out my_turn))
            {
                if (viewModel.Status is MatchDeal && Convert.ToBoolean(my_turn) == false)
                {
                    object is_win = false;
                    if (viewModel.LBPlayer.CustomProperties.TryGetValue("is_win", out is_win))
                    {
                        if (Convert.ToBoolean(is_win))
                        {
                            viewModel.ExecuteWin();
                            CoreGameRoot.ExecuteRefreshSummaryPlayersList();
                        }
                        else
                        {
                            viewModel.ExecuteTurnOff();
                        }
                    }
                }
                else if (viewModel.Status is MatchIdle && Convert.ToBoolean(my_turn))
                {
                    viewModel.ExecuteTurnOn();
                }
            }
        }
Example #2
0
        public override void ButtonReadyClicked(PlayerViewModel viewModel)
        {
            base.ButtonReadyClicked(viewModel);

            if (viewModel.Status is Wait || viewModel.Status is Init || viewModel.Status is MatchOver)
            {
                viewModel.ExecutePlayerReady();
            }
            else if (viewModel.Status is Ready)
            {
                viewModel.ExecutePlayerCancel();
            }

            viewModel.ExecuteRefreshPlayer();
        }