Пример #1
0
    Vector2 CellToWorld(iPoint cell)
    {
        var new_y = cell.y * m_lineHeight + m_bubbleRadius;
        var new_x = m_bubbleRadius * cell.x + m_bubbleRadius;

        return(new Vector2(new_x, new_y));
    }
Пример #2
0
        /// <summary>
        /// основной конструктор
        /// </summary>
        /// <param name="number_Window">номер бота (номер окна)</param>
        public botWindow(int number_Window)
        {
            numberWindow = number_Window;     // эта инфа поступает при создании объекта класса
            botParam     = new BotParam(numberWindow);
            //globalParam = new GlobalParam();

            #region Вариант 1. переменные класса подчитываются из текстовых файлов

            //this.databot = LoadUserDataBot(TypeLoadUserData.txt);

            #endregion

            #region Вариант 2. переменные класса подчитываются из БД

            //this.databot = LoadUserDataBot(TypeLoadUserData.db);

            #endregion

            //this.statusOfAtk = GetStatusOfAtk();              //значение статуса, 1 - мы уже били босса, 0 - нет

//            serverFactory = new ServerFactory(number_Window);
            serverFactory = new ServerFactory(this);
            server        = serverFactory.create(); // создали конкретный экземпляр класса server по паттерну "простая Фабрика" (Америка, Европа или Синг)


            // точки для тыканья. универсально для всех серверов
            this.pointButtonClose = new Point(850 - 5 + botParam.X, 625 - 5 + botParam.Y); //(848, 620);
            this.pointOneMode     = new Point(123 - 5 + botParam.X, 489 - 5 + botParam.Y); // 118, 484
        }
Пример #3
0
        // ===============================  Методы ==================================================



        /// <summary>
        /// получаем следующую точку маршрута
        /// </summary>
        /// <returns></returns>
        public override iPoint RouteNextPoint()
        {
            iPoint [,] route =
            {
                { new Point(505 - 5 + xx, 505 - 5 + yy), new Point(462 - 5 + xx, 468 - 5 + yy), new Point(505 - 5 + xx, 474 - 5 + yy) },
                { new Point(569 - 5 + xx, 414 - 5 + yy), new Point(511 - 5 + xx, 436 - 5 + yy), new Point(563 - 5 + xx, 444 - 5 + yy) },
                { new Point(334 - 5 + xx, 375 - 5 + yy), new Point(287 - 5 + xx, 350 - 5 + yy), new Point(286 - 5 + xx, 400 - 5 + yy) },
                { new Point(404 - 5 + xx, 339 - 5 + yy), new Point(362 - 5 + xx, 319 - 5 + yy), new Point(410 - 5 + xx, 289 - 5 + yy) },
                { new Point(379 - 5 + xx, 352 - 5 + yy), new Point(306 - 5 + xx, 347 - 5 + yy), new Point(350 - 5 + xx, 312 - 5 + yy) },
                { new Point(540 - 5 + xx, 479 - 5 + yy), new Point(476 - 5 + xx, 467 - 5 + yy), new Point(521 - 5 + xx, 442 - 5 + yy) }
            };

            iPoint result = route[NumberOfRoute(), counterRouteNode];

            return(result);
        }
Пример #4
0
        // ===============================  Методы ==================================================

        /// <summary>
        /// получаем следующую точку маршрута
        /// </summary>
        /// <returns></returns>
        public override iPoint RouteNextPoint()
        {
            iPoint[] route = { new Point(505 - 5 + xx, 505 - 5 + yy),
                               new Point(462 - 5 + xx, 468 - 5 + yy),
                               new Point(492 - 5 + xx, 437 - 5 + yy),
                               new Point(539 - 5 + xx, 486 - 5 + yy),
                               new Point(462 - 5 + xx, 468 - 5 + yy) };

            iPoint result = route[CounterRouteNode];

            CounterRouteNode++; if (CounterRouteNode > 4)
            {
                CounterRouteNode = 0;
            }

            return(result);
        }
Пример #5
0
        // ===============================  Методы ==================================================



        /// <summary>
        /// получаем следующую точку маршрута
        /// </summary>
        /// <returns></returns>
        public override iPoint RouteNextPoint()
        {
            iPoint[] route =
            {
                new Point(387 - 5 + xx, 461 - 5 + yy),
                new Point(311 - 5 + xx, 455 - 5 + yy),
                new Point(290 - 5 + xx, 352 - 5 + yy),
                new Point(308 - 5 + xx, 249 - 5 + yy),
                new Point(412 - 5 + xx, 267 - 5 + yy),
                new Point(498 - 5 + xx, 311 - 5 + yy),
                new Point(498 - 5 + xx, 388 - 5 + yy),
                new Point(487 - 5 + xx, 448 - 5 + yy)
            };

            iPoint result = route[counterRouteNode];

            return(result);
        }
Пример #6
0
        static ArrayList GetMonotonIntervals(iPoint[] Pts)
        {
            ArrayList result = new ArrayList();
            int n = Pts.Length;
            if (n == 0) return result;
            ArrayList L = new ArrayList();

            //----- Start with Strong Monoton (Pts[i].y < Pts[i+1].y) or (Pts[i].y > Pts[i+1].y)
            int FirstStrongMonoton = 0;
            while (Pts[FirstStrongMonoton].y == Pts[FirstStrongMonoton + 1].y) FirstStrongMonoton++;
            bool Up = (Pts[FirstStrongMonoton].y < Pts[FirstStrongMonoton + 1].y);
            MonotonInterval Interval = new MonotonInterval(Up, FirstStrongMonoton, FirstStrongMonoton);
            L.Add(Interval);
            int i = FirstStrongMonoton;
            do
            {
                // Interval.to = i;
                if ((Pts[i].y == Pts[mod(i + 1, n)].y) || (Up == (Pts[i].y < Pts[mod(i + 1, n)].y)))
                    Interval.to = i;
                else
                {
                    Up = (Pts[i].y < Pts[mod(i + 1, n)].y);
                    Interval = new MonotonInterval(Up, i, i);
                    L.Add(Interval);
                }
                i = mod(i + 1, n);
            }
            while (i != FirstStrongMonoton);

            if (L.Count / 2 * 2 != L.Count)
            {// Connect the Last with first
                MonotonInterval M0 = (MonotonInterval)L[0];
                MonotonInterval ML = (MonotonInterval)L[L.Count - 1];
                M0.from = ML.from;
                L.RemoveAt(L.Count - 1);
            }

            //----- order now by the min y - value of interval to result
            // and as second Key by the x-value
            //
            while (L.Count > 0)
            {
                MonotonInterval M = (MonotonInterval)L[0];
                i = 0;
                // order by y-value
                while ((i < result.Count) && (Pts[M.Min()].y > Pts[((MonotonInterval)result[i]).Min()].y)) i++;
                // order by x- value as second Key
                while ((i < result.Count) && (Pts[M.Min()].y == Pts[((MonotonInterval)result[i]).Min()].y) &&
                    (Pts[M.Min()].x > (Pts[((MonotonInterval)result[i]).Min()].x))) i++;
                result.Insert(i, M);
                L.RemoveAt(0);
            }
            return result;
        }
Пример #7
0
    void CheckEliminate(iPoint pt, int color, List <BubbleCell> eraseList, int threshold)
    {
        m_openTable.Clear();
        m_closedTable.Clear();
        var count = 1;

        try {
            m_openTable.Add(new iPoint(pt.x, pt.y));
            while (m_openTable.Count > 0)
            {
                int    last = m_openTable.Count - 1;
                iPoint cur  = m_openTable[last];
                m_openTable.RemoveAt(last);
                m_closedTable.Add(cur);
                var a = new iPoint(cur.x + 2, cur.y);
                if (GetBubbleColor(a.x, a.y) == color)
                {
                    if (!m_closedTable.Contains(a))
                    {
                        m_openTable.Add(a);
                        ++count;
                    }
                }
                var b = new iPoint(cur.x - 2, cur.y);
                if (GetBubbleColor(b.x, b.y) == color)
                {
                    if (!m_closedTable.Contains(b))
                    {
                        m_openTable.Add(b);
                        ++count;
                    }
                }
                var c = new iPoint(cur.x - 1, cur.y - 1);
                if (GetBubbleColor(c.x, c.y) == color)
                {
                    if (!m_closedTable.Contains(c))
                    {
                        m_openTable.Add(c);
                        ++count;
                    }
                }
                var d = new iPoint(cur.x + 1, cur.y + 1);
                if (GetBubbleColor(d.x, d.y) == color)
                {
                    if (!m_closedTable.Contains(d))
                    {
                        m_openTable.Add(d);
                        ++count;
                    }
                }
                var e = new iPoint(cur.x - 1, cur.y + 1);
                if (GetBubbleColor(e.x, e.y) == color)
                {
                    if (!m_closedTable.Contains(e))
                    {
                        m_openTable.Add(e);
                        ++count;
                    }
                }
                var f = new iPoint(cur.x + 1, cur.y - 1);
                if (GetBubbleColor(f.x, f.y) == color)
                {
                    if (!m_closedTable.Contains(f))
                    {
                        m_openTable.Add(f);
                        ++count;
                    }
                }
            }
        } finally {
            if (eraseList != null)
            {
                if (m_closedTable.Count > threshold)
                {
                    foreach (iPoint p in m_closedTable)
                    {
                        var b = GetBubble(p.x, p.y);
                        if (b != null && b.go != null)
                        {
                            m_eraseList.Add(b);
                        }
                    }
                }
            }
            m_openTable.Clear();
            m_closedTable.Clear();
        }
    }
Пример #8
0
        private void canvas1_MouseMove(object sender, MouseEventArgs e)
        {
            if (toolState>0) return;

            cur_p = new iPoint(e.GetPosition(this.canvas1));

            /* Frank: My own custom drawline with variable thickness (still needs some work)
            bm = new WriteableBitmap(canvas1, null);

            int x1 = cur_p.x;
            int y1 = cur_p.y;
            int x2 = prev_p.x;
            int y2 = prev_p.y;

            double pp_x = y1 - y2;
            double pp_y = x2 - x1;
            double mag = Math.Sqrt(pp_x * pp_x + pp_y * pp_y);

            //normalize
            pp_x /= mag;
            pp_y /= mag;

            for (int i = 0; i < Globals.brushSize; i++)
                bm.DrawLine((int)(x1 + pp_x * i), (int)(y1 + pp_y * i), (int)(x2 + pp_x * i), (int)(y2 + pp_y * i), Globals.scb.Color);

            bm.Invalidate();
            updateCanvasFromWBM(bm);
            */

            Line line = new Line() { X1 = cur_p.x, Y1 = cur_p.y, X2 = prev_p.x, Y2 = prev_p.y };
            line.Stroke = new SolidColorBrush(Globals.scb.Color);
            line.StrokeThickness = Globals.brushSize;
            line.StrokeStartLineCap = Globals.plc;

            this.canvas1.Children.Add(line);
            prev_p = cur_p;
        }
Пример #9
0
    void Sweep(List <BubbleCell> eraseList)
    {
        eraseList.Clear();
        m_openTable.Clear();
        m_closedTable.Clear();
        var cells = GetLine(0);

        if (cells != null)
        {
            for (int i = 0; i < cells.Length; ++i)
            {
                var b = GetBubble(i, 0);
                if (b != null && b.go != null)
                {
                    var pt = new iPoint(b.x, b.y);
                    m_closedTable.Add(pt);
                    m_openTable.Add(pt);
                }
            }
        }
        var count = 1;

        try {
            while (m_openTable.Count > 0)
            {
                int    last = m_openTable.Count - 1;
                iPoint cur  = m_openTable[last];
                m_openTable.RemoveAt(last);
                m_closedTable.Add(cur);
                var a  = new iPoint(cur.x + 2, cur.y);
                var aa = GetBubble(a.x, a.y);
                if (aa != null && aa.go != null)
                {
                    if (!m_closedTable.Contains(a))
                    {
                        m_openTable.Add(a);
                        ++count;
                    }
                }
                var b  = new iPoint(cur.x - 2, cur.y);
                var bb = GetBubble(b.x, b.y);
                if (bb != null && bb.go != null)
                {
                    if (!m_closedTable.Contains(b))
                    {
                        m_openTable.Add(b);
                        ++count;
                    }
                }
                var c  = new iPoint(cur.x - 1, cur.y - 1);
                var cc = GetBubble(c.x, c.y);
                if (cc != null && cc.go != null)
                {
                    if (!m_closedTable.Contains(c))
                    {
                        m_openTable.Add(c);
                        ++count;
                    }
                }
                var d  = new iPoint(cur.x + 1, cur.y + 1);
                var dd = GetBubble(d.x, d.y);
                if (dd != null && dd.go != null)
                {
                    if (!m_closedTable.Contains(d))
                    {
                        m_openTable.Add(d);
                        ++count;
                    }
                }
                var e  = new iPoint(cur.x - 1, cur.y + 1);
                var ee = GetBubble(e.x, e.y);
                if (ee != null && ee.go != null)
                {
                    if (!m_closedTable.Contains(e))
                    {
                        m_openTable.Add(e);
                        ++count;
                    }
                }
                var f  = new iPoint(cur.x + 1, cur.y - 1);
                var ff = GetBubble(f.x, f.y);
                if (ff != null && ff.go != null)
                {
                    if (!m_closedTable.Contains(f))
                    {
                        m_openTable.Add(f);
                        ++count;
                    }
                }
            }
        } finally {
            if (eraseList != null)
            {
                for (int j = 0; j < m_buffer.Count; ++j)
                {
                    var _cells = GetLine(j);
                    for (int i = 0; i < _cells.Length; ++i)
                    {
                        var b = _cells[i];
                        if (b != null && b.go != null && b.color != 0)
                        {
                            if (!m_closedTable.Contains(new iPoint(b.x, b.y)))
                            {
                                m_eraseList.Add(b);
                            }
                        }
                    }
                }
            }
            m_openTable.Clear();
            m_closedTable.Clear();
        }
    }
Пример #10
0
        static void calc_lon(Path pp)
        {
            int i, j, k, k1;
            int a, b, c, d;
            int[] ct = { 0, 0, 0, 0 };
            int dir;
            iPoint[] constraint = new iPoint[2];
            iPoint cur;
            iPoint off;
            iPoint dk;  /* direction of k-k1 */
            iPoint[] pt = pp.pt;

            int n = pt.Length;
            int[] Pivot = new int[n];
            int[] nc = new int[n];
            /* initialize the nc data structure. Point from each point to the
                 furthest future point to which it is connected by a vertical or
                 horizontal segment. We take advantage of the fact that there is
                 always a direction change at 0 (due to the path decomposition
                 algorithm). But even if this were not so, there is no harm, as
                 in practice, correctness does not depend on the word "furthest"
                 above.  */

            k = 0;
            for (i = n - 1; i >= 0; i--)
            {
                if (pt[i].x != pt[k].x && pt[i].y != pt[k].y)
                {
                    k = i + 1;  /* necessarily i<n-1 in this case */
                }
                nc[i] = k;
            }

            pp.Lon = new int[n];
            /* determine pivot points: for each i, let pivk[i] be the furthest k
            such that all j with i<j<k lie on a line connecting i,k. */

            for (i = n - 1; i >= 0; i--)
            {

                ct[0] = ct[1] = ct[2] = ct[3] = 0;

                /* keep track of "directions" that have occurred */
                dir = (3 + 3 * (pt[mod(i + 1, n)].x - pt[i].x) + (pt[mod(i + 1, n)].y - pt[i].y)) / 2;
                ct[dir]++;

                constraint[0].x = 0;
                constraint[0].y = 0;
                constraint[1].x = 0;
                constraint[1].y = 0;

                /* find the next k such that no straight line from i to k */
                k = nc[i];
                k1 = i;
                while (true)
                {
                    dir = (3 + 3 * sign(pt[k].x - pt[k1].x) + sign(pt[k].y - pt[k1].y)) / 2;
                    ct[dir]++;

                    /* if all four "directions" have occurred, cut this path */
                    if ((ct[0] == 1) && (ct[1] == 1) && (ct[2] == 1) && (ct[3] == 1))
                    {
                        Pivot[i] = k1;
                        goto foundk;
                    }

                    cur.x = pt[k].x - pt[i].x;
                    cur.y = pt[k].y - pt[i].y;

                    /* see if current constraint is violated */
                    if (xprod(constraint[0], cur) < 0 || xprod(constraint[1], cur) > 0)
                    {
                        goto constraint_viol;
                    }

                    /* else, update constraint */
                    if (abs(cur.x) <= 1 && abs(cur.y) <= 1)
                    {
                        /* no constraint */
                    }
                    else
                    {
                        off.x = cur.x + ((cur.y >= 0 && (cur.y > 0 || cur.x < 0)) ? 1 : -1);
                        off.y = cur.y + ((cur.x <= 0 && (cur.x < 0 || cur.y < 0)) ? 1 : -1);
                        if (xprod(constraint[0], off) >= 0)
                        {
                            constraint[0] = off;
                        }
                        off.x = cur.x + ((cur.y <= 0 && (cur.y < 0 || cur.x < 0)) ? 1 : -1);
                        off.y = cur.y + ((cur.x >= 0 && (cur.x > 0 || cur.y < 0)) ? 1 : -1);
                        if (xprod(constraint[1], off) <= 0)
                        {
                            constraint[1] = off;
                        }
                    }
                    k1 = k;
                    k = nc[k1];
                    if (!cyclic(k, i, k1))
                    {
                        break;
                    }
                }
            constraint_viol:
                /* k1 was the last "corner" satisfying the current constraint, and
                   k is the first one violating it. We now need to find the last
                   point along k1..k which satisfied the constraint. */

                dk.x = sign(pt[k].x - pt[k1].x);
                dk.y = sign(pt[k].y - pt[k1].y);
                cur.x = pt[k1].x - pt[i].x;
                cur.y = pt[k1].y - pt[i].y;

                /* find largest integer j such that xprod(constraint[0], cur+j*dk)
                   >= 0 and xprod(constraint[1], cur+j*dk) <= 0. Use bilinearity
                   of xprod. */
                a = xprod(constraint[0], cur);
                b = xprod(constraint[0], dk);
                c = xprod(constraint[1], cur);
                d = xprod(constraint[1], dk);
                /* find largest integer j such that a+j*b>=0 and c+j*d<=0. This
                   can be solved with integer arithmetic. */
                j = int.MaxValue;
                if (b < 0)
                {
                    j = floordiv(a, -b);
                }
                if (d > 0)
                {
                    j = min(j, floordiv(-c, d));
                }
                Pivot[i] = mod(k1 + j, n);
            foundk:
                ;
            } /* for i */

            /* clean up: for each i, let lon[i] be the largest k such that for
               all i' with i<=i'<k, i'<k<=pivk[i']. */

            j = Pivot[n - 1];
            pp.Lon[n - 1] = j;

            for (i = n - 2; i >= 0; i--)
            {
                if (cyclic(i + 1, Pivot[i], j))
                {
                    j = Pivot[i];
                }
                pp.Lon[i] = j;

            }

            for (i = n - 1; cyclic(mod(i + 1, n), j, pp.Lon[i]); i--)
            {
                pp.Lon[i] = j;

            }
        }
Пример #11
0
 public int MinY(iPoint[] Pts)
 {
     return Pts[Min()].y;
 }
Пример #12
0
 public int MaxY(iPoint[] Pts)
 {
     return Pts[Max()].y;
 }
Пример #13
0
 public static MathPoint MathPoint(this iPoint pt)
 {
     return(Mu.CreatePoint(pt.X, pt.Y, pt.Z));
 }
Пример #14
0
        /*  */
        /// <summary>
        /// Compute a path in the binary matrix.
        /// Start path at the point (x0,x1), which must be an upper left corner
        /// of the path. Also compute the area enclosed by the path. Return a
        /// new path_t object, or NULL on error (note that a legitimate path
        /// cannot have length 0). 
        /// We omit turnpolicies and sign
        /// </summary>
        /// <param name="Matrix">Binary Matrix</param>
        /// <returns></returns>
        static Path findpath(bool[,] Matrix, iPoint Start)
        {
            ArrayList L = new ArrayList();

            direction Dir = direction.North;
            int x;
            int y;
            int area = 0;
            int diry = -1;
            x = Start.x;
            y = Start.y;

            do
            {
                // area += x * diry;
                L.Add(new iPoint(x, y));
                int _y = y;
                findNextTrace(Matrix, ref x, ref y, ref Dir);
                diry = _y - y;
                area += x * diry;
            }
            while ((x != Start.x) || (y != Start.y));

            if (L.Count == 0) return null;
            Path result = new Path();
            result.pt = new iPoint[L.Count];
            result.area = area;

            for (int i = 0; i < L.Count; i++) result.pt[i] = (iPoint)L[i];

            // Shift 1 to be compatible with Potrace

            if (result.pt.Length > 0)
            {
                iPoint P = result.pt[result.pt.Length - 1];
                for (int i = result.pt.Length - 1; i >= 0; i--)
                {
                    if (i > 0)
                        result.pt[i] = result.pt[i - 1];
                    else
                        result.pt[0] = P;
                }
            }

            result.MonotonIntervals = GetMonotonIntervals(result.pt);

            return result;
        }
Пример #15
0
 public double DistanceDe3D(iPoint pt)
 {
     return(Math.Sqrt(Math.Pow(pt.X - X, 2) + Math.Pow(pt.Y - Y, 2) + Math.Pow(pt.Z - Z, 2)));
 }
Пример #16
0
 public double DistanceDe2D(iPoint pt)
 {
     return(Math.Abs(pt.DistanceDe2D(Centre) - Rayon));
 }
Пример #17
0
 public iArc(iPoint centre, double rayon, iPointOnSpline p1, iPointOnSpline p2, iPointOnSpline p3)
 {
     Centre = centre; Rayon = rayon; P1 = p1; P2 = p2; P3 = p3;
 }
Пример #18
0
 public iCercle(iPoint centre, double rayon)
 {
     Centre = centre; Rayon = rayon;
 }
Пример #19
0
 /* calculate p1 x p2 */
 static int xprod(iPoint p1, iPoint p2)
 {
     return p1.x * p2.y - p1.y * p2.x;
 }
Пример #20
0
 public frmSetPoint(String IDStudent,iPoint Input)
 {
     InitializeComponent();
     _iPoint=Input;
     _idStudent = IDStudent;
 }
Пример #21
-1
        private void canvas1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (toolState == 0)
            {
                canvas1.CaptureMouse();
                if (!activelyDrawing && toolState == 0) //just started to draw, save state first (in order to undo)
                {
                    updateUndoList();
                    activelyDrawing = true;
                }

                cur_p.x = (short)e.GetPosition(canvas1).X;
                cur_p.y = (short)e.GetPosition(canvas1).Y;

                prev_p = cur_p;
            }
            else if (toolState == 2)
            {
                bm = new WriteableBitmap(canvas1, null);
                Globals.scb.Color = bm.GetPixel((int)e.GetPosition(canvas1).X, (int)e.GetPosition(canvas1).Y);
                border2.Background = Globals.scb;
                makeToast("Color Sampled", "");
                toolState++;
                fillClick(null, null); //to move to pencil mode
                //NavigationService.Navigate(new Uri("/ColorPicker.xaml", UriKind.Relative));
            }
        }