Пример #1
0
 public Case(AbsCase Wrapped, Grille g)
 {
     PosX         = Wrapped.X;
     PosY         = Wrapped.Y;
     Type         = Wrapped.Type;
     m_Grille     = g;
     this.Wrapped = Wrapped;
     GCost        = 0;
     HCost        = 0;
     FCost        = 0;
 }
Пример #2
0
 public CollisionInfo(CollisionSide side, AbsCase Case)
 {
     this.Side = side;
     this.Case = Case;
 }
Пример #3
0
        /// <summary>
        /// Calcule et donne un tableau contenant les cases dans lesquelles se trouve l'entité
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public AbsCase[] GetCasesIn(int x, int y)
        {
            int  n = 1, i = 0;
            int  x1, x2, y1, y2;
            bool bx, by;

            AbsCase[] ret;

            x1 = (x) / Map.EntityPixelPerCase;
            x2 = (x + Size - 1) / Map.EntityPixelPerCase;
            y1 = (y) / Map.EntityPixelPerCase;
            y2 = (y + Size - 1) / Map.EntityPixelPerCase;

            if (y2 >= Map.NoCase)
            {
                y2 = Map.NoCase - 1;
                if (y1 >= Map.NoCase)
                {
                    y1 = Map.NoCase - 1;
                }
            }

            if (x2 >= Map.NoCase)
            {
                x2 = Map.NoCase - 1;
                if (x1 >= Map.NoCase)
                {
                    x1 = Map.NoCase - 1;
                }
            }
            if (x1 < 0)
            {
                x1 = 0;
                if (x2 < 0)
                {
                    x2 = 0;
                }
            }
            if (y1 < 0)
            {
                y1 = 0;
                if (y2 < 0)
                {
                    y2 = 0;
                }
            }
            bx = (x1 != x2);
            by = (y1 != y2);
            if (bx)
            {
                n <<= 1;
            }
            if (by)
            {
                n <<= 1;
            }
            ret = new AbsCase[n];

            ret[i++] = Map[x1, y1];

            if (bx)
            {
                ret[i++] = Map[x2, y1];
            }
            if (by)
            {
                ret[i++] = Map[x1, y2];
            }
            if (bx && by)
            {
                ret[i] = Map[x2, y2];
            }

            return(ret);
        }