Beispiel #1
0
        public Task SetGameAsync(string game, PlayingType type)
        {
            var obj = new { Name = game, PlayingType = type };
            var sub = Services.GetService <IDataCache>().Redis.GetSubscriber();

            return(sub.PublishAsync(Client.CurrentUser.Id + "_status.game_set", JsonConvert.SerializeObject(obj)));
        }
Beispiel #2
0
 private void btnComOnline_Click(object sender, RoutedEventArgs e)
 {
     if (Type == PlayingType.ComOnline)
     {
         Board.isEndGame = false;
         if (btnComOnline.Content.Equals("New Game!"))
         {
             socket.Emit("ConnectToOtherPlayer");
             btnComOnline.Content = "Change!";
         }
         else
         {
             ClientName = txtName.Text.Trim();
             socket.Emit("MyNameIs", ClientName);
         }
     }
     else
     {
         Type            = PlayingType.ComOnline;
         Board.isEndGame = false;
         ugrid.Dispatcher.Invoke(() => ugrid.Children.Clear());
         VeBanCo();
         btnComOnline.Content = "Change!";
         btnMain.Content      = "Start!";
         if (socket != null && thread != null)
         {
             socket.Close();
             thread.Interrupt();
         }
         thread = new Thread(ListenData);
         thread.IsBackground = true;
         thread.Start();
     }
 }
Beispiel #3
0
 private void btnPvC_Click(object sender, RoutedEventArgs e)
 {
     Type = PlayingType.PvCom;
     if (socket != null && thread != null)
     {
         socket.Close();
         thread.Interrupt();
         btnMain.Content      = "Start!";
         btnComOnline.Content = "Start!";
     }
     Lview.Items.Clear();
     Board.ResetBoard();
     ugrid.Children.Clear();
     VeBanCo();
     if (MessageBox.Show("Bạn có muốn chơi trước không?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
     {
         CaroButton center = GetButton(Board.BOARD_SIZE / 2 + 1, Board.BOARD_SIZE / 2 + 1);
         if (center != null)
         {
             Board.ActivePlayer = CellPlayer.Player2;
             Ellipse ell = new Ellipse();
             ell.Width = ell.Height = 25;
             RadialGradientBrush RadialBrush = new RadialGradientBrush();
             RadialBrush.GradientOrigin = new Point(0.9, 0.9);
             RadialBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0));
             RadialBrush.GradientStops.Add(new GradientStop(Colors.White, 0.75));
             ell.Stroke     = Brushes.Black;
             ell.Fill       = RadialBrush;
             center.Content = ell;
             Board.PlayAt(center.X, center.Y);
         }
     }
 }
Beispiel #4
0
 private async void OnPlayingTypeChanged(PlayingType pType)
 {
     await DispatchHelper.InvokeInUIThread(CoreDispatcherPriority.Normal, () =>
     {
         OnPropertyChanged(nameof(MiniPlayerVisibility));
         OnPropertyChanged(nameof(MiniPlayerVisibilityMediaCenter));
     });
 }
Beispiel #5
0
            public async Task AddPlaying(PlayingType t, [Remainder] string status)
            {
                using (var uow = _db.UnitOfWork)
                {
                    var config = uow.BotConfig.GetOrCreate(set => set.Include(x => x.RotatingStatusMessages));
                    var toAdd  = new PlayingStatus {
                        Status = status, Type = t
                    };
                    config.RotatingStatusMessages.Add(toAdd);
                    await uow.CompleteAsync();
                }

                await ReplyConfirmLocalized("ropl_added").ConfigureAwait(false);
            }
Beispiel #6
0
 private void btnPvP_Click(object sender, RoutedEventArgs e)
 {
     Type = PlayingType.PvP;
     if (socket != null && thread != null)
     {
         socket.Close();
         thread.Interrupt();
         btnMain.Content      = "Start!";
         btnComOnline.Content = "Start!";
     }
     Lview.Items.Clear();
     Board.ResetBoard();
     ugrid.Children.Clear();
     VeBanCo();
 }
Beispiel #7
0
 private void Board_onWinner(CellPlayer player)
 {
     if (Type == PlayingType.PvCom)
     {
         if (player == CellPlayer.Player2)
         {
             MessageBox.Show("COM is Winer!");
         }
         else
         {
             MessageBox.Show(player.ToString() + " is Winer!");
         }
     }
     else
     {
         MessageBox.Show(player.ToString() + " is Winer!");
     }
     Board.isEndGame = true;
     ugrid.Dispatcher.Invoke(() => ugrid.Children.Clear());
     VeBanCo();
     Type = PlayingType.PvP;
 }
Beispiel #8
0
        private void btnComOnline_Click(object sender, RoutedEventArgs e)
        {

            if (Type == PlayingType.ComOnline)
            {
                Board.isEndGame = false;
                if (btnComOnline.Content.Equals("New Game!"))
                {
                    socket.Emit("ConnectToOtherPlayer");
                    btnComOnline.Content = "Change!";
                }
                else
                {
                    ClientName = txtName.Text.Trim();
                    socket.Emit("MyNameIs", ClientName);
                }
            }
            else
            {
                Type = PlayingType.ComOnline;
                Board.isEndGame = false;
                ugrid.Dispatcher.Invoke(() => ugrid.Children.Clear());
                VeBanCo();
                btnComOnline.Content = "Change!";
                btnMain.Content = "Start!";
                if (socket != null && thread != null)
                {
                    socket.Close();
                    thread.Interrupt();
                }
                thread = new Thread(ListenData);
                thread.IsBackground = true;
                thread.Start();
            }
        }
Beispiel #9
0
        private void btnPvC_Click(object sender, RoutedEventArgs e)
        {
            Type = PlayingType.PvCom;
            if (socket != null && thread != null)
            {
                socket.Close();
                thread.Interrupt();
                btnMain.Content = "Start!";
                btnComOnline.Content = "Start!";
            }
            Lview.Items.Clear();
            Board.ResetBoard();
            ugrid.Children.Clear();
            VeBanCo();
            if (MessageBox.Show("Bạn có muốn chơi trước không?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                CaroButton center = GetButton(Board.BOARD_SIZE / 2 + 1, Board.BOARD_SIZE / 2 + 1);
                if (center != null)
                {
                    Board.ActivePlayer = CellPlayer.Player2;
                    Ellipse ell = new Ellipse();
                    ell.Width = ell.Height = 25;
                    RadialGradientBrush RadialBrush = new RadialGradientBrush();
                    RadialBrush.GradientOrigin = new Point(0.9, 0.9);
                    RadialBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0));
                    RadialBrush.GradientStops.Add(new GradientStop(Colors.White, 0.75));
                    ell.Stroke = Brushes.Black;
                    ell.Fill = RadialBrush;
                    center.Content = ell;
                    Board.PlayAt(center.X, center.Y);
                }

            }

        }
Beispiel #10
0
 private void btnPvP_Click(object sender, RoutedEventArgs e)
 {
     Type = PlayingType.PvP;
     if(socket != null && thread != null)
     {
         socket.Close();
         thread.Interrupt();
         btnMain.Content = "Start!";
         btnComOnline.Content = "Start!";
     }
     Lview.Items.Clear();
     Board.ResetBoard();
     ugrid.Children.Clear();
     VeBanCo();
 }
Beispiel #11
0
        private void Board_onWinner(CellPlayer player)
        {

            if (Type == PlayingType.PvCom)
            {
                if (player == CellPlayer.Player2)
                {
                    MessageBox.Show("COM is Winer!");
                }
                else
                    MessageBox.Show(player.ToString() + " is Winer!");
            }
            else
                MessageBox.Show(player.ToString() + " is Winer!");
            Board.isEndGame = true;
            ugrid.Dispatcher.Invoke(() => ugrid.Children.Clear());
            VeBanCo();
            Type = PlayingType.PvP;
        }
Beispiel #12
0
 public void PlayStopSound(MediaPlayer player, playingCommand command = playingCommand.play, string source = "", PlayingType type = PlayingType.original)
 {
     if (command == playingCommand.play)
     {
         _soundManager.PlaySound(player, source);
         if (type.Equals(PlayingType.loop))
         {
             player.MediaEnded += (object sender, EventArgs e) => { player.Play(); };
         }
     }
     else
     {
         _soundManager.StopPlaying(player);
     }
 }
Beispiel #13
0
            public async Task SetGame(PlayingType type, [Remainder] string game = null)
            {
                await _bot.SetGameAsync(game, type).ConfigureAwait(false);

                await ReplyConfirmLocalized("set_game").ConfigureAwait(false);
            }
        private void OnGUI()
        {
#if VRC_SDK_VRCSDK2
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                avatar = EditorGUILayout.ObjectField("Avatar", avatar, typeof(VRC_AvatarDescriptor), true) as VRC_AvatarDescriptor;

                if (check.changed)
                {
                    if (avatar != null)
                    {
                        animator   = avatar.gameObject.GetComponent <Animator>();
                        controller = avatar.CustomStandingAnims;
                    }
                    else
                    {
                        animator   = null;
                        controller = null;
                    }
                }
            }
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Camera", EditorStyles.boldLabel);
            using (new EditorGUILayout.HorizontalScope())
            {
                if (GUILayout.Button("Scene View"))
                {
                    EditorApplication.ExecuteMenuItem("Window/General/Scene");
                }
                if (GUILayout.Button("Game View"))
                {
                    EditorApplication.ExecuteMenuItem("Window/General/Game");
                }
            }

            /*
             * using (new EditorGUI.DisabledGroupScope(animator is null))
             * {
             *      if (GUILayout.Button("Focus on Avatar"))
             *      {
             *              var sceneViewCamera = SceneView.lastActiveSceneView.camera;
             *              sceneViewCamera.transform.position = animator.transform.position;
             *      }
             * }
             */

            GUILayout.Space(15);

            EditorGUILayout.LabelField("Testing", EditorStyles.boldLabel);
            using (new EditorGUILayout.HorizontalScope())
            {
                using (new EditorGUI.DisabledGroupScope(EditorApplication.isPlayingOrWillChangePlaymode || avatar == null))
                {
                    if (GUILayout.Button("Play"))
                    {
                        defaultController = animator.runtimeAnimatorController;
                        animator.runtimeAnimatorController = controller;

                        poseConstraintObj = CreatePoseConstrainterToRootIfNeeded();
                        poseConstraint    = poseConstraintObj.GetComponent <PoseConstraint>();
                        poseConstraint.UpdateBoneInfo(animator);

                        EditorApplication.isPlaying = true;
                    }
                }
                using (new EditorGUI.DisabledGroupScope(!EditorApplication.isPlayingOrWillChangePlaymode))
                {
                    if (GUILayout.Button("Stop"))
                    {
                        EditorApplication.isPlaying        = false;
                        animator.runtimeAnimatorController = defaultController;
                    }
                }
            }

            if (avatar == null && !EditorApplication.isPlaying)
            {
                EditorGUILayout.HelpBox("Avatarを設定してください", MessageType.Error);
            }

            if (avatar != null && animator != null && controller != null)
            {
                EditorGUILayout.HelpBox("Playを選択するとテストが実行できます", MessageType.Info);
            }

            EditorGUILayout.Space();

            using (new EditorGUI.DisabledGroupScope(!EditorApplication.isPlayingOrWillChangePlaymode))
            {
                if (GUILayout.Button("Reset All"))
                {
                    playingType = PlayingType.NONE;
                    playingHand = PlayingHand.NONE;
                }

                EditorGUILayout.Space();

                EditorGUILayout.LabelField("AnimationOverrides", EditorStyles.boldLabel);
                using (new EditorGUI.IndentLevelScope())
                {
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.LabelField("NONE");
                        if (GUILayout.Button("Left"))
                        {
                            if (playingType == PlayingType.OVERRIDE &&
                                playingHand == PlayingHand.BOTH)
                            {
                                playingHand = PlayingHand.RIGHT;
                            }
                            else
                            {
                                playingType = PlayingType.NONE;
                            }
                            PlayOverride("Left", 0, animator);
                        }
                        if (GUILayout.Button("Right"))
                        {
                            if (playingType == PlayingType.OVERRIDE &&
                                playingHand == PlayingHand.BOTH)
                            {
                                playingHand = PlayingHand.LEFT;
                            }
                            else
                            {
                                playingType = PlayingType.NONE;
                            }
                            PlayOverride("Right", 0, animator);
                        }
                    }
                    for (int overrideNumber = 0; overrideNumber < OVERRIDES.Length; overrideNumber++)
                    {
                        AnimationClip overrideAnimation = null;
                        string        overrideName      = string.Empty;

                        if (controller != null)
                        {
                            overrideAnimation = controller[OVERRIDES[overrideNumber]];

                            if (overrideAnimation.name != OVERRIDES[overrideNumber])
                            {
                                overrideName = $"({overrideAnimation.name})";
                            }
                        }

                        // AnimationClipとOVERRIDES[overrideNumber]の名前が同じであれば未設定
                        using (new EditorGUI.DisabledGroupScope(controller == null || overrideAnimation.name == OVERRIDES[overrideNumber]))
                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUILayout.LabelField(OVERRIDES[overrideNumber], overrideName);

                                if (GUILayout.Button("Left"))
                                {
                                    playingType = PlayingType.OVERRIDE;
                                    if (playingHand == PlayingHand.RIGHT ||
                                        playingHand == PlayingHand.BOTH)
                                    {
                                        playingHand = PlayingHand.BOTH;
                                    }
                                    else
                                    {
                                        playingHand = PlayingHand.LEFT;
                                    }
                                    PlayOverride("Left", overrideNumber, animator);
                                }

                                if (GUILayout.Button("Right"))
                                {
                                    playingType = PlayingType.OVERRIDE;
                                    if (playingHand == PlayingHand.LEFT ||
                                        playingHand == PlayingHand.BOTH)
                                    {
                                        playingHand = PlayingHand.BOTH;
                                    }
                                    else
                                    {
                                        playingHand = PlayingHand.RIGHT;
                                    }
                                    PlayOverride("Right", overrideNumber, animator);
                                }
                            }
                    }
                }
            }

            EditorGUILayout.Space();

            using (new EditorGUI.DisabledGroupScope(!EditorApplication.isPlayingOrWillChangePlaymode))
            {
                EditorGUILayout.LabelField("Emotes", EditorStyles.boldLabel);
                using (new EditorGUI.IndentLevelScope())
                {
                    for (int emoteNumber = 0; emoteNumber < EMOTES.Length; emoteNumber++)
                    {
                        AnimationClip emoteAnimation = null;
                        string        buttonText     = EMOTES[emoteNumber];
                        if (controller != null)
                        {
                            emoteAnimation = controller[EMOTES[emoteNumber]];
                            buttonText     = emoteAnimation.name;
                        }

                        // 取得できるAnimationClipの名前が"EMOTE*"だったら設定されていない
                        using (new EditorGUI.DisabledGroupScope(emoteAnimation == null || emoteAnimation.name == EMOTES[emoteNumber]))
                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUILayout.LabelField(EMOTES[emoteNumber]);

                                if (GUILayout.Button(buttonText) && emoteAnimation != null)
                                {
                                    if (animator.GetInteger($"Emote") != 0)
                                    {
                                        return;
                                    }

                                    playingType = PlayingType.EMOTE;
                                    playingHand = PlayingHand.NONE;
                                    PlayEmote(emoteNumber + 1, animator, emoteAnimation);
                                }
                            }
                    }
                }
            }
#else
            EditorGUILayout.HelpBox("使用するにはVRCSDK2がプロジェクトにインポートされている必要があります", MessageType.Error);
#endif
        }