예제 #1
0
 protected override void OnDisappearing()
 {
     isExit = true;
     NetProcess.SendLeaveRoom(0);
 }
예제 #2
0
        public Room()
        {
            InitializeComponent();

            if (User.IsEnableScreenChat == true)
            {
                Chatting.IsEnabled = true;
            }

            InitTimer();

            _ai._renderer = _renderer;

            renjuRuleChecker.initBoard();

            InitBoardGrid();

            if (User.Auto == true)
            {
                User.myInfo.ai_reset_flag = true;

                if (User.Color == eTeam.Black)
                {
                    Thread.Sleep(1000);
                }
            }

            Button PrevBtn = new Button {
                Text = "◁", HorizontalOptions = LayoutOptions.Start
            };

            PrevBtn.Clicked += (sender, e) => {
                Navigation.PopModalAsync();
            };

            ProgressRoom.Progress = 0.0f;

            timeLabel.IsEnabled = true;
            timeLabel.Text      = "00";

            rewardVideo = DependencyService.Get <iAd_RewardVideoView>();

            Device.StartTimer(TimeSpan.FromSeconds(1), () =>
            {
                try
                {
                    if (User.IsMyTurn == true)
                    {
                        var current           = ((DateTime.Now - User.MytrunStartTime).TotalSeconds * 0.033);
                        ProgressRoom.Progress = current;

                        int remainseconds = 30 - (int)((DateTime.Now - User.MytrunStartTime).TotalSeconds);
                        if (remainseconds < 0)
                        {
                            remainseconds = 0;
                        }

                        Device.BeginInvokeOnMainThread(() =>
                        {
                            timeLabel.Text = remainseconds.ToString();
                        });

                        //   DependencyService.Get<Toast>().Show(timeLabel.Text);

                        //   ToastNotification.TostMessage(timeLabel.Text);

                        if ((DateTime.Now - User.MytrunStartTime).TotalSeconds > 30)
                        {
                            if (User.Auto == true)
                            {
                                NetProcess.SendLeaveRoom(0);
                            }
                            else
                            {
                                NetProcess.SendPassThroughMessage(-1, -1, User.Color);
                            }
                        }
                    }

                    if (debug > 90)
                    {
                        NetProcess.SendLeaveRoom(0);
                    }


                    ///////////////////////////////////////////////////////////////////
                    if (User.myInfo.ai_reset_flag == true)
                    {
                        //흑ai
                        if (User.Color == eTeam.Black)
                        {
                            User.myInfo.ai_rule = 3;
                            User.myInfo.ai_mode = 1;
                        }
                        else //백ai
                        {
                            User.myInfo.ai_rule = 3;
                            User.myInfo.ai_mode = 2;
                        }

                        Device.BeginInvokeOnMainThread(() =>
                        {
                            _ai.PlayGame(User.myInfo.ai_rule, User.myInfo.ai_mode, true);
                            isPlaying = true;
                            User.myInfo.ai_reset_flag = false;

                            UpdateBattleInfo();
                        });
                    }

                    if (isPlaying == true)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            isPlaying = _ai.PlaygameLoop(this, User.myInfo.ai_mode, true);
                        });

                        if (isPlaying == false) //종료
                        {
                            isPlaying = false;
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }


                return(!isExit);
            });


            MessagingCenter.Subscribe <Room>(this, "close", (sender) =>
            {
                NetProcess.SendLeaveRoom(0);
            });

            //언어 수동 변환
            if (User.Locale != "ko")
            {
                LeaveRoom.Text = "Exit";

                LeftButton.Text  = "Left";
                UPButton.Text    = "Up";
                Clicked.Text     = "Stone";
                DownButton.Text  = "Down";
                RightButton.Text = "Right";

                black.Text = "Black";
                white.Text = "White";
            }
        }
예제 #3
0
 public void SendLeaveRoom()
 {
     NetProcess.SendLeaveRoom(0);
 }