コード例 #1
0
ファイル: DungeonLevel.cs プロジェクト: Kuqki/3902_ZJZH
        public void Update(GameTime _gameTime)
        {
            if (CurrentRoom != null)
            {
                CurrentRoom.Update();
            }
            Map.Update(_gameTime);
            Rectangle linkRectangle = Link.GetRectangle();

            if (linkRectangle.Intersects(doors[0]))
            {
                if (CurrentRoom.HasNorth)
                {
                    TempRoom    = CurrentRoom;
                    CurrentRoom = Rooms[Rooms.Count - 1];//switch to the empty room
                    North();
                }
            }
            else if (linkRectangle.Intersects(doors[1]))
            {
                if (CurrentRoom.HasEast)
                {
                    TempRoom    = CurrentRoom;
                    CurrentRoom = Rooms[Rooms.Count - 1];//switch to the empty room
                    East();
                }
            }
            else if (linkRectangle.Intersects(doors[2]))
            {
                if (CurrentRoom.HasSouth)
                {
                    TempRoom    = CurrentRoom;
                    CurrentRoom = Rooms[Rooms.Count - 1];//switch to the empty room
                    South();
                }
            }
            else if (linkRectangle.Intersects(doors[3]))
            {
                if (CurrentRoom.HasWest)
                {
                    TempRoom    = CurrentRoom;
                    CurrentRoom = Rooms[Rooms.Count - 1];//switch to the empty room
                    West();
                }
            }
            if (CurrentRoom != null)
            {
                DetectCollision.linkBlockDetection(this.Link, CurrentRoom.Block);
                DetectCollision.LinkEnemyDetection(this.Link, CurrentRoom.Enemies);
                DetectCollision.linkReceivedItemDetection(this.Link, CurrentRoom.ReceivedItems);
                DetectCollision.linkObtainedItemDetection(this.Link, CurrentRoom.ObtainedItems);
                DetectCollision.EnemyBlockDetection(CurrentRoom.Enemies, CurrentRoom.Block);
                DetectCollision.EnemyProjectileDetection(CurrentRoom.Enemies, this.game.ProjectileFactory);
            }
        }