Exemple #1
0
        public void QuadrantRotatedCallback(String quadrantName, TwistDirection twist)
        {
            okToRotateQuadrant = false;
            switch (quadrantName)
            {
            case "UpperLeft":
                if (twist == TwistDirection.Clockwise)
                {
                    masterBoard.DoRotation(Rotation.UpperLeftClockwise);
                }
                else
                {
                    masterBoard.DoRotation(Rotation.UpperLeftAntiClockwise);
                }
                break;

            case "UpperRight":
                if (twist == TwistDirection.Clockwise)
                {
                    masterBoard.DoRotation(Rotation.UpperRightClockwise);
                }
                else
                {
                    masterBoard.DoRotation(Rotation.UpperRightAntiClockwise);
                }
                break;

            case "LowerLeft":
                if (twist == TwistDirection.Clockwise)
                {
                    masterBoard.DoRotation(Rotation.LowerLeftClockwise);
                }
                else
                {
                    masterBoard.DoRotation(Rotation.LowerLeftAntiClockwise);
                }
                break;

            case "LowerRight":
                if (twist == TwistDirection.Clockwise)
                {
                    masterBoard.DoRotation(Rotation.LowerRightClockwise);
                }
                else
                {
                    masterBoard.DoRotation(Rotation.LowerRightAntiClockwise);
                }
                break;
            }

            if (this.currentGameStyle == GameStyle.VsAi)
            {
                DoAiMove();
            }
            else if (this.currentGameStyle == GameStyle.VsHuman)
            {
                DoHumanMove();
            }
        }
Exemple #2
0
        internal void ShowTwist(TwistDirection twistDirection)
        {
            Double currentAngle   = (double)MasterGrid.RenderTransform.GetValue(CompositeTransform.RotationProperty);
            Double totalTwistTime = 1.0;

            ((DoubleAnimation)QuadrantRotation.Children[0]).From = currentAngle;
            ((DoubleAnimation)QuadrantRotation.Children[0]).To   =
                (twistDirection == TwistDirection.Clockwise) ? currentAngle + 90 : currentAngle - 90;
            ((DoubleAnimation)QuadrantRotation.Children[0]).Duration = new Duration(TimeSpan.FromSeconds(totalTwistTime));
            QuadrantRotation.BeginTime = TimeSpan.FromSeconds(1);

            SineEase f = new SineEase();

            f.EasingMode = EasingMode.EaseOut;

            ((DoubleAnimation)QuadrantTranslation.Children[0]).From = 0;
            Double to = 0;

            switch (this.Name.ToLower())
            {
            case "upperleft":
            case "lowerleft":
                to = -1 * MasterGrid.ActualWidth * (Math.Sqrt(2.0) - 1) / 2.0;
                break;

            case "upperright":
            case "lowerright":
                to = MasterGrid.ActualWidth * (Math.Sqrt(2.0) - 1) / 2.0;
                break;
            }
            ((DoubleAnimation)QuadrantTranslation.Children[0]).To = to;

            ((DoubleAnimation)QuadrantTranslation.Children[0]).EasingFunction = f;
            ((DoubleAnimation)QuadrantTranslation.Children[0]).Duration       = new Duration(TimeSpan.FromSeconds(totalTwistTime / 2.0));

            ((DoubleAnimation)QuadrantTranslation.Children[1]).From = 0;
            switch (this.Name.ToLower())
            {
            case "upperleft":
            case "upperright":
                to = -1 * MasterGrid.ActualWidth * (Math.Sqrt(2.0) - 1) / 2.0;
                break;

            case "lowerleft":
            case "lowerright":
                to = MasterGrid.ActualWidth * (Math.Sqrt(2.0) - 1) / 2.0;
                break;
            }
            ((DoubleAnimation)QuadrantTranslation.Children[1]).To             = to;
            ((DoubleAnimation)QuadrantTranslation.Children[1]).EasingFunction = f;
            ((DoubleAnimation)QuadrantTranslation.Children[1]).Duration       = new Duration(TimeSpan.FromSeconds(totalTwistTime / 2.0));
            QuadrantTranslation.AutoReverse = true;
            QuadrantTranslation.BeginTime   = TimeSpan.FromSeconds(1);



            QuadrantRotation.Begin();
            QuadrantTranslation.Begin();
        }
Exemple #3
0
 public Barrel()
 {
     _ID             = Guid.NewGuid().ToString();
     _CartridgeID    = "";
     _Desc           = "";
     _Make           = "";
     _Model          = "";
     _Name           = "";
     _TwistDirection = TwistDirection.Right;
 }
Exemple #4
0
        internal void ShowTwist(TwistDirection twistDirection)
        {
            Double currentAngle = (double)MasterGrid.RenderTransform.GetValue(RotateTransform.AngleProperty);

            ((DoubleAnimation)QuadrantRotation.Children[0]).From = currentAngle;
            ((DoubleAnimation)QuadrantRotation.Children[0]).To   =
                (twistDirection == TwistDirection.Clockwise) ? currentAngle + 90 : currentAngle - 90;
            ((DoubleAnimation)QuadrantRotation.Children[0]).Duration = new Duration(TimeSpan.FromSeconds(1));
            QuadrantRotation.BeginTime = TimeSpan.FromSeconds(1);
            QuadrantRotation.Begin();
        }
Exemple #5
0
        public void QuadrantRotatedCallback(String quadrantName, TwistDirection twist)
        {
            okToRotateQuadrant = false;
            this.Cursor        = Cursors.Arrow;
            switch (quadrantName)
            {
            case "UpperLeft":
                if (twist == TwistDirection.Clockwise)
                {
                    masterBoard.DoRotation(Rotation.UpperLeftClockwise);
                }
                else
                {
                    masterBoard.DoRotation(Rotation.UpperLeftAntiClockwise);
                }
                break;

            case "UpperRight":
                if (twist == TwistDirection.Clockwise)
                {
                    masterBoard.DoRotation(Rotation.UpperRightClockwise);
                }
                else
                {
                    masterBoard.DoRotation(Rotation.UpperRightAntiClockwise);
                }
                break;

            case "LowerLeft":
                if (twist == TwistDirection.Clockwise)
                {
                    masterBoard.DoRotation(Rotation.LowerLeftClockwise);
                }
                else
                {
                    masterBoard.DoRotation(Rotation.LowerLeftAntiClockwise);
                }
                break;

            case "LowerRight":
                if (twist == TwistDirection.Clockwise)
                {
                    masterBoard.DoRotation(Rotation.LowerRightClockwise);
                }
                else
                {
                    masterBoard.DoRotation(Rotation.LowerRightAntiClockwise);
                }
                break;
            }

            DoAiMove();
        }
Exemple #6
0
        void PentagoQuadrant_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (mouseDrag)
            {
                mouseDrag = false;

                Double   currentAngle = (double)MasterGrid.RenderTransform.GetValue(RotateTransform.AngleProperty);
                Duration dur          = new Duration(TimeSpan.FromSeconds(0.1));
                Double   to           = currentAngle;

                if ((currentAngle % 90) != 0)
                {
                    Double mod360 = currentAngle % 360;
                    Double mod45  = currentAngle % 45;
                    if (mod360 < 0)
                    {
                        mod360 += 360;
                    }
                    if (mod45 < 0)
                    {
                        mod45 += 45;
                    }

                    to = currentAngle - mod45;

                    if ((mod360 <= 90 && mod360 > 45) ||
                        (mod360 <= 360 && mod360 > 315) ||
                        (mod360 <= 270 && mod360 > 225) ||
                        (mod360 <= 180 && mod360 > 135))
                    {
                        to += 45;
                    }
                }
                ((DoubleAnimation)QuadrantRotation.Children[0]).From     = currentAngle;
                ((DoubleAnimation)QuadrantRotation.Children[0]).To       = to;
                ((DoubleAnimation)QuadrantRotation.Children[0]).Duration = dur;
                QuadrantRotation.ClearValue(Storyboard.BeginTimeProperty);
                TwistDirection direction = GetTwistDirectionFromAngles(origAngle, to);
                if (direction != TwistDirection.None)
                {
                    sendTwistNotification = true;
                    latestTwistDirection  = direction;
                }
                this.ReleaseMouseCapture();
                QuadrantRotation.Begin();
                this.ClearValue(Canvas.ZIndexProperty);
            }
        }
        void PentagoQuadrant_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (mouseDrag)
            {
                mouseDrag = false;

                Double currentAngle = (double)MasterGrid.RenderTransform.GetValue(CompositeTransform.RotationProperty);
                Double currentX = (double)MasterGrid.RenderTransform.GetValue(CompositeTransform.TranslateXProperty);
                Double currentY = (double)MasterGrid.RenderTransform.GetValue(CompositeTransform.TranslateYProperty);

                Duration dur = new Duration(TimeSpan.FromSeconds(0.2));
                Double to = currentAngle;

                if ((currentAngle % 90) != 0)
                {
                    Double mod360 = currentAngle % 360;
                    Double mod45 = currentAngle % 45;
                    if (mod360 < 0) { mod360 += 360; }
                    if (mod45 < 0) { mod45 += 45; }

                    to = currentAngle - mod45;

                    if ((mod360 <= 90 && mod360 > 45) ||
                        (mod360 <= 360 && mod360 > 315) ||
                        (mod360 <= 270 && mod360 > 225) ||
                        (mod360 <= 180 && mod360 > 135))
                    {
                        to += 45;
                    }
                }
                ((DoubleAnimation)QuadrantRotation.Children[0]).From = currentAngle;
                ((DoubleAnimation)QuadrantRotation.Children[0]).To = to;
                ((DoubleAnimation)QuadrantRotation.Children[0]).Duration = dur;
                QuadrantRotation.ClearValue(Storyboard.BeginTimeProperty);
                TwistDirection direction = GetTwistDirectionFromAngles(origAngle, to);
                if (direction != TwistDirection.None)
                {
                    sendTwistNotification = true;
                    latestTwistDirection = direction;
                }

                SineEase f = new SineEase();
                f.EasingMode = EasingMode.EaseIn;

                ((DoubleAnimation)QuadrantTranslation.Children[0]).From = currentX;
                ((DoubleAnimation)QuadrantTranslation.Children[0]).To = 0.0;
                ((DoubleAnimation)QuadrantTranslation.Children[0]).Duration = dur;
              //  ((DoubleAnimation)QuadrantTranslation.Children[0]).EasingFunction = f;

                ((DoubleAnimation)QuadrantTranslation.Children[1]).From = currentY;
                ((DoubleAnimation)QuadrantTranslation.Children[1]).To = 0.0;
                ((DoubleAnimation)QuadrantTranslation.Children[1]).Duration = dur;
             //   ((DoubleAnimation)QuadrantTranslation.Children[1]).EasingFunction = f;
                QuadrantTranslation.ClearValue(Storyboard.BeginTimeProperty);
                QuadrantTranslation.AutoReverse = false;

                this.ReleaseMouseCapture();
                QuadrantTranslation.Begin();
                QuadrantRotation.Begin();
                this.ClearValue(Canvas.ZIndexProperty);
            }
        }
        internal void ShowTwist(TwistDirection twistDirection)
        {
            Double currentAngle = (double)MasterGrid.RenderTransform.GetValue(CompositeTransform.RotationProperty);
            Double totalTwistTime = 1.0;

            ((DoubleAnimation)QuadrantRotation.Children[0]).From = currentAngle;
            ((DoubleAnimation)QuadrantRotation.Children[0]).To =
                (twistDirection == TwistDirection.Clockwise) ? currentAngle + 90 : currentAngle - 90;
            ((DoubleAnimation)QuadrantRotation.Children[0]).Duration = new Duration(TimeSpan.FromSeconds(totalTwistTime));
            QuadrantRotation.BeginTime = TimeSpan.FromSeconds(1);

            SineEase f = new SineEase();
            f.EasingMode = EasingMode.EaseOut;

            ((DoubleAnimation)QuadrantTranslation.Children[0]).From = 0;
            Double to = 0;
            switch (this.Name.ToLower())
            {
                case "upperleft":
                case "lowerleft":
                    to = -1 * MasterGrid.ActualWidth * (Math.Sqrt(2.0) - 1) / 2.0;
                    break;
                case "upperright":
                case "lowerright":
                    to = MasterGrid.ActualWidth * (Math.Sqrt(2.0) - 1) / 2.0;
                    break;
            }
            ((DoubleAnimation)QuadrantTranslation.Children[0]).To = to;

            ((DoubleAnimation)QuadrantTranslation.Children[0]).EasingFunction = f;
            ((DoubleAnimation)QuadrantTranslation.Children[0]).Duration = new Duration(TimeSpan.FromSeconds(totalTwistTime/2.0));

            ((DoubleAnimation)QuadrantTranslation.Children[1]).From = 0;
            switch (this.Name.ToLower())
            {
                case "upperleft":
                case "upperright":
                    to = -1 * MasterGrid.ActualWidth * (Math.Sqrt(2.0) - 1) / 2.0;
                    break;
                case "lowerleft":
                case "lowerright":
                    to = MasterGrid.ActualWidth * (Math.Sqrt(2.0) - 1) / 2.0;
                    break;
            }
            ((DoubleAnimation)QuadrantTranslation.Children[1]).To = to;
            ((DoubleAnimation)QuadrantTranslation.Children[1]).EasingFunction = f;
            ((DoubleAnimation)QuadrantTranslation.Children[1]).Duration = new Duration(TimeSpan.FromSeconds(totalTwistTime / 2.0));
            QuadrantTranslation.AutoReverse = true;
            QuadrantTranslation.BeginTime = TimeSpan.FromSeconds(1);

            QuadrantRotation.Begin();
            QuadrantTranslation.Begin();
        }
Exemple #9
0
        public void QuadrantRotatedCallback(String quadrantName, TwistDirection twist)
        {
            okToRotateQuadrant = false;
            this.Cursor = Cursors.Arrow;
            switch (quadrantName)
            {
                case "UpperLeft":
                    if(twist == TwistDirection.Clockwise)
                        masterBoard.DoRotation(Rotation.UpperLeftClockwise);
                    else
                        masterBoard.DoRotation(Rotation.UpperLeftAntiClockwise);
                    break;
                case "UpperRight":
                    if (twist == TwistDirection.Clockwise)
                        masterBoard.DoRotation(Rotation.UpperRightClockwise);
                    else
                        masterBoard.DoRotation(Rotation.UpperRightAntiClockwise);
                    break;
                case "LowerLeft":
                    if (twist == TwistDirection.Clockwise)
                        masterBoard.DoRotation(Rotation.LowerLeftClockwise);
                    else
                        masterBoard.DoRotation(Rotation.LowerLeftAntiClockwise);
                    break;
                case "LowerRight":
                    if (twist == TwistDirection.Clockwise)
                        masterBoard.DoRotation(Rotation.LowerRightClockwise);
                    else
                        masterBoard.DoRotation(Rotation.LowerRightAntiClockwise);
                    break;
            }

            DoAiMove();
        }
Exemple #10
0
        public void QuadrantRotatedCallback(String quadrantName, TwistDirection twist)
        {
            okToRotateQuadrant = false;
            switch (quadrantName)
            {
                case "UpperLeft":
                    if (twist == TwistDirection.Clockwise)
                        masterBoard.DoRotation(Rotation.UpperLeftClockwise);
                    else
                        masterBoard.DoRotation(Rotation.UpperLeftAntiClockwise);
                    break;
                case "UpperRight":
                    if (twist == TwistDirection.Clockwise)
                        masterBoard.DoRotation(Rotation.UpperRightClockwise);
                    else
                        masterBoard.DoRotation(Rotation.UpperRightAntiClockwise);
                    break;
                case "LowerLeft":
                    if (twist == TwistDirection.Clockwise)
                        masterBoard.DoRotation(Rotation.LowerLeftClockwise);
                    else
                        masterBoard.DoRotation(Rotation.LowerLeftAntiClockwise);
                    break;
                case "LowerRight":
                    if (twist == TwistDirection.Clockwise)
                        masterBoard.DoRotation(Rotation.LowerRightClockwise);
                    else
                        masterBoard.DoRotation(Rotation.LowerRightAntiClockwise);
                    break;
            }

            if (this.currentGameStyle == GameStyle.VsAi)
            {
                DoAiMove();
            }
            else if (this.currentGameStyle == GameStyle.VsHuman)
            {
                DoHumanMove();
            }
        }
 internal void ShowTwist(TwistDirection twistDirection)
 {
     Double currentAngle = (double)MasterGrid.RenderTransform.GetValue(RotateTransform.AngleProperty);
     ((DoubleAnimation)QuadrantRotation.Children[0]).From = currentAngle;
     ((DoubleAnimation)QuadrantRotation.Children[0]).To =
         (twistDirection == TwistDirection.Clockwise) ? currentAngle + 90 : currentAngle - 90;
     ((DoubleAnimation)QuadrantRotation.Children[0]).Duration = new Duration(TimeSpan.FromSeconds(1));
     QuadrantRotation.BeginTime = TimeSpan.FromSeconds(1);
     QuadrantRotation.Begin();
 }
Exemple #12
0
 public Rifling(Measurement <DistanceUnit> riflingStep, TwistDirection direction)
 {
     RiflingStep = riflingStep;
     Direction   = direction;
 }