Ejemplo n.º 1
0
 public CollisionInfo(CollisionSide side, AbsCase Case)
 {
     this.Side = side;
     this.Case = Case;
 }
Ejemplo n.º 2
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  x2, y1, y2;
            bool bx, by;

            AbsCase[] ret;

            int 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);
        }