コード例 #1
0
        public PlayPage(Album album)
        {
            InitializeComponent();
            BindingContext = new PlayPageViewModel()
            {
                Album = album.thumbnailUrl
            };
            var connection = DependencyService.Get <ISQLiteDB>().GetConnection();

            connection.Insert(album);
        }
コード例 #2
0
        public Play_page()
        {
            InitializeComponent();
            //プレイヤー名の設定
            PlayerNumber = ((PN)Application.Current.Properties["Number"]).playernumber;
            //if (PlayerNumber == 1) this.DataContext = new { Name1 = "プレイヤー1", Name2 = "プレイヤー2", Score1 = count1, Score2 = count2 };
            //else if (PlayerNumber == 2) this.DataContext = new { Name1 = "プレイヤー2", Name2 = "プレイヤー1", Score1 = count1, Score2 = count2 };


            playPageViewModel = new PlayPageViewModel()
            {
                Name1  = (PlayerNumber == 1 ? "プレイヤー1" : "プレイヤー2"),
                Name2  = (PlayerNumber == 1 ? "プレイヤー2" : "プレイヤー1"),
                Score1 = 0,
                Score2 = 0
            };
            this.DataContext = playPageViewModel;

            //モグラをRandomで出すタイマー
            RandomTimer           = new DispatcherTimer(DispatcherPriority.Normal);
            RandomTimer.Interval  = TimeSpan.FromMilliseconds(RS);
            RandomTimer.IsEnabled = false;
            RandomTimer.Tick     += RandomTimerEventHandler;

            //モグラをRandomで出すタイマー2
            Random2Timer           = new DispatcherTimer(DispatcherPriority.Normal);
            Random2Timer.Interval  = TimeSpan.FromMilliseconds(RS2);
            Random2Timer.IsEnabled = false;
            Random2Timer.Tick     += Random2TimerEventHandler;

            //制限時間のタイマー
            timeup2Timer           = new DispatcherTimer(DispatcherPriority.Normal);
            timeup2Timer.Interval  = TimeSpan.FromMilliseconds(stop2);
            timeup2Timer.IsEnabled = false;
            timeup2Timer.Tick     += timeup2TimerEventHandler;

            //制限時間前のタイマー
            timeupTimer           = new DispatcherTimer(DispatcherPriority.Normal);
            timeupTimer.Interval  = TimeSpan.FromMilliseconds(stop);
            timeupTimer.IsEnabled = false;
            timeupTimer.Tick     += timeupTimerEventHandler;

            //ラグをなくすタイマー
            tienTimer           = new DispatcherTimer(DispatcherPriority.Normal);
            tienTimer.Interval  = TimeSpan.FromMilliseconds(tien);
            tienTimer.IsEnabled = false;
            tienTimer.Tick     += tienTimerEventHandler;

            // 制限時間のタイマーを開始
            timeupTimer.IsEnabled = true;
            timeupTimer.Start();

            // 制限時間前のタイマーを開始
            timeup2Timer.IsEnabled = true;
            timeup2Timer.Start();

            // ランダムタイマーを開始
            RandomTimer.IsEnabled = true;
            RandomTimer.Start();

            // リストに各モグラを追加
            MoguraList = new List <mogurahole>();
            MoguraList.Add(Mogura1_1);
            MoguraList.Add(Mogura1_2);
            MoguraList.Add(Mogura1_3);
            MoguraList.Add(Mogura1_4);
            MoguraList.Add(Mogura1_5);
            MoguraList.Add(Mogura1_6);
            MoguraList.Add(Mogura2_1);
            MoguraList.Add(Mogura2_2);
            MoguraList.Add(Mogura2_3);
            MoguraList.Add(Mogura2_4);
            MoguraList.Add(Mogura2_5);
            MoguraList.Add(Mogura2_6);
            MoguraList.Add(Mogura3_1);
            MoguraList.Add(Mogura3_2);
            MoguraList.Add(Mogura3_3);
            MoguraList.Add(Mogura3_4);
            MoguraList.Add(Mogura3_5);
            MoguraList.Add(Mogura3_6);
            MoguraList.Add(Mogura4_1);
            MoguraList.Add(Mogura4_2);
            MoguraList.Add(Mogura4_3);
            MoguraList.Add(Mogura4_4);
            MoguraList.Add(Mogura4_5);
            MoguraList.Add(Mogura4_6);

            // 全てのボタンにクリックイベントを設定しておく
            foreach (var targetbutton in MoguraList)
            {
                // クリック時のイベントを設定
                targetbutton.AttackEvent = () =>
                {
                    Mogura_Click();
                    count1++;
                    //clients.DataReceiveCallback = Doscore;



                    if (PlayerNumber == 1)
                    {
                        try
                        {
                            clients.receiveDone.Reset();
                            clients.Send("<p1>" + count1.ToString() + "<score><EOF>");
                            //clients.receiveDone.WaitOne();
                            // Receive the clients.response from the remote device.
                            if (clients.response.IndexOf("<score>") > -1) //score送信の部分
                            {
                                clients.response = (clients.response.Replace("<score>", ""));
                                var score = clients.response.Split(',');
                                count2 = int.Parse(score[1].Replace("<EOF>", ""));
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                        }
                    }
                    else if (PlayerNumber == 2)
                    {
                        try
                        {
                            clients.receiveDone.Reset();
                            clients.Send("<p2>" + count1.ToString() + "<score><EOF>");
                            //clients.receiveDone.WaitOne();
                            // Receive the clients.response from the remote device.
                            if (clients.response.IndexOf("<score>") > -1) //score送信の部分
                            {
                                clients.response = (clients.response.Replace("<score>", ""));
                                var score = clients.response.Split(',');
                                count2 = int.Parse(score[0].Replace("<EOF>", ""));
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                        }
                    }

                    // Application.Propertiesに設定しておく。
                    PN number = new PN()
                    {
                        playernumber = PlayerNumber
                    };
                    PN C1 = new PN()
                    {
                        c1 = count1
                    };
                    PN C2 = new PN()
                    {
                        c2 = count2
                    };

                    Application.Current.Properties["Number"] = number;
                    Application.Current.Properties["C1"]     = C1;
                    Application.Current.Properties["C2"]     = C2;
                };
            }
        }
コード例 #3
0
 public HighlightedMove(PlayPageViewModel viewModel)
 {
     this._viewModel = viewModel;
 }