Ejemplo n.º 1
0
 private void FixedUpdate()
 {
     if (moveStrategy != null)
     {
         moveStrategy.Move(moveSpeed);
     }
 }
Ejemplo n.º 2
0
        public override void HandlePlayGameRequest(IGameDisplay display, IBoard board)
        {
            int turn = 0;

            do
            {
                turn++;
                var player = turn % 2 == 0 ? 'O' : 'X';
                display.TurnMessage(turn);
                _moveStrategy.Move(player, board);
                display.DrawBoard(board);
                Thread.Sleep(_sleepDuration);
            } while (board.IsInPlay());

            if (_successor != null)
            {
                _successor.HandlePlayGameRequest(display, board);
            }
        }
Ejemplo n.º 3
0
 public void UpdatePosition(float move)
 {
     _moveStrategy.Move(_transform, move);
 }
Ejemplo n.º 4
0
 public virtual void Move()
 {
     Console.Write("I'm a {0}", name);
     moveStrategy.Move();
 }
Ejemplo n.º 5
0
        public async Task Run(CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            // TODO: Provide initial location
            GeoCoordinate currentLocation = new GeoCoordinate(48.642050, 9.458333);

            // Provide "fuzzy" movement observer
            //FuzzyLocationFeed fuzzyLocationFeed = new FuzzyLocationFeed(currentLocation, _moveStrategy, 10);
            TestLocationObserver testLocationObserver = new TestLocationObserver("test1");
            //IDisposable testLocationObserver1Subscription = fuzzyLocationFeed.Subscribe(testLocationObserver);
            var testLocationObserver1Subscription = _moveStrategy.Subscribe(testLocationObserver);

            Task movement = Task.Run(
                async() =>
            {
                while (true)
                {
                    _logger.Trace("walking...");

                    // simulate POIModule
                    PointOfInterest pointOfInterest = _poiProvider.GetPointOfInterest();
                    _logger.Trace(
                        "(POI) {0} ({1}, {2})", pointOfInterest.Name, pointOfInterest.Location.Latitude, pointOfInterest.Location.Longitude);

                    // get route to POI
                    NavigationRoute navigationRoute = await _navigator.GetDirectionsAsync(currentLocation, pointOfInterest.Location);
                    _logger.Trace(
                        "(NAV) Found a route to {0}. Let's go ({1}m, {2}s)", pointOfInterest.Name, navigationRoute.Distance,
                        navigationRoute.TravelTime);

                    // move
                    await _moveStrategy.Move(navigationRoute);
                }
            }, cancellationToken);

            Task action = Task.Run(
                async() =>
            {
                while (true)
                {
                    int x = new Random().Next(0, 1000);
                    if (x % 13 == 0)
                    {
                        _logger.Trace("Set movement speed 0!");
                        _moveStrategy.SetMovementSpeed(0);

                        await Task.Delay(10000, cancellationToken);
                    }
                    else if (x % 17 == 0)
                    {
                        _logger.Trace("Set movement speed 20!");
                        _moveStrategy.SetMovementSpeed(20);
                    }

                    await Task.Delay(1000, cancellationToken);
                }
            }, cancellationToken);

            await Task.WhenAll(movement, action);

            testLocationObserver1Subscription.Dispose();
        }
Ejemplo n.º 6
0
 public virtual void PrepareMove(GameTime gameTime)
 {
     //Update strategy and make move
     currentStrategy.Update(gameTime);
     currentStrategy.Move(this);
 }
Ejemplo n.º 7
0
 public void Move()
 {
     MoveStrategy.Move(this);
 }
Ejemplo n.º 8
0
 public Car()
 {
     _move = new DriveStrategy();
     _move.Move();
 }