Ejemplo n.º 1
0
        //Capturee Screem Pixels as Texture2D
        public IEnumerator Captutre(Rect CaptureArea, WallRatio Ratio)
        {
            HasEnvironment = true;
            yield return(new WaitForEndOfFrame());

            int       width   = (int)(CaptureArea.width - CaptureArea.x);
            int       height  = (int)(CaptureArea.height - CaptureArea.y);
            Texture2D texture = new Texture2D(width, height, TextureFormat.RGB24, true);

            texture.ReadPixels(CaptureArea, 0, 0);
            texture.Apply();

            Ratio.Active(true);
            Ratio.SetTexture(texture);


            yield return(new WaitForEndOfFrame());

            GameManager.instance.ReadyToPlay();
        }
Ejemplo n.º 2
0
        void DrawArc()
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString());
            }


            //
            //  Odd behavior when z is zero and x < zero: points get switched.
            //  this code switches them back.
            if (Z == 0 && X < 0)
            {
                double wrk = RightLineY;
                RightLineY = LeftLineY;
                LeftLineY  = wrk;
            }

            PathGeometry pathGeometry = new PathGeometry();

            PathFigure figure = new PathFigure();

            figure.StartPoint = new Point(RightLineX + CenterX, RightLineY + CenterY);



            Point EndPoint = new Point(LeftLineX + CenterX, LeftLineY + CenterY);

            if (ArcWidth == 1)
            {
                //@@@@

                double relativeX = Math.Atan(CenterWallY / CenterWallX);
                double wrkArc    = 0.999999D;

                double wrkX = WallRatio * Range *
                              Math.Cos(wrkArc * Math.PI + relativeX)
                              * ((CenterWallX < 0 && Math.Cos(relativeX) > 0) ? -1 : 1);

                double wrkY = WallRatio * Range *
                              Math.Sin(wrkArc * Math.PI + relativeX)
                              * (((CenterWallY > 0 && Math.Sin(relativeX) < 0) || (CenterWallY < 0 && Math.Sin(relativeX) > 0)) ? -1 : 1);

                EndPoint = new Point(wrkX + CenterX, wrkY + CenterY);



                wrkX = WallRatio * Range *
                       Math.Cos(-wrkArc * Math.PI + relativeX)
                       * ((CenterWallX < 0 && Math.Cos(relativeX) > 0) ? -1 : 1);

                wrkY = WallRatio * Range *
                       Math.Sin(-wrkArc * Math.PI + relativeX)
                       * (((CenterWallY > 0 && Math.Sin(relativeX) < 0) || (CenterWallY < 0 && Math.Sin(relativeX) > 0)) ? -1 : 1);

                figure.StartPoint = new Point(wrkX + CenterX, wrkY + CenterY);
            }
            Size arcSize  = new Size(Range * WallRatio, Range * WallRatio);
            bool largeArc = (ArcWidth > 0.5);


            if (_log.IsInfoEnabled)
            {
                _log.InfoFormat("~~~~~~~~~~~~~~~~WallRatio={0}, X={1}, Z={2}", WallRatio.ToString(), X.ToString(), Z.ToString());
                _log.InfoFormat("Rendering arc.  RightLineX={0}, RightLineY={1}, LeftLineX={2}, LeftLineY={3}, Range={4}, largeArc={5}, arcWidth={6}",
                                RightLineX.ToString(), RightLineY.ToString(), LeftLineX.ToString(),
                                LeftLineY.ToString(), Range.ToString(), largeArc.ToString(),
                                ArcWidth.ToString());
                _log.InfoFormat("Start Point=({0},{1}), End Point=({2},{3})",
                                figure.StartPoint.X.ToString(),
                                figure.StartPoint.Y.ToString(),
                                EndPoint.X.ToString(),
                                EndPoint.Y.ToString());
            }

            figure.Segments.Add(
                new ArcSegment(
                    EndPoint,
                    arcSize, 0,
                    largeArc,
                    SweepDirection.Clockwise,
                    true));


            Brush  FillBrush       = null;
            double strokeThickness = 1;

            if (Highlighter)
            {
                strokeThickness = 3;
                BrushConverter cnv = new BrushConverter();
                string         wrk = cnv.ConvertToString(this.SideLinesBrush);
                FillBrush = new BrushConverter().ConvertFromString("#70" + wrk.Substring(3)) as Brush;


                List <Point> points = new List <Point>();
                points.Add(new Point(CenterX, CenterY));
                points.Add(new Point(LeftLineX + CenterX, LeftLineY + CenterY));
                points.Add(new Point(RightLineX + CenterX, RightLineY + CenterY));
                myTriangle.Points = new PointCollection(points);

                myTriangle.Fill       = FillBrush;
                myTriangle.Visibility = Visibility.Visible;
            }
            else
            {
                myTriangle.Visibility = Visibility.Collapsed;
            }


            LeftLine.StrokeThickness   = strokeThickness;
            CenterLine.StrokeThickness = strokeThickness;
            RightLine.StrokeThickness  = strokeThickness;
            pathGeometry.Figures.Add(figure);

            myArc.Data = pathGeometry;

            myArc.Fill            = FillBrush;
            myArc.Stroke          = this.SideLinesBrush;
            myArc.StrokeThickness = strokeThickness;
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString());
            }
        }