Beispiel #1
0
 private void CountDownTimer_Tick(object sender, EventArgs e)
 {
     if (CountDown >= 120)
     {
         CountDownTimer.Stop();
         Tijd.Text = " BETS CLOSED  0:00";
     }
     else
     {
         string seconde;
         CountDown++;
         int huidigtijd = 120 - CountDown;
         int min        = huidigtijd / 60;
         int sec        = huidigtijd - (60 * min);
         if (sec < 10)
         {
             seconde = "0" + Convert.ToString(sec);
         }
         else
         {
             seconde = Convert.ToString(sec);
         }
         string minuut = Convert.ToString(min);
         Tijd.Text = Convert.ToString("  BETS OPEN    " + minuut + ":" + seconde);
     }
 }
Beispiel #2
0
 private void CountDownTimer_Tick(object sender, EventArgs e)
 {
     if (PBCountDown.Maximum - 100 == PBCountDown.Value)
     {
         if (OPlayerCard.Count == 0)
         {
             CardChoose.Clear();
             CardChoose.Add(MyCard.First());
             tcpForPlayer.SendData("|" + MyCard.First().GetName());
             MyCard.Remove(MyCard.First());
             SeperateData(CardChoose, CardHavePlay);
             SeperateData(MyCard, CardButton);
         }
         else
         {
             tcpForPlayer.SendData("Skip");
         }
         yourturn    = false;
         label2.Text = "";
         CountDownTimer.Stop();
         PBCountDown.Value   = 0;
         PBCountDown.Visible = false;
     }
     else
     {
         PBCountDown.PerformStep();
     }
 }
Beispiel #3
0
 void bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     if (PBCountDown.Maximum == e.ProgressPercentage)
     {
         if (yourturn == true)
         {
             if (OPlayerCard.Count == 0)
             {
                 CardChoose.Clear();
                 CardChoose.Add(MyCard.First());
                 tcpForPlayer.SendData("|" + MyCard.First().GetName());
                 MyCard.Remove(MyCard.First());
                 SeperateData(CardChoose, CardHavePlay);
                 SeperateData(MyCard, CardButton);
             }
             else
             {
                 tcpForPlayer.SendData("Skip");
             }
             yourturn    = false;
             label2.Text = "";
             CountDownTimer.Stop();
             PBCountDown.Visible = false;
         }
     }
 }
Beispiel #4
0
 public void CloseCommunicationThread(object sender, FormClosedEventArgs e)
 {
     tcpForPlayer.SendData("Exit");
     if (t != null && t.IsAlive)
     {
         tcpForPlayer.CloseConnection();
         t.Abort();
     }
     CountDownTimer.Stop();
 }
Beispiel #5
0
        public void StopTimer()
        {
            _timer.Stop();
            IsPlaying = false;

            btnPlayPause.ImageMargin = new Padding(3, 0, 0, 0);
            btnPlayPause.Image       = Properties.Resources.Play_104px_4;

            lblCountdown.Text = "00:00:00";
            lblCountdown.Left = (Width - lblCountdown.Width) / 2;

            _alignedText = false;
        }
Beispiel #6
0
        private void onOffButton_Click(object sender, EventArgs e)
        {
            if (!start)
            {
                // Check
                if (timeTextBox.Text == "")
                {
                    MessageBox.Show("時間を入力して下さい"); return;
                }
                try
                {
                    interval = int.Parse(timeTextBox.Text);
                    if (!debug && interval < 5)
                    {
                        MessageBox.Show("5分以上にしてください");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("入力内容が正しくありません。\n" + ex.Message);
                    return;
                }
                // Enable
                onOffButton.Text        = "停止";
                processComboBox.Enabled = false;
                timeTextBox.Enabled     = false;
                // Timer Start
                timer1.Interval = interval * 60 * 1000;
                timer1.Start();
                // CountDown
                minLabel.Text = interval.ToString().PadLeft(2, '0'); secLabel.Text = "00";
                CountDownTimer.Start();

                start = true;
            }
            else
            {
                onOffButton.Text = "開始";
                timer1.Stop();
                CountDownTimer.Stop();
                start = false;
                timeTextBox.Enabled     = true;
                processComboBox.Enabled = true;
            }
        }
Beispiel #7
0
 private void btnPlay_click(object sender, EventArgs e)
 {
     if (yourturn == true)
     {
         PlayACard();
         bool CheckYourCard;
         if (OPlayerCard.Count == 0)
         {
             CheckYourCard = rule.Check(CardChoose);
         }
         else
         {
             CheckYourCard = rule.Check(CardChoose, OPlayerCard);
         }
         if (CheckYourCard)
         {
             string str = "";
             foreach (Card item in CardChoose)
             {
                 str += "|" + item.GetName();
                 MyCard.Remove(item);
             }
             tcpForPlayer.SendData(str);
             HideChosenCard();
             SeperateData(CardChoose, CardHavePlay);
             SeperateData(MyCard, CardButton);
             yourturn            = false;
             label2.Text         = "";
             PBCountDown.Visible = false;
             CountDownTimer.Stop();
         }
         else
         {
             MessageBox.Show("Cards Invalid");
             CardDown(CardButton);
         }
     }
     else
     {
         MessageBox.Show("not your turn");
         CardDown(CardButton);
     }
 }
Beispiel #8
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (yourturn == true)
     {
         if (OPlayerCard.Count == 0)
         {
             CardChoose.Clear();
             CardChoose.Add(MyCard.First());
             tcpForPlayer.SendData("|" + MyCard.First().GetName());
             MyCard.Remove(MyCard.First());
             SeperateData(CardChoose, CardHavePlay);
             SeperateData(MyCard, CardButton);
         }
         else
         {
             tcpForPlayer.SendData("Skip");
         }
         yourturn    = false;
         label2.Text = "";
         CountDownTimer.Stop();
         PBCountDown.Visible = false;
     }
     CardDown(CardButton);
 }
Beispiel #9
0
 private void button_ResetClock_Click(object sender, EventArgs e)
 {
     CDTimer.Stop();
     Init_CDTimer();
     Digit_clock.BackColor = Color.LightSteelBlue;
 }
Beispiel #10
0
 public void TearDown()
 {
     _uut.Stop();
 }
Beispiel #11
0
        public void Commmunication()
        {
            int rem = 0;

            string[] s;
            string[] OrderAndCard;
            while (true)
            {
                string str = tcpForPlayer.ReadData();
                s = str.Split('#');
                //MessageBox.Show(str);
                //Console.WriteLine(s);
                for (int z = 1; z < s.Length; z++)
                {
                    OrderAndCard = s[z].Split('|');
                    //for(int i=0;i<OrderAndCard.Length;i++)
                    //{
                    //    MessageBox.Show(OrderAndCard[i]);
                    //}
                    switch (OrderAndCard[0])
                    {
                    case "Init":
                        for (int i = 0; i < 4; i++)
                        {
                            if (OrderAndCard[i + 1] != tcpForPlayer.UpdateInformation())
                            {
                                for (int y = 0; y < 13; y++)
                                {
                                    Enemy[rem, y].Visible = true;
                                }
                                EnemyName[rem]     = OrderAndCard[i + 1];
                                EnemyCardLeft[rem] = 12;
                                rem++;
                            }
                        }
                        label3.Text = EnemyName[0];
                        label4.Text = EnemyName[1];
                        label5.Text = EnemyName[2];
                        break;

                    case "NewTurn":
                        label7.Text  = "";
                        label8.Text  = "";
                        label9.Text  = "";
                        label10.Text = "";
                        HideButton(CardHavePlay);
                        break;

                    case "Yourturn":
                        label6.Text = OrderAndCard[1] + "'s Turn";
                        if (OrderAndCard[1] == tcpForPlayer.UpdateInformation())
                        {
                            OPlayerCard.Clear();
                            for (int i = 2; i < OrderAndCard.Length; i++)
                            {
                                OPlayerCard.Add(new Card(OrderAndCard[i]));
                            }
                            yourturn            = true;
                            label2.Text         = "yourturn";
                            PBCountDown.Visible = true;
                            PBCountDown.Value   = 0;
                            BeginInvoke((Action)(() => CountDownTimer.Start()));
                        }
                        break;

                    case "Skip":
                        //MessageBox.Show("here");
                        //MessageBox.Show(s[z]);
                        if (OrderAndCard[1] == tcpForPlayer.UpdateInformation())
                        {
                            label10.Text = "Bo qua";
                            break;
                        }
                        for (int i = 0; i < 3; i++)
                        {
                            if (EnemyName[i] == OrderAndCard[1])
                            {
                                switch (i)
                                {
                                case 0:
                                    label7.Text = "Bo qua";
                                    break;

                                case 1:
                                    label8.Text = "Bo qua";
                                    break;

                                case 2:
                                    label9.Text = "Bo qua";
                                    break;
                                }
                                break;
                            }
                        }
                        break;

                    case "YourCard":
                        GetCard(OrderAndCard);
                        MyCard.Sort(compare);
                        SeperateData(MyCard, CardButton);
                        MatchForm();
                        break;

                    case "PlayerTurn":
                        SeperateData(OrderAndCard, CardHavePlay);
                        for (int i = 0; i < 3; i++)
                        {
                            if (EnemyName[i] == OrderAndCard[1])
                            {
                                //MessageBox.Show(s[z]);
                                //MessageBox.Show(EnemyCardLeft[i].ToString());
                                //MessageBox.Show((EnemyCardLeft[i] - OrderAndCard.Length ).ToString());
                                for (int y = EnemyCardLeft[i]; y > EnemyCardLeft[i] - OrderAndCard.Length + 2; y--)
                                {
                                    Enemy[i, y].Visible = false;
                                }
                                EnemyCardLeft[i] = EnemyCardLeft[i] - OrderAndCard.Count() + 2;
                                break;
                            }
                        }
                        break;

                    case "CreateRoomSuccessful":
                        MessageBox.Show("CreateRoomSuccessful");
                        ReadyForm();
                        label1.Visible = true;
                        label1.Text    = "Room: " + OrderAndCard[1];
                        break;

                    case "RoomFound":
                        MessageBox.Show("RoomFound");
                        ReadyForm();
                        label1.Visible = true;
                        label1.Text    = "Room: " + OrderAndCard[1];
                        break;

                    case "Win":
                        Thread.Sleep(1000);
                        for (int i = 0; i < 3; i++)
                        {
                            for (int y = 0; y < 13; y++)
                            {
                                Enemy[i, y].Visible = false;
                            }
                        }
                        WiningForm(tcpForPlayer.UpdateInformation() == OrderAndCard[1]);
                        label3.Text  = "";
                        label4.Text  = "";
                        label5.Text  = "";
                        label6.Text  = "";
                        label7.Text  = "";
                        label8.Text  = "";
                        label9.Text  = "";
                        label10.Text = "";
                        HideButton(CardButton);
                        HideButton(CardHavePlay);
                        MyCard.Clear();
                        break;

                    //case "FlipDown":
                    //    FlipDown(Int32.Parse(OrderAndCard[1]), CardHavePlay);
                    //    break;
                    case "Exit":
                        HideButton(CardButton);
                        HideButton(CardHavePlay);
                        ChooseRoomForm();
                        CountDownTimer.Stop();
                        PBCountDown.Visible = false;
                        label2.Visible      = false;
                        label1.Visible      = false;
                        MyCard.Clear();
                        break;
                    }
                }
            }
            //while (true)
            //{
            //    Console.WriteLine("chokhang");
            //}
        }
Beispiel #12
0
        public SecondPageViewModel()
        {
            _musicPlayer = DependencyService.Get <IMusicPlayer>();

            _timer                 = new CountDownTimer(TimeSpan.FromSeconds(300));
            _timer.Interval        = TimeSpan.FromSeconds(1);
            _timer.IntervalPassed += _timer_IntervalPassed;

            Plus1MinCommand = new DelegateCommand(() => {
                _timer.CurrentTime.Add(TimeSpan.FromMinutes(1));
                UpdateTimer();
            });

            Plus10SecCommand = new DelegateCommand(() => {
                _timer.CurrentTime.Add(TimeSpan.FromSeconds(10));
                UpdateTimer();
            });

            Minus10SecCommand = new DelegateCommand(() => {
                _timer.CurrentTime.Subtract(TimeSpan.FromSeconds(10));
                UpdateTimer();
            });


            Minus1MinCommand = new DelegateCommand(() => {
                _timer.CurrentTime.Subtract(TimeSpan.FromMinutes(1));
                UpdateTimer();
            });


            StartTimerCommand = new DelegateCommand(() => {
                _timer.Start();
                UpdateTimer();
            });


            StopTimerCommand = new DelegateCommand(() => {
                _timer.Stop();
                UpdateTimer();
            });


            ResetTimerCommand = new DelegateCommand(() => {
                _timer.Reset();
                UpdateTimer();
            });

            BGMStopCommand = new DelegateCommand(() => {
                _musicPlayer.Stop();
            });

            BGMOpeningCommand = new DelegateCommand(() => {
                _musicPlayer.Stop();
                _musicPlayer.PlayAsync("openingBGM");
            });

            BGMRoleCommand = new DelegateCommand(() => {
                _musicPlayer.Stop();
                _musicPlayer.PlayAsync("confirmBGM");
            });

            BGMMorningCommand = new DelegateCommand(() => {
                _musicPlayer.Stop();
                _musicPlayer.PlayAsync("morningBGM");
            });
            BGMDayTimeCommand = new DelegateCommand(() => {
                _musicPlayer.Stop();
                _musicPlayer.PlayAsync("discussionBGM");
            });

            BGMVoteCommand = new DelegateCommand(() => {
                _musicPlayer.Stop();
                _musicPlayer.PlayAsync("voteBGM");
            });

            BGMExecuteCommand = new DelegateCommand(() => {
                _musicPlayer.Stop();
                _musicPlayer.PlayAsync("executionBGM");
            });

            BGMNightCommand = new DelegateCommand(() => {
                _musicPlayer.Stop();
                _musicPlayer.PlayAsync("nightBGM");
            });


            BGMVillagerWinCommand = new DelegateCommand(() => {
                _musicPlayer.Stop();
                _musicPlayer.PlayAsync("victoryBGM_villagers");
            });

            BGMWerewolfWinCommand = new DelegateCommand(() => {
                _musicPlayer.Stop();
                _musicPlayer.PlayAsync("victoryBGM_werewolf");
            });

            BGMThirdPartyWinCommand = new DelegateCommand(() => {
                _musicPlayer.Stop();
                _musicPlayer.PlayAsync("victoryBGM_3rdParty");
            });
        }
 public void Dispose()
 {
     TheTimer.Stop();
     TheTimer.IntervalPassed -= _timer2_IntervalPassed;
 }