コード例 #1
0
        void rollRandomLoot(iRoom room, IEnemy enemy)
        {
            Random rand = new Random();
            //Chooses a random number between 1 and 100, and compares it to a table of loot.
            //Drops the random item at the same position of the enemy
            int lootRoll = rand.Next(1, 101);

            if (lootRoll <= heartWindow)
            {
                room.Items.Add(new Heart(enemy.Position));
            }
            else if (lootRoll <= rupeeWindow)
            {
                room.Items.Add(new Rupee(enemy.Position));
            }
            else if (lootRoll <= clockWindow)
            {
                room.Items.Add(new Clock(enemy.Position));
            }
            else if (lootRoll <= bombWindow)
            {
                room.Items.Add(new Bomb(enemy.Position));
            }
            else
            {
                //drop nothing
            }
        }
コード例 #2
0
 void dropSpecificLoot(iRoom room, IEnemy enemy)
 {
     if (enemy.carriedLoot != "")
     {
         if (enemy.carriedLoot == "Key")
         {
             if (!lootAlreadyDropped.Contains(((Room1)room).CurrentRoom))
             {
                 room.Items.Add(new Key(enemy.Position));
             }
         }
     }
 }
コード例 #3
0
 void revealHiddenLoot(iRoom room)
 {
     if (room.Enemies.FindAll(enemy => !(enemy is EnemyBoomerang || enemy is Fireball)).Count == 1)
     //triggers if this enemy that died is the last enemy in the room
     {
         if (room.HiddenItems.Count > 0)
         {
             if (!lootAlreadyDropped.Contains(((Room1)room).CurrentRoom))
             {
                 SoundFactory.Instance.sfxHiddenKeyAppears.Play();
                 room.Items.AddRange(room.HiddenItems);
             }
         }
     }
 }
コード例 #4
0
        protected override void Initialize()
        {
            LoadContent();

            DoorBombed.ResetBombedDoors();
            DoorClosed.ResetClosedDoors();
            DoorLocked.ResetLockedfDoors();
            LootManagement.ResetLoot();

            player          = new Link(this);
            player.Position = new Vector2(0, 160);
            LinkSpriteFactory.Instance.player = player;
            if (playerDebug)
            {
                player.Health      = 1000;
                player.TotalHealth = 1000;
                player.ItemCounts[ItemType.Map]++;
                player.ItemCounts[ItemType.Compass]++;
                player.ItemCounts[ItemType.Rupee] = 89;
            }

            player.ItemCounts[ItemType.Rupee] += 10;
            hud       = new HeadsUpDisplay(this, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            screen    = new NormalScreen(this, GraphicsDevice, graphics);
            gameState = new NormalGameState(this);

            this.IsMouseVisible = true;
            base.Initialize();

            currentRoom = new Room1(this, new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2 + 84), floortilebase);
            currentRoom.LoadRoom("RoomC6");
            if (playerDebug)
            {
                currentRoom.LoadRoom("RoomDEBUG");
            }
            roomIndex = Array.FindIndex(rooms, x => x == "RoomC6");

            lightingManager = new LightingManager(this);

            savedPlayer = new Link(this);
            savedRoom   = new Room1(this, new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2 + 84), floortilebase);
            savedScreen = new NormalScreen(this, GraphicsDevice, graphics);

            notificationsQueue = new Queue <INotification>();

            SoundFactory.Instance.musicDungeonLoop.Play();
        }
コード例 #5
0
        protected override void Initialize()
        {
            LoadContent();
            player          = new Link(this);
            player.Position = new Vector2(200, 360);
            LinkSpriteFactory.Instance.player = player;

            hud       = new HeadsUpDisplay(this, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            screen    = new NormalScreen(this, GraphicsDevice, graphics);
            gameState = new NormalGameState(this);

            this.IsMouseVisible = true;
            base.Initialize();

            currentRoom = new Room1(this, new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2 + 84), floortilebase);
            currentRoom.LoadRoom("RoomDEBUG");

            SoundFactory.Instance.musicDungeonLoop.Play();
        }
コード例 #6
0
 public void enemyDeathLootCheck(iRoom room, IEnemy enemy)
 {
     rollRandomLoot(room, enemy);
     dropSpecificLoot(room, enemy);
     revealHiddenLoot(room);
 }
コード例 #7
0
 public void FinishTransition(iRoom room)
 {
     currentRoom             = room;
     gameState               = new NormalGameState(this);
     player.CollisionHandler = new LinkCollisionHandler(this, player, 56, 50, 0, 10);
 }
コード例 #8
0
        private List <Vector2> GetWallCornersFromRoom(iRoom room)
        {
            List <Vector2> corners = new List <Vector2>();

            // add wall corners:
            Vector2 topLeft     = room.Position - room.Size / 2f;
            Vector2 bottomRight = room.Position + room.Size / 2f;
            Vector2 bottomLeft  = new Vector2(room.Position.X - room.Size.X / 2f, room.Position.Y + room.Size.Y / 2f);
            Vector2 topRight    = new Vector2(room.Position.X + room.Size.X / 2f, room.Position.Y - room.Size.Y / 2f);

            corners.Add(topLeft);
            corners.Add(topRight);
            corners.Add(bottomRight);
            corners.Add(bottomLeft);

            // add corners of each block:
            foreach (IBlock block in game.currentRoom.Blocks)
            {
                if (block is Stairs || block is StairsInvisible || block is BlockWater || block is BlockInvisible || block is Ladder)
                {
                    continue;
                }
                topLeft     = new Vector2(block.Position.X + room.Position.X - blockSize.X / 2f, block.Position.Y + room.Position.Y - blockSize.Y / 2f);
                bottomLeft  = new Vector2(block.Position.X + room.Position.X - blockSize.X / 2f, block.Position.Y + room.Position.Y + blockSize.Y / 2f);
                topRight    = new Vector2(block.Position.X + room.Position.X + blockSize.X / 2f, block.Position.Y + room.Position.Y - blockSize.Y / 2f);
                bottomRight = new Vector2(block.Position.X + room.Position.X + blockSize.X / 2f, block.Position.Y + room.Position.Y + blockSize.Y / 2f);
                if (corners.Contains(topLeft))
                {
                    corners.Remove(topLeft);
                }
                else
                {
                    corners.Add(topLeft);
                }
                if (corners.Contains(topRight))
                {
                    corners.Remove(topRight);
                }
                else
                {
                    corners.Add(topRight);
                }
                if (corners.Contains(bottomRight))
                {
                    corners.Remove(bottomRight);
                }
                else
                {
                    corners.Add(bottomRight);
                }
                if (corners.Contains(bottomLeft))
                {
                    corners.Remove(bottomLeft);
                }
                else
                {
                    corners.Add(bottomLeft);
                }
            }

            return(corners);
        }
コード例 #9
0
        private List <LineSegment> GetWallLineSegmentsFromRoom(iRoom room)
        {
            List <LineSegment> lineSegments = new List <LineSegment>();

            // add walls:
            Vector2 topLeft     = room.Position - room.Size / 2f;
            Vector2 bottomRight = room.Position + room.Size / 2f;
            Vector2 bottomLeft  = new Vector2(room.Position.X - room.Size.X / 2f, room.Position.Y + room.Size.Y / 2f);
            Vector2 topRight    = new Vector2(room.Position.X + room.Size.X / 2f, room.Position.Y - room.Size.Y / 2f);

            lineSegments.Add(new LineSegment(topLeft, topRight));
            lineSegments.Add(new LineSegment(topRight, bottomRight));
            lineSegments.Add(new LineSegment(bottomRight, bottomLeft));
            lineSegments.Add(new LineSegment(bottomLeft, topLeft));

            // add edges of each block:
            foreach (IBlock block in game.currentRoom.Blocks)
            {
                if (block is Stairs || block is StairsInvisible || block is BlockWater || block is BlockInvisible || block is Ladder)
                {
                    continue;
                }
                topLeft     = new Vector2(block.Position.X + room.Position.X - blockSize.X / 2f, block.Position.Y + room.Position.Y - blockSize.Y / 2f);
                bottomLeft  = new Vector2(block.Position.X + room.Position.X - blockSize.X / 2f, block.Position.Y + room.Position.Y + blockSize.Y / 2f);
                topRight    = new Vector2(block.Position.X + room.Position.X + blockSize.X / 2f, block.Position.Y + room.Position.Y - blockSize.Y / 2f);
                bottomRight = new Vector2(block.Position.X + room.Position.X + blockSize.X / 2f, block.Position.Y + room.Position.Y + blockSize.Y / 2f);
                LineSegment top    = new LineSegment(topLeft, topRight);
                LineSegment right  = new LineSegment(topRight, bottomRight);
                LineSegment bottom = new LineSegment(bottomRight, bottomLeft);
                LineSegment left   = new LineSegment(bottomLeft, topLeft);
                if (Contains(lineSegments, top))
                {
                    lineSegments.Remove(top);
                }
                else
                {
                    lineSegments.Add(top);
                }
                if (Contains(lineSegments, right))
                {
                    lineSegments.Remove(right);
                }
                else
                {
                    lineSegments.Add(right);
                }
                if (Contains(lineSegments, bottom))
                {
                    lineSegments.Remove(bottom);
                }
                else
                {
                    lineSegments.Add(bottom);
                }
                if (Contains(lineSegments, left))
                {
                    lineSegments.Remove(left);
                }
                else
                {
                    lineSegments.Add(left);
                }
            }

            return(lineSegments);
        }