Пример #1
0
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public bool areEqual(CLoc other)
 {
     if (other == null)
     {
         return(false);
     }
     return(x == other.x && y == other.y);
 }
Пример #2
0
        //////////////////////////////////////////////////////////////////////
        //Returns Location based on x/y shifts
        //Returns null if invalid
        public CLoc getLocationFromAdjustment(CLoc loc, int xAdj, int yAdj)
        {
            if (!validLoc(loc, xAdj, yAdj))
            {
                return(null);
            }
            int ux = hwash(loc.x + xAdj);
            int uy = vwash(loc.y + yAdj);

            return(new CLoc(ux, uy));
        }
Пример #3
0
        //////////////////////////////////////////////////////////////////////
        //returns List of all valid locations surrounding specifieed loc up to specified range
        public List <CLoc> getSurroundingRng(CLoc loc, int rng)
        {
            var ret = new List <CLoc>();

            if (rng == 0)
            {
                return(ret);
            }


            int ec = 1;
            int sc = 2;
            int wc = 2;
            int nc = 2;


            int rc = 1;
            int x  = loc.x;
            int y  = loc.y;

            while (rc <= rng)
            {
                y--;//1N
                if (validLoc(x, y))
                {
                    ret.Add(washLoc(x, y));
                }
                //east
                for (int i = 0; i < ec; i++)
                {
                    x++;
                    if (validLoc(x, y))
                    {
                        ret.Add(washLoc(x, y));
                    }
                }
                //south
                for (int i = 0; i < sc; i++)
                {
                    y++;
                    if (validLoc(x, y))
                    {
                        ret.Add(washLoc(x, y));
                    }
                }
                //west
                for (int i = 0; i < wc; i++)
                {
                    x--;
                    if (validLoc(x, y))
                    {
                        ret.Add(washLoc(x, y));
                    }
                }
                //north
                for (int i = 0; i < nc; i++)
                {
                    y--;
                    if (validLoc(x, y))
                    {
                        ret.Add(washLoc(x, y));
                    }
                }

                rc++;
                ec += 2;
                sc += 2;
                wc += 2;
                nc += 2;
            }

            return(ret);
        }
Пример #4
0
 //////////////////////////////////////////////////////////////////////
 //returns shortest distance between two locations
 public int getLocRange(CLoc A, CLoc B)
 {
     return(getLocRange(A.x, A.y, B.x, B.y));
 }
Пример #5
0
 //////////////////////////////////////////////////////////////////////
 //Returns a location based on shifting from a dirextion and distance
 //Returns null if invalid
 public CLoc getLocationFromDir(CLoc L, int dir, int dist)
 {
     return(getLocationFromDir(L.x, L.y, dir, dist));
 }
Пример #6
0
 //////////////////////////////////////////////////////////////////////
 //Determines Validity of an X/Y shifted location
 public bool validLoc(CLoc loc, int xAdj, int yAdj)
 {
     return(validLoc(loc.x + xAdj, loc.y + yAdj));
 }
Пример #7
0
 public void set(CLoc loc)
 {
     x = loc.x;
     y = loc.y;
 }
Пример #8
0
 public CLoc(CLoc loc)
 {
     x = loc.x;
     y = loc.y;
 }