Example #1
0
        public WayPointsFollowingRRTPlanner(
            double goalBias,
            int maximumNumberOfIterations,
            IVehicleModel vehicleModel,
            IMotionModel motionModel,
            ITrack track,
            ICollisionDetector collisionDetector,
            Random random,
            TimeSpan timeStep,
            IActionSet actions,
            IReadOnlyList <IGoal> wayPoints)
        {
            if (goalBias > 0.5)
            {
                throw new ArgumentOutOfRangeException($"Goal bias must be at most 0.5 (given {goalBias}).");
            }

            this.goalBias = goalBias;
            this.maximumNumberOfIterations = maximumNumberOfIterations;
            this.vehicleModel      = vehicleModel;
            this.motionModel       = motionModel;
            this.track             = track;
            this.collisionDetector = collisionDetector;
            this.random            = random;
            this.timeStep          = timeStep;
            this.wayPoints         = wayPoints;
            this.actions           = actions;

            distances        = new DistanceMeasurement(track.Width, track.Height);
            wayPointsReached = 0;

            ExploredStates = exploredStates;
        }
 public CollisionDetectorFixture()
 {
     GridDimensions.MaxYValue = 10;
     GridDimensions.MinXValue = 1;
     GridDimensions.MaxXValue = 10;
     _detector = (ICollisionDetector)new CollisionDetector();
 }
Example #3
0
        public void Setup()
        {
            // Instantiating dependencies to fakes
            _collisionDetector   = Substitute.For <ICollisionDetector>();
            _track               = Substitute.For <ITrack>();
            _writer              = Substitute.For <IWriter>();
            _transponderReceiver = Substitute.For <ITransponderReceiver>();

            OnTracksReady = false;
            TrackEntered  = false;
            TrackLeaving  = false;

            // Injecting fakes into class Decoder (UUT)
            _uut = new Decoder
            {
                Writer              = _writer,
                CollisionDetector   = _collisionDetector,
                Track               = _track,
                TransponderReceiver = _transponderReceiver
            };

            _uut.OnTracksReady += (List <ITrack> tracks) => { OnTracksReady = true; };
            _uut.TrackEntered  += (ITrack track) => { TrackEntered = true; };
            _uut.TrackLeaving  += (ITrack track) => { TrackLeaving = true; };
        }
Example #4
0
        public RRTPlanner(
            double goalBias,
            int maximumNumberOfIterations,
            IWorldDefinition world,
            Random random,
            TimeSpan timeStep,
            IGoal goal)
        {
            if (goalBias > 0.5)
            {
                throw new ArgumentOutOfRangeException($"Goal bias must be at most 0.5 (given {goalBias}).");
            }

            this.goalBias = goalBias;
            this.maximumNumberOfIterations = maximumNumberOfIterations;
            this.vehicleModel      = world.VehicleModel;
            this.motionModel       = world.MotionModel;
            this.track             = world.Track;
            this.collisionDetector = world.CollisionDetector;
            this.random            = random;
            this.timeStep          = timeStep;
            this.goal    = goal;
            this.actions = world.Actions;

            distances = new DistanceMeasurement(track.Width, track.Height);

            ExploredStates = exploredStates;
        }
Example #5
0
 public CollisionManager()
 {
     myCollisionDetector = new CollisionDetector();
     playerBlockHandler  = new PlayerBlockCollisionHandler();
     playerItemHandler   = new PlayerItemCollisionHandler();
     playerEnemyHandler  = new PlayerEnemyCollisionHandler();
 }
Example #6
0
        public World()
        {
            gameObjects = new List<IGameObject>();
            respawnPoints = new List<RespawnPoint>();
            updateableObjects = new List<IUpdateable>();
            temporaryObjects = new List<ITemporaryObject>();
            players = new List<Player>();
            assassinPlayers = new List<Player>();
            knightPlayers = new List<Player>();
            physicsSimulator = new RigidBodySimulator();
            collisionDetector = physicsSimulator.CollisionDetector;
            collisionDetector.OnCollision += new CollisionHandler(this.OnCollision);

            physicsSimulator.Paused = true;

            physicsSimulator.DoAngularDrag = false;
            physicsSimulator.DoLinearDrag = false;
            physicsSimulator.DoGravity = false;

            if (_instance != null)
            {
                _instance.Close();
            }
            _instance = this;
        }
 public FlightCollection(IFlightCalculator flightCalculator, IFlightFilter flightFilter, ICollisionDetector collisionDetector)
 {
     flightFilter.transponderFilterChanged += GetTransponderData;
     this.FlightList         = new List <Flight>();
     this.flightCalculator   = flightCalculator;
     this.collisionDetector_ = collisionDetector;
 }
Example #8
0
            public void SetUp()
            {
                //arrange
                stubCalculator        = new StubCalculator();
                stubFilter            = Substitute.For <IFlightFilter>();
                stubCollisionDetector = Substitute.For <ICollisionDetector>();
                uut             = new FlightCollection(stubCalculator, stubFilter, stubCollisionDetector);
                receivedArgs    = null;
                setArgs         = new FlightArgs();
                setArgs.flights = new List <Flight>();

                TransponderData td = new TransponderData("aaa", 0, 0, 0, new DateTime());
                Flight          f  = new Flight(td);

                stubCollisionDetector.OnFlightsChanged(Arg.Any <FlightArgs>()).ReturnsForAnyArgs(setArgs.flights);


                numberOfFlightsChangedEvents = 0;

                uut.flightsChanged += (s, e) =>
                {
                    receivedArgs = e;
                    numberOfFlightsChangedEvents++;
                };
            }
Example #9
0
        public void SetUp()
        {
            _uut = new CollisionDetector();

            //Attaching event handlers
            _uut.Separation   += (e, args) => SeparationEventCounter++;
            _uut.NotColliding += (e, args) => NotCollidingEventCounter++;
        }
Example #10
0
        public void Update()
        {
            if (!myClue && Mygame.World.clue1Note)
            {
                ItemList.Add(new FlowerClueClass(Mygame, new Vector2(4446, 364)));
                myClue = true;
            }
            foreach (IEnemy enemy in EnemyList)
            {
                enemy.Update();
            }
            foreach (IItem item in ItemList)
            {
                item.Update();
            }
            foreach (IBlock block in BlockList)
            {
                block.Update();
            }

            foreach (IFire fire in FireList)
            {
                fire.Update();
            }
            count++;
            Queue <IProjectile> tempQueue = new Queue <IProjectile>();

            while (ProjectileQueue.Count > 0)
            {
                IProjectile temp       = ProjectileQueue.Dequeue();
                bool        checkIfOut = temp.position.X <Mygame.camera.cameraPositionX ||
                                                          temp.position.X> Mygame.camera.cameraPositionX + 800 || temp.position.Y < 0 || temp.position.Y > 480;
                if ((temp.rectangle.Height == 0 && count == 10) || checkIfOut)
                {
                }
                else
                {
                    temp.Update();
                    tempQueue.Enqueue(temp);
                }
            }
            if (count == 10)
            {
                count = 0;
            }
            ProjectileQueue = tempQueue;

            foreach (IBackground background in BackgroundList)
            {
                background.Update();
            }

            CollisionDetector.Update(this);
            ECollisionDetector.Update(this);
            FBCollisionDetector.Update(this);
            ICollisionDetector.Update(this);
        }
 public GameGridController(IGameGrid gameGrid)
 {
     _gameGrid = gameGrid;
     _collisionDetector = (ICollisionDetector)new CollisionDetector();
     _fallenTiles = (IFallenTiles)new FallenTiles();
     _gameTimer = new GameTimer(Level.Easy);
     _gameTimer.Tick += new EventHandler(TetrisTick);
     _scoreHolder = ScoreHolder.GetScoreHolder();
 }
Example #12
0
 public ControllerFactory(IDecoder decoder, ITrackDataFilter filter, ICollisionDetector collisionDetector, IDisplay display, ITransponderReceiver receiver, IFlightCalculator flightCalculator)
 {
     Decoder           = decoder;
     Filter            = filter;
     CollisionDetector = collisionDetector;
     Display           = display;
     Receiver          = receiver;
     FlightCalculator  = flightCalculator;
 }
Example #13
0
 /// <summary>
 /// Initializes the engine and sets the instance value.
 /// </summary>
 void Awake()
 {
     instance   = this;
     bodyCount  = 0;
     bodies     = new List <DBody>();
     detector   = new HashGridDetector(cellSize, sceneWidth, sceneHeight);
     integrator = new EulerImplicit();
     contacts   = new HashSet <Manifold>();
     simulate   = false;
 }
Example #14
0
 public ControllerFactory()
 {
     Decoder           = new Decoder();
     Filter            = new TrackDataFilter();
     CollisionDetector = new CollisionDetector(new Logger());
     Display           = new Display();
     Receiver          = TransponderReceiverFactory.CreateTransponderDataReceiver();
     FlightCalculator  =
         new FlightCalculator(new VelocityCalculator(), new DirectionCalculator());
 }
Example #15
0
        public void Setup()
        {
            _fakeVelocityCalculator  = Substitute.For <IVelocityCalculator>();
            _fakeDirectionCalculator = Substitute.For <IDirectionCalculator>();
            _fakeCollisionDetector   = Substitute.For <ICollisionDetector>();

            _fakeVelocityCalculator.CalculateSpeed(Arg.Any <TrackData>(), Arg.Any <TrackData>()).Returns(1000);
            _fakeDirectionCalculator.CalculateDirection(Arg.Any <TrackData>(), Arg.Any <TrackData>()).Returns(45);


            uut = new FlightCalculator(_fakeVelocityCalculator, _fakeDirectionCalculator);
        }
 public GameEngine(IGameFactory factory, IScreenPrinter printer, IHeroPrinter heroPrint,
                   IFightMode fightMode, ICollisionDetector detect, ICommandSelection commandSelection)
 {
     this.factory          = factory ?? throw new ArgumentNullException();
     this.printer          = printer ?? throw new ArgumentNullException();
     this.heroPrint        = heroPrint ?? throw new ArgumentNullException();
     this.fightMode        = fightMode ?? throw new ArgumentNullException();
     this.detect           = detect ?? throw new ArgumentNullException();
     this.commandSelection = commandSelection ?? throw new ArgumentNullException();
     this.Factory.HeroFactory();
     this.printer.Logger.SetSize();
 }
Example #17
0
        public void Update()
        {
            foreach (IEnemy enemy in EnemyList)
            {
                enemy.Update();
            }
            foreach (IBlock block in BlockList)
            {
                block.Update();
            }
            foreach (IItem item in ItemList)
            {
                item.Update();
            }
            foreach (IFire item in FireList)
            {
                item.Update();
            }
            count++;
            Queue <IProjectile> tempQueue = new Queue <IProjectile>();

            while (ProjectileQueue.Count > 0)
            {
                IProjectile temp       = ProjectileQueue.Dequeue();
                bool        checkIfOut = (temp.position.X <Mygame.camera.cameraPositionX ||
                                                           temp.position.X> Mygame.camera.cameraPositionX + 800 || temp.position.Y < 0 || temp.position.Y > 480);
                if ((temp.rectangle.Height == 0 && count == 10) || checkIfOut)
                {
                }
                else
                {
                    temp.Update();
                    tempQueue.Enqueue(temp);
                }
            }
            if (count == 10)
            {
                count = 0;
            }
            ProjectileQueue = tempQueue;

            foreach (IBackground background in BackgroundList)
            {
                background.Update();
            }
            BossPr.Update();
            CollisionDetector.Update(this);
            ECollisionDetector.Update(this);
            FBCollisionDetector.Update(this);
            ICollisionDetector.Update(this);
            BossPrincessCollisionDetector.Update(this);
        }
Example #18
0
        public ATMController(ControllerFactory controllerFactory)
        {
            _decoder           = controllerFactory.Decoder;
            _filter            = controllerFactory.Filter;
            _flightCalculator  = controllerFactory.FlightCalculator;
            _collisionDetector = controllerFactory.CollisionDetector;
            _display           = controllerFactory.Display;
            _receiver          = controllerFactory.Receiver;

            _data = new Dictionary <string, FlightData>();

            _receiver.TransponderDataReady += OnTransponderDataReady;
        }
Example #19
0
        public void Update()
        {
            foreach (IEnemy enemy in EnemyList)
            {
                enemy.Update();
            }
            foreach (IBlock block in BlockList)
            {
                block.Update();
            }
            foreach (IItem item in ItemList)
            {
                item.Update();
            }
            foreach (IFire fire in FireList)
            {
                fire.Update();
            }
            count++;
            Queue <IProjectile> tempQueue = new Queue <IProjectile>();

            while (ProjectileQueue.Count > 0)
            {
                IProjectile temp = ProjectileQueue.Dequeue();
                if (temp.mySprite is MarioFireBallBoomSprite && count == 50)
                {
                }
                else
                {
                    temp.Update();
                    tempQueue.Enqueue(temp);
                }
            }
            if (count == 50)
            {
                count = 0;
            }
            ProjectileQueue = tempQueue;

            foreach (IBackground background in BackgroundList)
            {
                background.Update();
            }
            CollisionDetector.Update(this);
            ECollisionDetector.Update(this);
            FBCollisionDetector.Update(this);
            ICollisionDetector.Update(this);
        }
Example #20
0
        protected override void Initialize()
        {
            hud = new HUD(this);

            begin    = true;
            infinite = false;
            normal   = false;

            soundEffect = new SoundEffects(this);
            sound       = new Sounds(this);
            contrl      = new ArrayList();
            camera      = new Camera(this);
            camObj      = new CameraObjectDetector(this);
            itemSpawn   = new ItemSpawn(this);
            start       = new startScreen(this);
            lvCtrl      = new LevelControl(this);
            infLvl      = new InfiniteLevel(this);

            marioColDetector = new MarioCollisionDetector(this);
            enemyColDetector = new EnemyCollisionDetector(this);
            itemColDetector  = new ItemCollisionDetector(this);

            keyboard = new KeyboardController();
            gmPad    = new GamepadController();
            KeyBind keyB = new KeyBind(this);

            keyB.BindKey();
            contrl.Add(keyboard);
            contrl.Add(gmPad);
            paused   = new Pause(this);
            gameOver = new GameOver(this);
            gameover = false;

            marioState = new MarioStateClass(false, false, false, false);
            fireBalls  = new List <Fireball>();
            fbDelay    = 0;

            countOfPopItem = 0;
            projColDet     = new ProjectileCollisionDetector(this, fireBalls);

            animationModifier = 0;
            starDuration      = 500;

            base.Initialize();
        }
        public void SetUp()
        {
            _collisionDetector = Substitute.For <ICollisionDetector>();
            _airSpace          = Substitute.For <IAirSpace>();
            _log          = Substitute.For <ILog>();
            _render       = Substitute.For <IRender>();
            _trackStorage = Substitute.For <ITrackStorage>();
            _tos          = Substitute.For <Tos>(Substitute.For <ITransponderReceiver>());

            validTrack1 = new Track {
                Tag = "AAA111", PositionX = 12000, PositionY = 80000, Altitude = 700
            };
            validTrack2 = new Track {
                Tag = "BBB222", PositionX = 80000, PositionY = 12000, Altitude = 1700
            };

            _uut = new AirTrafficController(_collisionDetector, _trackStorage, _airSpace, _render, _log);
        }
        public AirTrafficController(ICollisionDetector cd, ITrackStorage ts, IAirSpace airs, IRender r, ILog l)
        {
            _collisonDetector = cd;
            _trackStorage     = ts;
            _airSpace         = airs;
            _render           = r;
            _log = l;

            _collisonDetector.Separation += (s, e) =>
            {
                _render.PrintCollisionTracks(e.CollisionPairs);
                _log.LogCollisionToFile(e.CollisionPairs);
            };

            _collisonDetector.NotColliding += (s, e) =>
            {
                _render.PrintCollisionTracks(e.CollisionPairs, true);
            };
        }
Example #23
0
        public MainViewModel(
            IKeyboardConfigurationProvider keyboardConfigurationProvider,
            IGameConfigurationProvider gameConfigurationProvider,
            ICollisionDetector collisionDetector,
            IFoodCreator foodCreator,
            IImageDownloader imageDownloader,
            IDirectionChangeDetector directionChangeDetector
            )
        {
            _keyboardConfigurationProvider = keyboardConfigurationProvider;
            _gameConfigurationProvider     = gameConfigurationProvider;
            _collisionDetector             = collisionDetector;
            _foodCreator             = foodCreator;
            _imageDownloader         = imageDownloader;
            _directionChangeDetector = directionChangeDetector;

            _up    = _keyboardConfigurationProvider.Up;
            _down  = _keyboardConfigurationProvider.Down;
            _left  = _keyboardConfigurationProvider.Left;
            _right = _keyboardConfigurationProvider.Right;

            _allowedMovementKeysMap = new Dictionary <Key, SnakeDirection>()
            {
                { _up, SnakeDirection.Up },
                { _down, SnakeDirection.Down },
                { _left, SnakeDirection.Left },
                { _right, SnakeDirection.Right }
            };

            OnKeyDownCommand = new RelayCommandGeneric <Key>(p => OnKeyDown(p), p => true);

            timer.Interval = TimeSpan.FromMilliseconds(1000 / gameConfigurationProvider.SnakeSpeed);
            timer.Tick    += OnTimerTick;
            timer.Start();

            _objectSizeX         = _gameConfigurationProvider.GameObjectSizeX;
            _objectSizeY         = _gameConfigurationProvider.GameObjectSizeY;
            _maxXLogicalPosition = GameAreaDimensionX / _objectSizeX;
            _maxYLogicalPosition = GameAreaDimensionY / _objectSizeY;

            StartGame();
        }
Example #24
0
        public void Setup()
        {
            //Arrange
            _fakeDisplay           = Substitute.For <IDisplay>();
            _fakeTrackDataFilter   = Substitute.For <ITrackDataFilter>();
            _fakeFlightCalculator  = Substitute.For <IFlightCalculator>();
            _fakeCollisionDetector = Substitute.For <ICollisionDetector>();
            _fakeDecoder           = Substitute.For <IDecoder>();
            _fakeReceiver          = Substitute.For <ITransponderReceiver>();

            _fakeEventArgs      = new RawTransponderDataEventArgs(new List <string>());
            _fakeTrackData      = new List <TrackData>();
            _fakeFilteredData   = new List <TrackData>();
            _emptyFlightData    = new Dictionary <string, FlightData>();
            _fakeFlightData     = new Dictionary <string, FlightData>();
            _fakeCalculatedData = new Dictionary <string, FlightData>();
            _fakeSeperationData = new Tuple <List <string>, List <string> >(new List <string>(), new List <string>());

            //Fake decoder should return fake Trackdata when called with fakeEventArgs
            _fakeDecoder.Decode(_fakeEventArgs).Returns(_fakeTrackData);

            //Filter returns _fakeFilteredData
            _fakeTrackDataFilter.Filter(_fakeTrackData).Returns(_fakeFilteredData);

            //FlightCalculator returns _fakeFlightData
            _fakeFlightCalculator.Calculate(Arg.Any <Dictionary <string, FlightData> >(), Arg.Any <List <TrackData> >())
            .Returns(_fakeCalculatedData);

            //Seperation detector returns _fakeSeperationData
            _fakeCollisionDetector.SeperationCheck(Arg.Any <List <TrackData> >())
            .Returns(_fakeSeperationData);

            ControllerFactory fakeFactory = new ControllerFactory(
                _fakeDecoder,
                _fakeTrackDataFilter,
                _fakeCollisionDetector,
                _fakeDisplay,
                _fakeReceiver,
                _fakeFlightCalculator);

            _uut = new ATMController(fakeFactory);
        }
Example #25
0
        public void Setup()
        {
            // Arrange
            // (subs)
            _fAirspace            = Substitute.For <IAirspace <IAirplaneInfo> >();
            _fGenerator           = Substitute.For <AirplaneGenerator>();
            _fDetector            = Substitute.For <ICollisionDetector>(/*new FileLogger(_path)*/);
            _fConsoleLogger       = Substitute.For <ILog>();
            _fFileLogger          = Substitute.For <ILog>();
            _fTransponderReceiver = Substitute.For <ITransponderReceiver>();
            _fSeperationCondition = Substitute.For <ITime>();
            // _path = $"{Environment.CurrentDirectory}/log.txt";

            _uut = new AirTrafficMonitor(
                _fAirspace,
                _fGenerator,
                _fFileLogger,
                _fConsoleLogger,
                _fDetector);
        }
        public HybridAStarPlanner(
            TimeSpan timeStep,
            IWorldDefinition world,
            IReadOnlyList <IGoal> wayPoints,
            bool greedy = false)
        {
            this.timeStep  = timeStep;
            this.greedy    = greedy;
            this.wayPoints = wayPoints;

            vehicleModel      = world.VehicleModel;
            motionModel       = world.MotionModel;
            track             = world.Track;
            actions           = world.Actions;
            collisionDetector = world.CollisionDetector;

            discretizer = new StateDiscretizer(
                positionXCellSize: vehicleModel.Width / 2,
                positionYCellSize: vehicleModel.Width / 2,
                headingAngleCellSize: 2 * Math.PI / 36);

            ExploredStates = exploredStates;
        }
 public StateClassificator(ICollisionDetector collisionDetector, IGoal goal)
 {
     this.collisionDetector = collisionDetector;
     this.goal = goal;
 }
        // tid + txt

        public Log(ICollisionDetector collisionDetector)
        {
            collisionDetector.NewCollision += Logwriter;
        }
        public void ReadCommands(IHero hero, IMap map, IGameFactory factory,
                                 IConsoleLogger logger, IHeroPrinter heroprint, IFightMode mode,
                                 ICollisionDetector detect, IHeroCoordinates coord)
        {
            bool   happyend    = false;
            string currentLine = "";
            string message     = GlobalMessages.JourneyMessage;
            IEnemy enemy;

            while (hero.Hp > 0 && !happyend)
            {
                logger.Clear();
                Console.BackgroundColor = (ConsoleColor)hero.HeroColor;
                logger.Write(message);
                Console.ResetColor();
                logger.Write(hero.ToString());
                logger.Write(coord.ToString());
                logger.Write(GlobalMessages.ChooseMessage);
                logger.Write(" 1 = " + detect.GuideMessage(detect.CheckCollisions(hero.PositionX, hero.PositionY - 1, map)));
                logger.Write(" 2 = " + detect.GuideMessage(detect.CheckCollisions(hero.PositionX, hero.PositionY + 1, map)));
                logger.Write(" 3 = " + detect.GuideMessage(detect.CheckCollisions(hero.PositionX - 1, hero.PositionY, map)));
                logger.Write(" 4 = " + detect.GuideMessage(detect.CheckCollisions(hero.PositionX + 1, hero.PositionY, map)));
                logger.Write(GlobalMessages.EnterMessage);
                currentLine = logger.Read();

                switch (currentLine)
                {
                case "1":
                    if (detect.CheckCollisions(hero.PositionX, hero.PositionY - 1, map) == 'x')
                    {
                        message = GlobalMessages.EscapeMessage;
                        break;
                    }
                    else if (detect.CheckCollisions(hero.PositionX, hero.PositionY - 1, map) == '@')
                    {
                        message  = GlobalMessages.ClimbRockMessage;
                        hero.Hp -= 1;
                    }
                    else if (detect.CheckCollisions(hero.PositionX, hero.PositionY - 1, map) == '1')
                    {
                        enemy = factory.CreateMonster();
                        mode.Fight(hero, enemy, logger, heroprint);
                        message = GlobalMessages.DeadMonsterMessage;
                        hero.Move(1);
                        map.FirstMap[hero.PositionX, hero.PositionY] = '-';
                    }
                    else if (detect.CheckCollisions(hero.PositionX, hero.PositionY - 1, map) == '2')
                    {
                        enemy = factory.CreateBossMonster();
                        mode.Fight(hero, enemy, logger, heroprint);
                        message = GlobalMessages.DeadMonsterMessage;
                        hero.Move(1);
                        map.FirstMap[hero.PositionX, hero.PositionY] = '-';
                    }
                    else
                    {
                        hero.Move(1);
                        message = GlobalMessages.LeftMessage;
                    }
                    break;

                case "2":
                    if (detect.CheckCollisions(hero.PositionX, hero.PositionY + 1, map) == 'x')
                    {
                        message = GlobalMessages.EscapeMessage;
                        break;
                    }
                    else if (detect.CheckCollisions(hero.PositionX, hero.PositionY + 1, map) == '@')
                    {
                        message  = GlobalMessages.ClimbRockMessage;
                        hero.Hp -= 1;
                    }
                    else if (detect.CheckCollisions(hero.PositionX, hero.PositionY + 1, map) == '1')
                    {
                        enemy = factory.CreateMonster();
                        mode.Fight(hero, enemy, logger, heroprint);
                        message = GlobalMessages.DeadMonsterMessage;
                        hero.Move(2);
                        map.FirstMap[hero.PositionX, hero.PositionY] = '-';
                    }
                    else if (detect.CheckCollisions(hero.PositionX, hero.PositionY + 1, map) == '2')
                    {
                        enemy = factory.CreateBossMonster();
                        mode.Fight(hero, enemy, logger, heroprint);
                        message = GlobalMessages.DeadMonsterMessage;
                        hero.Move(2);
                        map.FirstMap[hero.PositionX, hero.PositionY] = '-';
                    }
                    else
                    {
                        hero.Move(2);
                        message = GlobalMessages.RightMessage;
                    }
                    break;

                case "3":
                    if (detect.CheckCollisions(hero.PositionX - 1, hero.PositionY, map) == 'x')
                    {
                        message = GlobalMessages.EscapeMessage;
                        break;
                    }
                    else if (detect.CheckCollisions(hero.PositionX - 1, hero.PositionY, map) == '@')
                    {
                        message  = GlobalMessages.ClimbRockMessage;
                        hero.Hp -= 1;
                    }
                    else if (detect.CheckCollisions(hero.PositionX - 1, hero.PositionY, map) == '1')
                    {
                        enemy = factory.CreateMonster();
                        mode.Fight(hero, enemy, logger, heroprint);
                        message = GlobalMessages.DeadMonsterMessage;
                        hero.Move(3);
                        map.FirstMap[hero.PositionX, hero.PositionY] = '-';
                    }
                    else if (detect.CheckCollisions(hero.PositionX - 1, hero.PositionY, map) == '2')
                    {
                        enemy = factory.CreateBossMonster();
                        mode.Fight(hero, enemy, logger, heroprint);
                        message = GlobalMessages.DeadMonsterMessage;
                        hero.Move(3);
                        map.FirstMap[hero.PositionX, hero.PositionY] = '-';
                    }
                    else
                    {
                        hero.Move(3);
                        message = GlobalMessages.UpMessage;
                    }
                    break;

                case "4":
                    if (detect.CheckCollisions(hero.PositionX + 1, hero.PositionY, map) == 'x')
                    {
                        message  = GlobalMessages.EscapeMessage;
                        happyend = true;
                        break;
                    }
                    else if (detect.CheckCollisions(hero.PositionX + 1, hero.PositionY, map) == '@')
                    {
                        message  = GlobalMessages.ClimbRockMessage;
                        hero.Hp -= 1;
                    }
                    else if (detect.CheckCollisions(hero.PositionX + 1, hero.PositionY, map) == '1')
                    {
                        enemy = factory.CreateMonster();
                        mode.Fight(hero, enemy, logger, heroprint);
                        message = GlobalMessages.DeadMonsterMessage;
                        hero.Move(4);
                        map.FirstMap[hero.PositionX, hero.PositionY] = '-';
                    }
                    else if (detect.CheckCollisions(hero.PositionX + 1, hero.PositionY, map) == '2')
                    {
                        enemy = factory.CreateBossMonster();
                        mode.Fight(hero, enemy, logger, heroprint);
                        message = GlobalMessages.DeadMonsterMessage;
                        hero.Move(4);
                        map.FirstMap[hero.PositionX, hero.PositionY] = '-';
                    }
                    else
                    {
                        hero.Move(4);
                        message = GlobalMessages.DownMessage;
                    }
                    break;

                default:
                    message = GlobalMessages.WrongInputMessage;
                    break;
                }
            }

            logger.Clear();

            if (happyend)
            {
                logger.Write(GlobalMessages.EscapeMessage);
                System.Threading.Thread.Sleep(1000);
                logger.Write(GlobalMessages.EscapeMessageFun);
            }
            else
            {
                logger.Write(GlobalMessages.DeadGameMessage);
                System.Threading.Thread.Sleep(1000);
                logger.Write(GlobalMessages.DeadGameMessageFun);
            }

            logger.Write(GlobalMessages.GameOverMessage);
        }
 /// <summary>
 /// Register the detectos
 /// </summary>
 /// <param name="collisionDetector"></param>
 public static void RegisterDetector(ICollisionDetector collisionDetector)
 {
     collisionDetectors.Add(collisionDetector);
 }
 public SlowPokeGameField(ICollisionDetector collisionDetector, IGameTicker gameTicker)
 {
     _collisionDetector = collisionDetector;
     _gameTicker        = gameTicker;
 }
Example #32
0
 public void SetUp()
 {
     //arrange
     _fakeCollisionDetector = Substitute.For <ICollisionDetector>();
     uut = new Log(_fakeCollisionDetector);
 }