Esempio n. 1
0
        //static bool CheckCoord(Coordinats.Coord c, int d)
        //{
        //    int x, y;
        //    x = c.GetX();
        //    y = c.GetY();
        //    try
        //    {
        //        switch (d)
        //        {
        //            case 0: //Nort
        //                if (iPole[x - 1, y] != 1 && iPole[x - 1, y] != 2 && iPole[x - 1, y] != 3 && iPole[x - 1, y] != 4 && iPole[x, y - 1] != 9)
        //                {
        //                    return true;
        //                }
        //                else
        //                    return false;
        //            case 1: //East
        //                if (iPole[x, y + 1] != 1 && iPole[x, y + 1] != 2 && iPole[x, y + 1] != 3 && iPole[x, y + 1] != 4 && iPole[x, y - 1] != 9)
        //                {
        //                    return true;
        //                }
        //                else
        //                    return false;
        //            case 2: //South
        //                if (iPole[x + 1, y] != 1 && iPole[x + 1, y] != 2 && iPole[x + 1, y] != 3 && iPole[x + 1, y] != 4 && iPole[x, y - 1] != 9)
        //                {
        //                    return true;
        //                }
        //                else
        //                    return false;
        //            case 3: //West
        //                if (iPole[x, y - 1] != 1 && iPole[x, y - 1] != 2 && iPole[x, y - 1] != 3 && iPole[x, y - 1] != 4 && iPole[x, y - 1] != 9)
        //                {
        //                    return true;
        //                }
        //                else
        //                    return false;
        //        }
        //        return false;
        //    }
        //    catch(System.IndexOutOfRangeException ex)
        //    {
        //        return false;
        //    }
        //}

        static bool CheckFCoord(Coordinats.Coord c, int d)
        {
            int x, y;

            x = c.GetX();
            y = c.GetY();
            try
            {
                switch (d)
                {
                case 0:     //Nort
                    if (fPole[x - 1, y].GetVal() == Field.cVoid)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case 1:     //East
                    if (fPole[x, y + 1].GetVal() == Field.cVoid)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case 2:     //South
                    if (fPole[x + 1, y].GetVal() == Field.cVoid)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case 3:     //West
                    if (fPole[x, y - 1].GetVal() == Field.cVoid)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (System.Exception ex)
            {
                return(false);
            }
            return(false);
        }
Esempio n. 2
0
        //static void GenForPath(int iPathLen, int iCoun)
        //{
        //    int iFTecDir, iFTecPov, iFTecPath = 0;
        //    iFTecPath = iFTecPath + iCoun;
        //    for (int p = 0; p < iPathLen; p++ )
        //    {
        //        using (System.IO.StreamWriter file = new System.IO.StreamWriter(Environment.CurrentDirectory + @"\log.txt", true))
        //        {
        //            file.WriteLine("TEST {0} {1} {2}", p, iCountPov, iCountEndPath);
        //        }
        //        iFTecDir = ElementPath.CheckDir(rndDir.Next(0, 101));
        //        iFTecPov = ElementPath.CheckPov(rndPov.Next(0,101));
        //        /*Устанавливаем направление*/
        //        ep[iFTecPath].SetDirection(iFTecDir);
        //        /*Устанавливаем поворот*/
        //        ep[iFTecPath].SetPovorot(iFTecPov);
        //        if (iFTecPov == 0)
        //        {
        //            if (CheckCoord(ep[iFTecPath].Cord, iFTecDir) == true)
        //            {
        //                /*Установить элемент пути*/
        //                ep[iFTecPath].SetCoord(SetPosPath(ep[iFTecPath].Cord, iFTecPath, iFTecDir));
        //                iPathLen--;
        //                bLuck = true;
        //            }
        //            else
        //            {
        //                p--;
        //                bLuck = false;
        //            }
        //        }
        //        else
        //        {
        //            if (iCountPov != 0)
        //            {
        //                if (iCountEndPath > iFTecPath)
        //                {
        //                    for (int p2 = 0; p2 < iFTecPov; p2++)
        //                    {
        //                        GenForPath(GenSymplePath(iFTecPath + 1, ep[iFTecPath].Cord.GetX(), ep[iFTecPath].Cord.GetY()), iFTecPath+1);
        //                    }
        //                    iCountEndPath--;
        //                }
        //                iCountPov--;
        //            }
        //        }
        //    }
        //}

        static Coordinats.Coord SetPosFPath(Coordinats.Coord c, int iPath, int d, int p)
        {
            int x, y;

            x = c.GetX();
            y = c.GetY();
            switch (d)
            {
            case 0:
                //iPole[x - 1, y] = 1;
                fPole[x, y].SetValue(/*Field.cCUPer*/ GetNextEl(ep[iPath].GetPrevDirInt(), p, d), ep[iPath]);  //= 1;
                ep[iPath].SetCoord(c);
                Console.WriteLine("ZN {0} DIR 0 NEW X{1} NEW Y{2} X{3} Y{4}", 1, x - 1, y, x, y);
                return(new Coordinats.Coord(x - 1, y));

            case 1:
                //iPole[x, y + 1] = 2;
                fPole[x, y].SetValue(GetNextEl(ep[iPath].GetPrevDirInt(), p, d), ep[iPath]);
                ep[iPath].SetCoord(c);
                Console.WriteLine("ZN {0} DIR 1 NEW X{1} NEW Y{2} X{3} Y{4}", 2, x, y + 1, x, y);
                return(new Coordinats.Coord(x, y + 1));

            case 2:
                //iPole[x + 1, y] = 3;
                fPole[x, y].SetValue(GetNextEl(ep[iPath].GetPrevDirInt(), p, d), ep[iPath]);
                ep[iPath].SetCoord(c);
                Console.WriteLine("ZN {0} DIR 2 NEW X{1} NEW Y{2} X{3} Y{4}", 3, x + 1, y, x, y);
                return(new Coordinats.Coord(x + 1, y));

            case 3:
                //iPole[x, y - 1] = 4;
                fPole[x, y].SetValue(GetNextEl(ep[iPath].GetPrevDirInt(), p, d), ep[iPath]);
                ep[iPath].SetCoord(c);
                Console.WriteLine("ZN {0} DIR 3 NEW X{1} NEW Y{2} X{3} Y{4}", 4, x, y - 1, x, y);
                return(new Coordinats.Coord(x, y - 1));
            }
            return(new Coordinats.Coord(c));
        }
Esempio n. 3
0
        static Coordinats.Coord SetPosPath(Coordinats.Coord c, int iPath, int d)
        {
            int x, y;

            x = c.GetX();
            y = c.GetY();
            switch (d)
            {
            case 0:
                //iPole[x - 1, y] = 1;
                iPole[x, y] = 1;
                ep[iPath].SetCoord(c);
                Console.WriteLine("ZN {0} DIR 0 NEW X{1} NEW Y{2} X{3} Y{4}", 1, x - 1, y, x, y);
                return(new Coordinats.Coord(x - 1, y));

            case 1:
                //iPole[x, y + 1] = 2;
                iPole[x, y] = 2;
                ep[iPath].SetCoord(c);
                Console.WriteLine("ZN {0} DIR 1 NEW X{1} NEW Y{2} X{3} Y{4}", 2, x, y + 1, x, y);
                return(new Coordinats.Coord(x, y + 1));

            case 2:
                //iPole[x + 1, y] = 3;
                iPole[x, y] = 3;
                ep[iPath].SetCoord(c);
                Console.WriteLine("ZN {0} DIR 2 NEW X{1} NEW Y{2} X{3} Y{4}", 3, x + 1, y, x, y);
                return(new Coordinats.Coord(x + 1, y));

            case 3:
                //iPole[x, y - 1] = 4;
                iPole[x, y] = 4;
                ep[iPath].SetCoord(c);
                Console.WriteLine("ZN {0} DIR 3 NEW X{1} NEW Y{2} X{3} Y{4}", 4, x, y - 1, x, y);
                return(new Coordinats.Coord(x, y - 1));
            }
            return(new Coordinats.Coord(c));
        }
Esempio n. 4
0
 public void SetCoord(Coordinats.Coord c)
 {
     this.Cord.Add(c);
 }