Example #1
0
 /// <summary>
 /// Creates new Pawn
 /// </summary>
 /// <param name="x">position x of a pawn</param>
 /// <param name="y">position y of a pawn</param>
 public Pawn(int x, int y, Element.Direction krawedz, int wartosc)
 {
     this.x = x;
     this.y = y;
     this.wartosc = wartosc;
     this.krawedz = krawedz;
 }
Example #2
0
 public List<Element> XDocParse()
 {
     List<Element> tempElements = new List<Element>();
     Element tempElement;
     foreach (XmlNode elem in xNode)
     {
         tempElement = new Element(elem.FirstChild.InnerText, elem.FirstChild.NextSibling.InnerText, elem.FirstChild.NextSibling.NextSibling.InnerText, elem.FirstChild.NextSibling.NextSibling.NextSibling.InnerText, elem.LastChild.PreviousSibling.InnerText, elem.LastChild.InnerText);
         tempElements.Add(tempElement);
     }
     return tempElements;
 }
Example #3
0
File: Board.cs Project: Arasho/GR
        private void initBoard()
        {
            _board = new Element[20][];
            x = new VertexPositionTexture[sizeX][][];
            for (int i = 0; i < sizeX; i++) {
                x[i] = new VertexPositionTexture[sizeY][];
                _board[i] = new Element[20];

                for (int j = 0; j < sizeY; j++) {
                    x[i][j] = new VertexPositionTexture[4];
                }
            }
        }
Example #4
0
File: Board.cs Project: Arasho/GR
        private void GenerateBoard()
        {
            for (int i = 0; i < sizeX; i++) {
                for (int j = 0; j < sizeY; j++) {
                    x[i][j][0] = new VertexPositionTexture(new Vector3(i, j + size, 0), new Vector2(0, 0));
                    x[i][j][1] = new VertexPositionTexture(new Vector3(i + size, j + size, 0), new Vector2(1, 0));
                    x[i][j][2] = new VertexPositionTexture(new Vector3(i, j, 0), new Vector2(0, 1));
                    x[i][j][3] = new VertexPositionTexture(new Vector3(i + size, j, 0), new Vector2(1, 1));

                    _board[i][j] = new Element(x[i][j], txt1);
                }
            }
        }
Example #5
0
File: Board.cs Project: Arasho/GR
        private int FloodFill(Point node, Element.Direction kierunek, int szukanaKrawedz)
        {
            int numberOfShield = 0;
            Element target = _board[node.X][node.Y];
            if (target.additional == 1) // jesli jest katedrÄ…
                return 5;

            bool first = true;
            Queue<Point> Q = new Queue<Point>();
            List<Point> policzone = new List<Point>();

            if (szukanaKrawedz == (int)Element.Edges.EndRoad) szukanaKrawedz = (int)Element.Edges.Road;
            if (szukanaKrawedz == (int)Element.Edges.EndTown) szukanaKrawedz = (int)Element.Edges.Town;

            Q.Enqueue(node);
            while (Q.Count != 0)
            {
                Point n = Q.Dequeue();
                if (_board[n.X][n.Y].additional == 2 && !policzone.Contains(new Point(n.X, n.Y)))
                    numberOfShield += 1;
                if (first)
                {

                    if (n.X < _board.Length - 1 && n.Y < _board[0].Length - 1 && n.X >= 1 && n.Y >= 1)
                    {
                        policzone.Add(n);
                        target = _board[n.X][n.Y];
                        if (!policzone.Contains(new Point(n.X - 1, n.Y)) && (target.leftEdge == szukanaKrawedz || target.leftEdge == szukanaKrawedz + 1) && _board[n.X - 1][n.Y].rightEdge != -10)
                        {
                            Q.Enqueue(new Point(n.X - 1, n.Y));
                        }

                        if (!policzone.Contains(new Point(n.X + 1, n.Y)) && (target.rightEdge == szukanaKrawedz || target.rightEdge == szukanaKrawedz + 1) && _board[n.X + 1][n.Y].leftEdge != -10)
                        {
                            Q.Enqueue(new Point(n.X + 1, n.Y));
                        }

                        if (!policzone.Contains(new Point(n.X, n.Y + 1)) && (target.upEdge == szukanaKrawedz || target.upEdge == szukanaKrawedz + 1) && _board[n.X][n.Y + 1].bottomEdge != -10)
                        {
                            Q.Enqueue(new Point(n.X, n.Y + 1));
                        }

                        if (!policzone.Contains(new Point(n.X, n.Y - 1)) && (target.bottomEdge == szukanaKrawedz || target.bottomEdge == szukanaKrawedz + 1) && _board[n.X][n.Y - 1].upEdge != -10)
                        {
                            Q.Enqueue(new Point(n.X, n.Y - 1));
                        }
                        first = false;
                    }
                }
                else
                {

                    if (n.X < _board.Length - 1 && n.Y < _board[0].Length - 1 && n.X >= 1 && n.Y >= 1)
                    {
                        policzone.Add(n);
                        target = _board[n.X][n.Y];
                        if (!policzone.Contains(new Point(n.X - 1, n.Y)) && (target.leftEdge == szukanaKrawedz) && _board[n.X - 1][n.Y].rightEdge != -10)
                        {
                            Q.Enqueue(new Point(n.X - 1, n.Y));
                        }

                        if (!policzone.Contains(new Point(n.X + 1, n.Y)) && (target.rightEdge == szukanaKrawedz) && _board[n.X + 1][n.Y].leftEdge != -10)
                        {
                            Q.Enqueue(new Point(n.X + 1, n.Y));
                        }

                        if (!policzone.Contains(new Point(n.X, n.Y + 1)) && (target.upEdge == szukanaKrawedz) && _board[n.X][n.Y + 1].bottomEdge != -10)
                        {
                            Q.Enqueue(new Point(n.X, n.Y + 1));
                        }

                        if (!policzone.Contains(new Point(n.X, n.Y - 1)) && (target.bottomEdge == szukanaKrawedz) && _board[n.X][n.Y - 1].upEdge != -10)
                        {
                            Q.Enqueue(new Point(n.X, n.Y - 1));
                        }
                    }
                }
            }
            if (numberOfShield != 0)
            {
                int sum = 0;
                sum = policzone.Count * (numberOfShield *2);
                return sum;
            }
            else
                return policzone.Count;
        }