Exemple #1
0
        public void Constructor()
        {
            var a = new V2I();

            Assert.Zero(a.X);
            Assert.Zero(a.Y);

            var b = new V2I(1, 2);

            Assert.AreEqual(1, b.X);
            Assert.AreEqual(2, b.Y);
        }
Exemple #2
0
        public void IEquatableImpl()
        {
            var a  = new V2I(1, 2);
            var b  = new V2I(1, 2);
            var c  = new V2I(1, 3);
            var d  = new V2I(2, 2);
            var ec = EqualityComparer <V2I> .Default;

            Assert.True(ec.Equals(a, b));
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
            Assert.False(ec.Equals(a, c));
            Assert.False(ec.Equals(a, d));
            Assert.False(ec.Equals(c, d));
        }
Exemple #3
0
        public V2I ClampInPlace(V2I coord)
        {
            if (coord.Col < 0)
            {
                coord.x = 0;
            }
            else if (coord.Col >= Size.Col)
            {
                coord.x = XMax;
            }

            if (coord.Row < 0)
            {
                coord.y = 0;
            }
            else if (coord.Row >= Size.Row)
            {
                coord.y = YMax;
            }

            return(coord);
        }
Exemple #4
0
    public bool DeQuyMap(V2I pointJoin, List <V2I> listPointDeQuy, int[,] mapDeQuy, int directMap)
    {
        List <V2I> listPointPossile = new List <V2I>();
        // create path from join point
        int x      = pointJoin.X;
        int y      = pointJoin.Y;
        int option = 0; // 0: move len, 1: move xuong: 2 move sang

        // lap ra tat ca cac diem co the join
        while (isPointValid(x, y, mapDeQuy))
        {
            listPointPossile.Add(new V2I(x, y)); // nho remove 0 pos
            if (option == 0)
            {
                y = y + 1;
                if (y - pointJoin.Y == 3)
                {
                    if (directMap == 0)
                    {
                        if (isPointValid(x, y, mapDeQuy) && isPointValid(x + 1, y, mapDeQuy) && isPointValid(x + 2, y, mapDeQuy))
                        {
                            listPointPossile.Add(new V2I(x, y));
                            listPointPossile.Add(new V2I(x + 1, y));
                            listPointPossile.Add(new V2I(x + 2, y));
                            x      = x + 2;
                            option = 1;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (isPointValid(x, y, mapDeQuy) && isPointValid(x - 1, y, mapDeQuy) && isPointValid(x - 2, y, mapDeQuy))
                        {
                            listPointPossile.Add(new V2I(x, y));
                            listPointPossile.Add(new V2I(x - 1, y));
                            listPointPossile.Add(new V2I(x - 2, y));
                            x      = x + 2;
                            option = 1;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    option = 2;
                }
            }
            else if (option == 1)
            {
                y = y - 1;
            }
            else if (option == 2)
            {
                if (directMap == 0)
                {
                    x = x + 1;
                }
                else
                {
                    x = x - 1;
                }
            }
        }


        // 2 kha nang xay ra o day, la x la diem cuoi o map hay x = 2 hoac la 31 , thi return true

        // neu x chua bang 2 hoac 31, thi chon ra 1 pointJoin bat ky de tiep tuc de quy
        // random 1 diem bat ky

        // remove diem ay ra khoi list

        // tiep tuc de quy

        return(true);
    }
Exemple #5
0
 public Window(V2I from, V2I to)
 {
     From = from;
     To   = to;
 }
Exemple #6
0
 public Window(int colFrom, int rowFrom, int colTo, int rowTo)
 {
     From = new V2I(colFrom, rowFrom);
     To   = new V2I(colTo, rowTo);
 }
Exemple #7
0
 public Window GetWindow(V2I from, V2I to)
 {
     return(GetWindow(from.Row, to.Row, from.Col, to.Col));
 }
Exemple #8
0
 public int Index(V2I coord)
 {
     return(coord.Row * Size.Col + coord.Col);
 }
Exemple #9
0
 public Coord(int rowSize, int colSize)
 {
     this.Size = new V2I(colSize, rowSize);
 }