public void ShouldFindTwoConnectedRoomsWithAPushwall()
        {
            AddStart(2, 2);

            AddSpace(2, 2, _tileNorthWestWalls);
            AddSpace(3, 2, _tileNorthEastWalls);
            AddSpace(3, 3, _tileSouthWalls);
            AddSpace(2, 3, _tileSouthWestWalls);

            AddPushwall(4, 3);

            AddSpace(5, 2, _tileWestNorthEastWalls);
            AddSpace(5, 3, _tileSouthEastWalls);

            var levelMap = new LevelMapper().Map(_data);
            var room     = levelMap.StartingRoom;

            room.Should().NotBeNull();

            room.Locations.Count.Should().Be(4);
            AssertLocationInRoom(room, 2, 2);
            AssertLocationInRoom(room, 3, 2);
            AssertLocationInRoom(room, 2, 3);
            AssertLocationInRoom(room, 3, 3);

            room.AdjacentRooms.Count.Should().Be(1);

            var firstTransition = room.AdjacentRooms.First();

            firstTransition.Key.Count.Should().Be(1);
            firstTransition.Should().NotBeNull();
            firstTransition.Value.Locations.Count.Should().Be(2);
            AssertLocationInRoom(firstTransition.Value, 5, 2);
            AssertLocationInRoom(firstTransition.Value, 5, 3);
        }
Beispiel #2
0
        protected override void Write(LogEventInfo logEvent)
        {
            if (!LevelMapper.TryGetValue(logEvent.Level, out ErrorLevel rollbarLogLevel))
            {
                rollbarLogLevel = ErrorLevel.Debug;
            }

            DTOs.Body rollbarBody = null;
            if (logEvent.Exception != null)
            {
                rollbarBody = new DTOs.Body(logEvent.Exception);
            }
            else
            {
                var formattedMessage = RenderLogEvent(Layout, logEvent);
                rollbarBody = new DTOs.Body(new DTOs.Message(formattedMessage));
            }

            IDictionary <string, object> custom = GetAllProperties(logEvent);

            DTOs.Data rollbarData = new DTOs.Data(RollbarConfig, rollbarBody, custom)
            {
                Level = rollbarLogLevel
            };

            ReportToRollbar(rollbarData);
        }
        public void ShouldHandleNullSpace()
        {
            AddStart(2, 2);

            AddSpace(2, 2, _tileNorthWestWalls);
            AddSpace(3, 2, _tileNorthWalls);
            AddSpace(4, 2, _tileNorthEastWalls);

            AddSpace(2, 3, _tileWestWalls);
            AddSpace(3, 3);
            AddSpace(4, 3, _tileEastWalls);

            AddSpace(2, 4, _tileSouthWestWalls);
            AddSpace(3, 4, _tileSouthWalls);
            AddSpace(4, 4, _tileSouthEastWalls);

            var levelMap = new LevelMapper().Map(_data);
            var room     = levelMap.StartingRoom;

            room.Should().NotBeNull();
            room.Locations.Count.Should().Be(9);

            AssertLocationInRoom(room, 2, 2);
            AssertLocationInRoom(room, 3, 2);
            AssertLocationInRoom(room, 4, 2);

            AssertLocationInRoom(room, 2, 3);
            AssertLocationInRoom(room, 3, 2);
            AssertLocationInRoom(room, 4, 3);

            AssertLocationInRoom(room, 2, 4);
            AssertLocationInRoom(room, 3, 4);
            AssertLocationInRoom(room, 4, 4);
        }
        public void ShouldFindOnlyOneConnectedRoomsWithALockedDoorAndNoKey()
        {
            AddStart(2, 2);

            AddSpace(2, 2, _tileNorthWestWalls);
            AddSpace(3, 2, _tileNorthEastWalls);
            AddSpace(3, 3, _tileSouthWalls);
            AddSpace(2, 3, _tileSouthWestWalls);

            AddDoor(4, 3, true, LockLevel.Silver);

            AddSpace(5, 2, _tileWestNorthEastWalls);
            AddSpace(5, 3, _tileSouthEastWalls);

            var levelMap = new LevelMapper().Map(_data);
            var room     = levelMap.StartingRoom;

            room.Should().NotBeNull();

            room.Locations.Count.Should().Be(4);
            AssertLocationInRoom(room, 2, 2);
            AssertLocationInRoom(room, 3, 2);
            AssertLocationInRoom(room, 2, 3);
            AssertLocationInRoom(room, 3, 3);

            room.AdjacentRooms.Count.Should().Be(0);
        }
        public void ShouldExcludeBlockingSpaceInNullTile()
        {
            AddStart(2, 2);

            AddSpace(2, 2, _tileNorthWestWalls);
            AddSpace(3, 2, _tileNorthWalls);
            AddSpace(4, 2, _tileAllWalls);

            AddSpace(2, 3, _tileWestWalls);
            AddSpace(3, 3);
            AddSpace(4, 3, _tileAllWalls);

            AddSpace(2, 4, _tileAllWalls);
            AddSpace(3, 4, _tileAllWalls);
            AddSpace(4, 4, _tileAllWalls);

            AddBlocker(3, 3);

            var levelMap = new LevelMapper().Map(_data);
            var room     = levelMap.StartingRoom;

            room.Should().NotBeNull();
            room.Locations.Count.Should().Be(3);
            AssertLocationInRoom(room, 2, 2);
            AssertLocationInRoom(room, 3, 2);
            AssertLocationInRoom(room, 2, 3);
        }
        public void ShouldFindOneByOneRoom()
        {
            AddStart(2, 2);
            AddSpace(2, 2, _tileAllWalls);

            var levelMap = new LevelMapper().Map(_data);
            var room     = levelMap.StartingRoom;

            room.Should().NotBeNull();
            room.Locations.Count.Should().Be(1);
            AssertLocationInRoom(room, 2, 2);
        }
Beispiel #7
0
        public static LogFactory CreateLogFactory(string verbosity)
        {
            var logLevel = (LogLevel)LevelMapper.FromString(verbosity);

            var loggerFactory = new LoggerFactory();

            loggerFactory.AddProvider(new ConsoleErrorLoggerProvider((message, level) => level >= logLevel));

            return(type =>
            {
                var logger = loggerFactory.CreateLogger(type);
                return (level, message, exception) =>
                {
                    logger.Log((LogLevel)level, message, exception);
                };
            });
        }
Beispiel #8
0
        public static LogFactory CreateLogFactory(string verbosity)
        {
            var logLevel = (LogLevel)LevelMapper.FromString(verbosity);

            var loggerFilterOptions = new LoggerFilterOptions()
            {
                MinLevel = logLevel
            };

            var consoleLoggerProvider = new ConsoleLoggerProvider(new ConsoleOptionsMonitor());

            var loggerFactory = new LoggerFactory(new[] { consoleLoggerProvider }, loggerFilterOptions);

            return(type =>
            {
                var logger = loggerFactory.CreateLogger(type);
                return (level, message, exception) =>
                {
                    logger.Log((LogLevel)level, message, exception);
                };
            });
        }
        public void ShouldFindPartialDonut()
        {
            AddStart(2, 2);
            AddSpace(2, 2, _tileNorthWestWalls);
            AddSpace(3, 2, _tileNorthSouthWalls);
            AddSpace(4, 2, _tileNorthSouthWalls);
            AddSpace(5, 2, _tileNorthSouthWalls);
            AddSpace(6, 2, _tileNorthEastWalls);

            AddSpace(2, 3, _tileEastWestWalls);
            AddSpace(6, 3, _tileEastWestWalls);

            AddSpace(2, 4, _tileSouthWestWalls);
            AddSpace(3, 4, _tileNorthSouthWalls);
            AddSpace(4, 4, _tileNorthEastSouthWalls);
            AddSpace(6, 4, _tileEastSouthWestWalls);

            var levelMap = new LevelMapper().Map(_data);
            var room     = levelMap.StartingRoom;

            room.Should().NotBeNull();
            room.Locations.Count.Should().Be(11);

            AssertLocationInRoom(room, 2, 2);
            AssertLocationInRoom(room, 3, 2);
            AssertLocationInRoom(room, 4, 2);
            AssertLocationInRoom(room, 5, 2);
            AssertLocationInRoom(room, 6, 2);

            AssertLocationInRoom(room, 2, 3);
            AssertLocationInRoom(room, 6, 3);

            AssertLocationInRoom(room, 2, 4);
            AssertLocationInRoom(room, 3, 4);
            AssertLocationInRoom(room, 4, 4);
            AssertLocationInRoom(room, 6, 4);
        }
        public void ShouldBlockFromOutside()
        {
            AddStart(3, 3);

            AddSpace(2, 2, _tileAllWalls);
            AddSpace(3, 2, _tileAllWalls);
            AddSpace(4, 2, _tileAllWalls);

            AddSpace(2, 3, _tileAllWalls);
            AddSpace(3, 3);
            AddSpace(4, 3, _tileAllWalls);

            AddSpace(2, 4, _tileAllWalls);
            AddSpace(3, 4, _tileAllWalls);
            AddSpace(4, 4, _tileAllWalls);

            var levelMap = new LevelMapper().Map(_data);
            var room     = levelMap.StartingRoom;

            room.Should().NotBeNull();
            room.Locations.Count.Should().Be(1);

            AssertLocationInRoom(room, 3, 3);
        }
Beispiel #11
0
        static void SetSliderLevel(object sender, MessageTranferEventArgs e)
        {
            frmControler    frm  = (frmControler)e.Form;
            LevelController lc   = (LevelController)e.LC;
            ScrollBar       sbar = lc.sbar;
            TextBox         txt  = lc.txt;

            if ((sbar != null) && (lc.gui_flags[LevelController.fMin] || lc.gui_flags[LevelController.fMax] || lc.gui_flags[LevelController.fLev] || lc.gui_flags[LevelController.fResize]))
            {
                if (sbar.InvokeRequired)
                {
                    var d = new SafeCallDelegate(SetSliderLevel);
                    sbar.Invoke(d, new object[] { sender, e });
                }
                else
                {
                    if (lc.gui_flags[LevelController.fMin] || lc.gui_flags[LevelController.fMax] || lc.gui_flags[LevelController.fResize])
                    {
                        // sliders don't return a level between min_level & max_level
                        // they return the top of a page where the page is located between min_level & max_level
                        int minSbar = lc.slider_min_level;
                        int maxSbar = lc.slider_max_level;

                        LevelMapper tmapper = new LevelMapper((double)minSbar, (double)maxSbar, 0.0, ((sbar.Width > sbar.Height) ? (double)sbar.Width : (double)sbar.Height));
                        //  pageSize = tmapper.B_to_intA(1.2 * (double)((sbar.Width > sbar.Height) ? (double)sbar.Height : (double)sbar.Width));

                        int pageSize = tmapper.B_to_intA(30.0);  // level -> slider

                        //  maxSbar = maxSbar + pageSize;  --- let controller take care of fact that max value is (max -  pagesize)
                        Console.WriteLine("Scroll-bar: length = {0}  => 30 =>  pageSize = {1}", ((sbar.Width > sbar.Height) ? (double)sbar.Width : (double)sbar.Height), pageSize);

                        sbar.LargeChange = pageSize;
                        sbar.Minimum     = minSbar;
                        sbar.Maximum     = maxSbar;

                        //  if (lc.gui_flags[LevelController.fLev]) {
                        //     sbar.Value = lc.last_slider_value; // load_slider_parms is going to trash last_slider_value !!!
                        //  }

                        lc.load_slider_parms(); // corrects last_slider_value based on new pageSize
                    }
                    if (lc.gui_flags[LevelController.fMin])
                    {
                    }
                    if (lc.gui_flags[LevelController.fMax])
                    {
                    }
                    if (lc.gui_flags[LevelController.fLev])
                    {
                        sbar.Value = lc.last_slider_value;
                    }
                }
            }
            if ((txt != null) && lc.gui_flags[LevelController.fTxt])
            {
                ShowParameterValues(sender, e);
            }
            if (sbar != null)
            {
                if (sbar.Value != lc.last_slider_value)
                {
                    Console.WriteLine("Slider level doesn't match slider position: {0} <> {1}", lc.last_slider_value, sbar.Value);
                }
            }
            lc.gui_flags[LevelController.fMin]    = false;
            lc.gui_flags[LevelController.fMax]    = false;
            lc.gui_flags[LevelController.fLev]    = false;
            lc.gui_flags[LevelController.fTxt]    = false;
            lc.gui_flags[LevelController.fResize] = false;
        }
Beispiel #12
0
        private void gameInterval(object sender, EventArgs e)
        {
            if (HP > 1)
            {
                progressBar.Value = Convert.ToInt32(HP);
            }
            else
            {
                player.BackgroundImage = Properties.Resources.ash;
                timer1.Stop();
                UserInterfaceHelper.showEndGame(StartLabel, score);
                gameOver = true;
            }

            UserInterfaceHelper.updateBullets(label2, ammo);
            UserInterfaceHelper.updateScore(scoreLabel, score);

            if (HP < 20)
            {
                progressBar.ForeColor = System.Drawing.Color.Red;
            }

            if (score % 5 == 0 && !medkitOnMap && !needtoKillzombie)
            {
                new SpawnObjectsFactory().create(SpawnObject.HEAL, this);
                medkitOnMap = true;
            }

            if (goLeft && player.Left > 0)
            {
                player.Left -= speed;
            }

            if (goRight && player.Left + player.Width < ScreenWidth)
            {
                player.Left += speed;
            }

            if (goUp && player.Top > 60)
            {
                player.Top -= speed;
            }

            if (goDown && player.Top + player.Height < ScreenHeight - 80)
            {
                player.Top += speed;
            }


            foreach (Control c in this.Controls)
            {
                if (c is PictureBox)
                {
                    PictureBox loopedControlObject = (PictureBox)c;
                    #pragma warning disable CS0252 // Possible unintended reference comparison; left hand side needs cast
                    if (c.Tag == SpawnObject.AMMO)
                    {
                        if (loopedControlObject.Bounds.IntersectsWith(player.Bounds))
                        {
                            this.Controls.Remove(loopedControlObject);
                            loopedControlObject.Dispose();
                            ammo += 5;
                        }
                    }

                    if (c.Tag == SpawnObject.SHOOT)
                    {
                        if (loopedControlObject.Left < 1 || loopedControlObject.Left > ScreenWidth || loopedControlObject.Top < 10 || loopedControlObject.Top > ScreenHeight)
                        {
                            this.Controls.Remove(loopedControlObject);
                            loopedControlObject.Dispose();
                        }
                    }

                    if (c.Tag == SpawnObject.ZOMBIE)
                    {
                        if (loopedControlObject.Bounds.IntersectsWith(player.Bounds))
                        {
                            HP -= 1;
                        }

                        int zombieSpeed = LevelMapper.adjust(score);

                        if (loopedControlObject.Left > player.Left)
                        {
                            loopedControlObject.Left           -= zombieSpeed;
                            loopedControlObject.BackgroundImage = Properties.Resources.zombie_left;
                        }

                        if (loopedControlObject.Top > player.Top)
                        {
                            loopedControlObject.Top            -= zombieSpeed;
                            loopedControlObject.BackgroundImage = Properties.Resources.zombie_top;
                        }

                        if (loopedControlObject.Left < player.Left)
                        {
                            loopedControlObject.Left           += zombieSpeed;
                            loopedControlObject.BackgroundImage = Properties.Resources.zombie_right;
                        }

                        if (loopedControlObject.Top < player.Top)
                        {
                            loopedControlObject.Top            += zombieSpeed;
                            loopedControlObject.BackgroundImage = Properties.Resources.zombie_bottom;
                        }

                        loopedControlObject.BackColor = Color.Transparent;
                    }

                    if (c.Tag == SpawnObject.HEAL)
                    {
                        if (loopedControlObject.Bounds.IntersectsWith(player.Bounds))
                        {
                            this.Controls.Remove(loopedControlObject);
                            loopedControlObject.Dispose();
                            HP              += 20;
                            HP               = (HP > 100) ? 100 : HP;
                            medkitOnMap      = false;
                            needtoKillzombie = true;
                        }
                    }

                    foreach (Control c2 in this.Controls)
                    {
                        if ((c2 is PictureBox && c2.Tag == SpawnObject.SHOOT) && (c.Tag == SpawnObject.ZOMBIE))
                        {
                            if (c.Bounds.IntersectsWith(c2.Bounds))
                            {
                                score++;
                                this.Controls.Remove(c2);
                                c2.Dispose();
                                this.Controls.Remove(c);
                                c.Dispose();
                                new SpawnObjectsFactory().create(SpawnObject.ZOMBIE, this);
                                needtoKillzombie = false;
                            }
                        }
                    }
                }
            }
        }