Пример #1
0
        /// <summary>
        /// checks for top collision from the entity from the left. 
        /// </summary>
        /// <param name="creature"></param>
        /// <returns></returns>
        public virtual bool checkLeftTopCollision(Mob creature)
        {
            int boxNum = creature.getX() % CHUNKWIDTH / (CHUNKWIDTH / boundingBoxes.Count);

            if (creature.getX() - chunkPos * CHUNKWIDTH <= 0)
            {
                boxNum = 0;
            }

            if (boxNum >= boundingBoxes.Count) return false;

            return boundingBoxes.ElementAt(boxNum).checkCollision(creature);
        }
Пример #2
0
        /// <summary>
        /// Gets the chunk right of the entity
        /// </summary>
        /// <param name="creature"></param>
        /// <returns></returns>
        public Chunk getCurrentChunkRight(Mob creature)
        {
            int chunkNum = (creature.getX() + creature.getWidth()) / Chunk.CHUNKWIDTH; //InputManager.getInstance().getCurrentPlayer().getWidth();

            for (int i = 0; i < rooms.Count; i++)
            {
                if (rooms.ElementAt(i).getSize() <= chunkNum)
                {
                    chunkNum -= rooms.ElementAt(i).getSize();
                }
                else
                {
                    return rooms.ElementAt(i).getChunk(chunkNum);
                }
            }
            return new SquareChunk(-1, Int32.MaxValue);
        }
Пример #3
0
        /// <summary>
        /// Gets the chunk left of the entity.
        /// </summary>
        /// <param name="creature"></param>
        /// <returns></returns>
        public Chunk getCurrentChunkLeft(Mob creature)
        {
            if (creature.getX() < 0 && creature.getX() > -Chunk.CHUNKWIDTH) return starter;
            int chunkNum = (creature.getX()) / Chunk.CHUNKWIDTH; //InputManager.getInstance().getCurrentPlayer().getWidth();

            for (int i = 0; i < rooms.Count; i++)
            {
                if (rooms.ElementAt(i).getSize() <= chunkNum)
                {
                    chunkNum -= rooms.ElementAt(i).getSize();
                }
                else
                {
                    return rooms.ElementAt(i).getChunk(chunkNum);
                }
            }
            return null;
        }
Пример #4
0
        /// <summary>
        /// Checks if the entity is even inside of the chunk.
        /// </summary>
        /// <param name="creature"></param>
        /// <returns></returns>
        public virtual bool isInside(Mob creature)
        {
            int creatureX = creature.getX();

            if (creatureX < chunkPos * CHUNKWIDTH + CHUNKWIDTH)
            {
                if (creatureX > chunkPos * CHUNKWIDTH)
                {
                    return true;
                }
            }

            return false;
        }
Пример #5
0
        /// <summary>
        /// Checks for collision of entity from the right side of the chunk. 
        /// </summary>
        /// <param name="creature"></param>
        /// <returns></returns>
        public bool checkRightSideCollision(Mob creature)
        {
            int boxNum = (creature.getX() + creature.getWidth()) % CHUNKWIDTH / (CHUNKWIDTH / boundingBoxes.Count);

            if (creature.getX() + creature.getWidth() - chunkPos * CHUNKWIDTH <= 0)
            {
                boxNum = 0;
            }

            if (boxNum >= boundingBoxes.Count) return false;

            return boundingBoxes.ElementAt(boxNum).checkSideCollision(creature);
        }