コード例 #1
0
        protected virtual void OnCardClick(RoutedEventArgs e)
        {
            SetCard3D card = (SetCard3D)e.OriginalSource;

            if (m_set.CanPlay)
            {
                m_listener.StartListening();


                if (m_checkedCards.Contains(card) && !card.IsChecked)
                {
                    m_checkedCards.Remove(card);

                    card.CurrentZVelocity = -10;
                }
                else if (!m_checkedCards.Contains(card) && card.IsChecked)
                {
                    m_checkedCards.Add(card);

                    card.CurrentZVelocity = -20;
                }

                Debug.Assert(m_checkedCards.Count <= 3);

                if (m_checkedCards.Count == 3)
                {
                    int index0 = m_cards.IndexOf(m_checkedCards[0]);
                    int index1 = m_cards.IndexOf(m_checkedCards[1]);
                    int index2 = m_cards.IndexOf(m_checkedCards[2]);

                    Debug.Assert(index0 != index1 &&
                                 index0 != index2 &&
                                 index1 != index2);

                    bool goodPlay = m_set.TryPlay(index0, index1, index2);

                    m_checkedCards.Clear();
                    m_cards[index0].IsChecked = false;
                    m_cards[index1].IsChecked = false;
                    m_cards[index2].IsChecked = false;

                    double velocity = goodPlay ? -50 : -20;

                    m_cards[index0].CurrentZVelocity = velocity;
                    m_cards[index1].CurrentZVelocity = velocity;
                    m_cards[index2].CurrentZVelocity = velocity;
                }
            } // if can play
            else
            {
                card.IsChecked = false;
            }
        } //*** void OnCardClick
コード例 #2
0
        public SetBoardElement()
            : base(new Viewport3D())
        {
            int row = 0, column = 0;

            Vector3D offset = new Vector3D(
                -s_setCard3DSize.Width * 1.5 - 1.5 * c_setCardMargin,
                s_setCard3DSize.Height + c_setCardMargin,
                0);

            Vector3D delta = new Vector3D(s_setCard3DSize.Width + c_setCardMargin, -(s_setCard3DSize.Height + c_setCardMargin), 0);

            for (int i = 0; i < m_cards.Count; i++)
            {
                row    = i / 4;
                column = i % 4;

                m_cards[i] = new SetCard3D();
                m_cards[i].TranslateTransform3D.SetToVector(offset + new Vector3D(delta.X * column, delta.Y * row, 0));

                this.WrappedElement.Children.Add(m_cards[i]);
            }

            WrappedElement.ClipToBounds = false;

            // camera to ue
            PerspectiveCamera camera = new PerspectiveCamera();

            camera.Position       = new Point3D(0, 0, 500);
            WrappedElement.Camera = camera;

            ModelVisual3D modelView3DPointLight1 = new ModelVisual3D();

            modelView3DPointLight1.Content = new PointLight(Color.FromRgb(255, 255, 255), new Point3D(-100, 200, 500));
            WrappedElement.Children.Add(modelView3DPointLight1);

            ModelVisual3D modelView3DPointLight2 = new ModelVisual3D();

            modelView3DPointLight2.Content = new PointLight(Color.FromRgb(45, 45, 50), new Point3D(100, -200, 500));
            WrappedElement.Children.Add(modelView3DPointLight2);

            m_listener.Rendering += m_listener_Rendering;
        }