Пример #1
0
        /// <summary>
        /// Sets the Dungeon that is currently being played through.
        /// </summary>
        /// <param name="dungeon"></param>
        public void setCurrentDungeon(Dungeon dungeon)
        {
            if(currentDungeon != null && !currentDungeon.GetType().Equals(typeof(PresetDungeon)))
            MenuManager.getInstance().getInventoryMenu().setCurrentItem(InputManager.getInstance().getCurrentPlayer().getInventoryItems()[0]);

            this.currentDungeon = dungeon;
        }
Пример #2
0
        public static Light[] getLights()
        {
            if (lights == null)
            {
                lights = new List<Light>();
            }

            if (DungeonManager.getInstance().getCurrentDungeon() == null) return lights.ToArray();

            if (cDungeon != DungeonManager.getInstance().getCurrentDungeon())
            {
                cDungeon = DungeonManager.getInstance().getCurrentDungeon();
                vector = InputManager.getInstance().getCurrentPlayer().getVector();
                lights.Clear();
            }
            else return lights.ToArray();

            TorchChunk[] chunks = DungeonManager.getInstance().getCurrentDungeon().getTorchChunks();

            foreach(TorchChunk chunk in chunks)
            {
                lights.Add(chunk.getLight());
            }

            return lights.ToArray();
        }
Пример #3
0
 /// <summary>
 /// Creates a portal chunk to a predefined location.
 /// </summary>
 /// <param name="chunkPos"></param>
 /// <param name="chunkHeight"></param>
 /// <param name="dungeon"></param>
 /// <param name="vector"></param>
 public PortalChunk(int chunkPos, int chunkHeight, Dungeon dungeon, Vector2 vector)
     : base(chunkPos)
 {
     boundingBoxes.Add(new BoundingBox(chunkHeight));
     this.dungeon = dungeon;
     x = vector.X;
     y = vector.Y;
 }
Пример #4
0
        /// <summary>
        /// Creates a dungeon that is linked to another dungeon through a portalChunk
        /// </summary>
        /// <param name="linkedDungeon">The Dungeon for the portal to link to</param>
        /// <param name="vector">The position to warp to into the other dungeon</param>
        public Dungeon(Dungeon linkedDungeon, Vector2 vector)
        {
            rooms = new RoomContainer();
            random = new Random();

            extraBeginningChunk = new SquareChunk(-2, 10000);

            starter = new PortalChunk(-1, 230, linkedDungeon, vector);
            if (!GetType().Equals(typeof(PresetDungeon)))
                generateDungeon();
        }
Пример #5
0
        public Room(int height, int chunkPos, Dungeon dungeon)
        {
            if (Dungeon.getDeserializing()) return;
            baseHeight = height;
            random = new Random(this.GetHashCode());
            sColor = new SerializedColor(random.Next(256), random.Next(256), random.Next(256));
            color = sColor.getColor();
            chunks = new ChunkContainer();
            this.chunkPos = chunkPos;

            if (GetType().Equals(typeof(Room)))
                generateRoom();
        }
Пример #6
0
        /// <summary>
        /// Returns the dungeon to teleport to.
        /// </summary>
        /// <returns></returns>
        public Dungeon usePortal()
        {
            if (dungeon == null)
            {
                dungeon = new Dungeon(DungeonManager.getInstance().getCurrentDungeon(), InputManager.getInstance().getCurrentPlayer().getVector());
                x = -80;
                y = ResourceHandler.getInstance().getBottom() - dungeon.getFirstChunk().getHeight() - InputManager.getInstance().getCurrentPlayer().getHeight();
            }

            DungeonManager.getInstance().setCurrentDungeon(dungeon);

            return dungeon;
        }
Пример #7
0
        /// <summary>
        /// Follows the player and attacks him when touching him.
        /// </summary>
        /// <param name="dungeon"></param>
        public override void followPlayer(Dungeon dungeon)
        {
            base.followPlayer(dungeon);

            if(collidingWith(InputManager.getInstance().getCurrentPlayer()))
            {
                Random rand = new Random();
                int lel = rand.Next(10);
                if (lel == 9)
                {
                    attack(InputManager.getInstance().getCurrentPlayer());
                }
            }
        }
Пример #8
0
        public virtual void followPlayer(Dungeon dungeon)
        {
            if (!collidingWith(InputManager.getInstance().getCurrentPlayer()))
            {
                if (getDistanceFrom(InputManager.getInstance().getCurrentPlayer()) < 450)
                {
                    if (getVector().X < InputManager.getInstance().getCurrentPlayer().getX())
                    {
                        if (getVector().Y > InputManager.getInstance().getCurrentPlayer().getY())
                        {
                            if (dungeon.getCurrentChunkRight(this).checkRightSideCollision(this))
                            {

                                if (dungeon.getCurrentChunkLeft(this).checkRightTopCollision(this))
                                    moveY(-32);
                                else moveX(-2);
                            }
                            else moveX(2);
                        }
                        else moveX(2);

                    }
                    else
                    {
                        if (getVector().Y > InputManager.getInstance().getCurrentPlayer().getY())
                        {
                            if (dungeon.getCurrentChunkLeft(this).checkLeftSideCollision(this))
                            {
                                if (dungeon.getCurrentChunkRight(this).checkLeftTopCollision(this))
                                    moveY(-32);
                                else moveX(2);
                            }
                            else moveX(-2);
                        }
                        else moveX(-2);
                    }
                }
            }
        }