/// <summary>
 /// Checks collision on the side of the chunk.
 /// </summary>
 /// <param name="creature"></param>
 /// <returns></returns>
 public Boolean checkSideCollision(Mob creature)
 {
     //creature.moveY(-1);
     bool result = (creature.getY() - 2 + creature.getHeight() >= ResourceHandler.getInstance().getBottom() - height);
     //creature.moveY(1);
     return result;
 }
 /// <summary>
 /// Checks collision of the entity on the BoundingBox.
 /// </summary>
 /// <param name="creature"></param>
 /// <returns></returns>
 public Boolean checkCollision(Mob creature)
 {
     if (creature.getY() + creature.getHeight() == ResourceHandler.getInstance().getBottom() - height) return true;
     else if (creature.getY() + creature.getHeight() > ResourceHandler.getInstance().getBottom() - height)
     {
         creature.setY(creature.getY() - 1);
         return true;
     }
     return false;
 }
示例#3
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);
        }
示例#4
0
        /// <summary>
        /// Removes an entity from the Dungeon.
        /// </summary>
        /// <param name="entity"></param>
        public void removeEntity(Mob entity)
        {
            if (entities == null) return;

            entities.Remove(entity);
        }
示例#5
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);
        }
示例#6
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;
        }
示例#7
0
        /// <summary>
        /// Adds an entity into the dungeon to be rendered.
        /// </summary>
        /// <param name="entity">The entity to be added.</param>
        public void addEntity(Mob entity)
        {
            Logger.getInstance().log("Entity Created.");
            if (entities == null) entities = new MobContainer();

            entities.Add(entity);
        }
示例#8
0
 public virtual void attack(Mob creature)
 {
     int damage = new Random().Next(5);
     creature.damageEntity(damage);
 }
示例#9
0
 /// <summary>
 /// Gets the distance from another entity.
 /// </summary>
 /// <param name="creature"></param>
 /// <returns></returns>
 public float getDistanceFrom(Mob creature)
 {
     return Vector2.Distance(getVector(), creature.getVector());
 }
示例#10
0
        /// <summary>
        /// Checks entity collision.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool collidingWith(Mob entity)
        {
            if (getVector().X + getWidth() >= entity.getVector().X && getVector().X <= entity.getVector().X + entity.getWidth())
            {
                if (getVector().Y + getHeight() >= entity.getVector().Y && getVector().Y <= entity.getVector().Y + entity.getHeight())
                {
                    return true;
                }
            }

            return false;
        }
示例#11
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;
        }
示例#12
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);
        }
示例#13
0
        public override void attack(Mob creature)
        {
            int damage = 0;
            if (weapon != null) damage = getWeapon().getAttack().getValue();
            damage += (this.getStrength().getValue() / 7) * 5;

            int c = (new Random()).Next(1, 100);
            if (c <= this.getStrength().getValue()) damage *= 2;

            creature.getHealth().setValue(creature.getHealth().getValue() - damage/3);
            //creature.setHealthValue(creature.getHealth().getValue() - damage);
        }