Example #1
0
 public LetterInWord(int index, CoOrd letterCoord, char letter, List<CoOrd> neighborhood)
 {
     _index = index;
     _letterCoord = letterCoord;
     _letter = letter;
     _neighborhoods = neighborhood;
 }
Example #2
0
        public List<CoOrd> GetCellNeighborhoods(CoOrd coOrd)
        {
            List<CoOrd> allNeighborhoods = new List<CoOrd>();

            int x;
            int y;

            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    x = coOrd.x;
                    y = coOrd.y;
                    x += i;
                    y += j;

                    if (_pathOfword.ContainsCoord(new CoOrd(x, y)))
                    {
                        continue;
                    }

                    if ((x >= 0 && x < _x) && (y >= 0 && y < _y))
                    {
                        //Console.WriteLine("GetCellNeighborhoods: ({0};{1})", x, y);
                        allNeighborhoods.Add(new CoOrd(x, y));
                    }

                }
            }
            allNeighborhoods.Remove(new CoOrd(coOrd.x, coOrd.y));
            return allNeighborhoods;
        }
Example #3
0
 public bool ContainsCoord(CoOrd coord)
 {
     if (_coordPath.Contains(coord))
     {
         return true;
     }
     return false;
 }
 public void CalculateAdditionalPos()
 {
     additionalPos = new CoOrd[noOfOffsets];
     for (int i = 0; i < additionalPos.Length; i++)
     {
         additionalPos[i] = new CoOrd(pos.xCord + offsets[i].xCord, pos.yCord + offsets[i].yCord);
     }
 }
 public bool CheckIfCoordsAreFree(CoOrd[] coords,int width,Tetris.mapVal[,] map)
 {
     for (int i = 0; i < coords.Length; i++)
     {
         if (pos.xCord + coords[i].xCord < 0 ||
             pos.xCord + coords[i].xCord >= width ||
             map[pos.xCord + coords[i].xCord, pos.yCord + coords[i].yCord].cubeInPos
             && !CheckIfCoOrdInBlock(new CoOrd(pos.xCord + coords[i].xCord, pos.yCord + coords[i].yCord)))
         {
             return false;
         }
     }
     return true;
 }
 public bool CheckIfCoOrdInBlock(CoOrd coord)
 {
     if (pos.xCord == coord.xCord && pos.yCord == coord.yCord)
     {
         return true;
     }
     for (int i = 0; i < additionalPos.Length; i++)
     {
         if (additionalPos[i].xCord == coord.xCord && additionalPos[i].yCord == coord.yCord)
         {
             return true;
         }
     }
     return false;
 }
Example #7
0
        public void ArrayDetour()
        {
            List<Thread> thread = new List<Thread>(); ;
            for (int x = 0; x < _x; x++)
            {

                for (int y = 0; y < _y; y++)
                {
                    //_wordPath = new WordPath();
                    //GraphDetour(new CoOrd(x, y));
                    object coord = new CoOrd(x, y);
                    //Thread t = new Thread(new ThreadStart(GraphDetour(coord));
                    thread.Add(new Thread(GraphDetour));
                    thread.Last().Start(coord);

                    //int status = GraphDetour(new CoOrd(0, 0));

                    //_MW.FieldUpdate(_path);
                    //return;
                }
            }
        }
Example #8
0
 public void PopNeighborhood(CoOrd coord)
 {
     _neighborhoods.Remove(coord);
 }
 private void SetRotationOffsets(CoOrd[] verticalOffsets, CoOrd[] horizontalOffsets, int limit, Tetris.mapVal[,] map)
 {
     if (rotation == 0 && CheckIfCoordsAreFree(horizontalOffsets, limit, map))
     {
         for (int i = 0; i < offsets.Length; i++)
         {
             offsets[i] = horizontalOffsets[i];
         }
         rotation = 90;
     }
     else if (rotation == 90)
     {
         CoOrd[] flippedCoords = new CoOrd[3];
         for (int i = 0; i < flippedCoords.Length; i++)
         {
             flippedCoords[i].xCord = verticalOffsets[i].xCord * -1;
             flippedCoords[i].yCord = verticalOffsets[i].yCord * -1;
         }
         if (CheckIfCoordsAreFree(flippedCoords, limit, map))
         {
             for (int i = 0; i < offsets.Length; i++)
             {
                 offsets[i] = flippedCoords[i];
             }
         }
         rotation = 180;
     }
     else if (rotation == 180)
     {
         CoOrd[] flippedCoords = new CoOrd[3];
         for (int i = 0; i < flippedCoords.Length; i++)
         {
             flippedCoords[i].xCord = horizontalOffsets[i].xCord * -1;
             flippedCoords[i].yCord = horizontalOffsets[i].yCord * -1;
         }
         if (CheckIfCoordsAreFree(flippedCoords, limit, map))
         {
             for (int i = 0; i < offsets.Length; i++)
             {
                 offsets[i] = flippedCoords[i];
             }
         }
         rotation = 270;
     }
     else if (rotation == 270 && CheckIfCoordsAreFree(verticalOffsets, limit, map))
     {
         for (int i = 0; i < offsets.Length; i++)
         {
             offsets[i] = verticalOffsets[i];
         }
         rotation = 0;
     }
 }
    public void RotateBlock(int limit, Tetris.mapVal[,] map)
    {
        switch (shape)
        {
            case Shapes.LShape:
                CoOrd[] verticalOffsets = new CoOrd[3];
                CoOrd[] horizontalOffsets = new CoOrd[3];

                verticalOffsets[0] = new CoOrd(0, 1);
                verticalOffsets[1] = new CoOrd(0, -1);
                verticalOffsets[2] = new CoOrd(1, -1);

                horizontalOffsets[0] = new CoOrd(1, 0);
                horizontalOffsets[1] = new CoOrd(-1, 0);
                horizontalOffsets[2] = new CoOrd(-1, -1);

                SetRotationOffsets(verticalOffsets, horizontalOffsets, limit, map);
                break;
            case Shapes.IShape:
                verticalOffsets = new CoOrd[3];
                horizontalOffsets = new CoOrd[3];

                verticalOffsets[0] = new CoOrd(0, -1);
                verticalOffsets[1] = new CoOrd(0, 1);
                verticalOffsets[2] = new CoOrd(0, 2);

                horizontalOffsets[0] = new CoOrd(-1, 0);
                horizontalOffsets[1] = new CoOrd(1, 0);
                horizontalOffsets[2] = new CoOrd(2, 0);

                SetRotationOffsets(verticalOffsets, horizontalOffsets, limit, map);
                break;
            case Shapes.CubeShape:
                //Do nothing
                break;
            case Shapes.TShape:
                verticalOffsets = new CoOrd[3];
                horizontalOffsets = new CoOrd[3];

                verticalOffsets[0] = new CoOrd(0, -1);
                verticalOffsets[1] = new CoOrd(1, 0);
                verticalOffsets[2] = new CoOrd(-1, 0);

                horizontalOffsets[0] = new CoOrd(0, -1);
                horizontalOffsets[1] = new CoOrd(0, 1);
                horizontalOffsets[2] = new CoOrd(-1, 0);

                SetRotationOffsets(verticalOffsets, horizontalOffsets, limit, map);
                break;
            case Shapes.JShape:
                verticalOffsets = new CoOrd[3];
                horizontalOffsets = new CoOrd[3];

                verticalOffsets[0] = new CoOrd(0, 1);
                verticalOffsets[1] = new CoOrd(0, -1);
                verticalOffsets[2] = new CoOrd(-1, -1);

                horizontalOffsets[0] = new CoOrd(1, 0);
                horizontalOffsets[1] = new CoOrd(-1, 0);
                horizontalOffsets[2] = new CoOrd(-1, 1);

                SetRotationOffsets(verticalOffsets, horizontalOffsets, limit, map);
                break;
        }
    }
 public void GetOffsets()
 {
     int selector = Random.Range(0, 5);
     if (AI) { selector = 1; }
     if (selector == 0)
     {
         noOfOffsets = 3;
         offsets = new CoOrd[noOfOffsets];
         offsets[0] = new CoOrd(0, 1);
         offsets[1] = new CoOrd(0, -1);
         offsets[2] = new CoOrd(1, -1);
         blockColor = Color.blue;
         shape = Shapes.LShape;
     }
     else if (selector == 1)
     {
         noOfOffsets = 3;
         offsets = new CoOrd[noOfOffsets];
         offsets[0] = new CoOrd(0, -1);
         offsets[1] = new CoOrd(0, 1);
         offsets[2] = new CoOrd(0, 2);
         blockColor = Color.yellow;
         shape = Shapes.IShape;
     }
     else if (selector == 2)
     {
         noOfOffsets = 3;
         offsets = new CoOrd[noOfOffsets];
         offsets[0] = new CoOrd(0, 1);
         offsets[1] = new CoOrd(1, 0);
         offsets[2] = new CoOrd(1, 1);
         blockColor = Color.red;
         shape = Shapes.CubeShape;
     }
     else if (selector == 3)
     {
         noOfOffsets = 3;
         offsets = new CoOrd[noOfOffsets];
         offsets[0] = new CoOrd(0, -1);
         offsets[1] = new CoOrd(1, 0);
         offsets[2] = new CoOrd(-1, 0);
         blockColor = Color.green;
         shape = Shapes.TShape;
     }
     else if (selector == 4)
     {
         noOfOffsets = 3;
         offsets = new CoOrd[noOfOffsets];
         offsets[0] = new CoOrd(0, 1);
         offsets[1] = new CoOrd(0, -1);
         offsets[2] = new CoOrd(-1, -1);
         blockColor = Color.white;
         shape = Shapes.JShape;
     }
 }
 public CoOrd[] GetInhabitedCoords()
 {
     CoOrd[] returnArr = new CoOrd[additionalPos.Length + 1];
     returnArr[0] = pos;
     for (int i = 1; i < additionalPos.Length + 1; i++)
     {
         returnArr[i] = additionalPos[i - 1];
     }
     return returnArr;
 }