Exemple #1
0
        public void Move(MovementDirectionEnum movementDirection)
        {   //BAT
            //Define Behavior
            System.Windows.Point    batLocation             = _imageManager.GetImageLocation(EnemyImage);
            BehaviorPropertiesModel behaviorPropertiesModel = new BehaviorPropertiesModel()
            {
                EnemyName         = EnemyName,
                MovementDirection = movementDirection,
                Target            = _playerLocationPoint,
                Chaser            = batLocation,
            };

            var behavioralDirection = _selectedBehavior.ApplyBehavior(behaviorPropertiesModel);
            //Confirm Castle Wall Boundaries reached
            var _imageObjectShapeModel        = _castle.GetCanvasLocationAndDimensionsOuterLimits();
            var castleSideWallBoundaryReached = _imageManager.ImageIsBeyondBoundaries_Adaptor(_imageObjectShapeModel, EnemyImage);

            var selectedMovementDirection = (castleSideWallBoundaryReached == MovementDirectionEnum.MovementClear_NoBoundariesReached)
                                            ? behavioralDirection
                                            :_movementDirectionManager.GetOppositeDirection(castleSideWallBoundaryReached);

            //Set Movement
            MovementDirection = selectedMovementDirection;
            //Process Movement
            System.Drawing.Point newLocationPoint      = _movementStrategy.GetMovement(MovementDirection);
            System.Drawing.Point newSpeedLocationPoint = _imageManager.ModifyLocationPointValues(newLocationPoint, _speedMovement);
            _imageManager.SetNewLocationImage(EnemyImage, newSpeedLocationPoint);
        }
Exemple #2
0
        public MovementDirectionEnum ApplyBehavior(BehaviorPropertiesModel behaviorProperties)
        {
            if (behaviorProperties.Target.HasValue && behaviorProperties.Chaser.HasValue)
            {
                Point targetLocation = (Point)behaviorProperties.Target;
                Point chaserLocation = (Point)behaviorProperties.Chaser;
                if (horizontalVerification == 0)
                {
                    horizontalVerification++;
                    verticalVerification = 0;

                    //Movement To the Left
                    if (targetLocation.X < chaserLocation.X)
                    {
                        return(MovementDirectionEnum.MovingLeft);
                    }

                    //Movement To the Right
                    if (targetLocation.X > chaserLocation.X)
                    {
                        return(MovementDirectionEnum.MovingRight);
                    }
                }
                if (verticalVerification == 0)
                {
                    verticalVerification++;
                    horizontalVerification = 0;
                    //Movement Up
                    if (targetLocation.Y < chaserLocation.Y)
                    {
                        return(MovementDirectionEnum.MovingUp);
                    }
                    //Movement Down
                    if (targetLocation.Y > chaserLocation.Y)
                    {
                        return(MovementDirectionEnum.MovingDown);
                    }
                }
            }
            return(MovementDirectionEnum.NotMoving);
        }
Exemple #3
0
        public MovementDirectionEnum ApplyBehavior(BehaviorPropertiesModel behaviorPropertiesModel)
        {
            var enemyFound = behaviorEnemies.Where(a => a.EnemyName == behaviorPropertiesModel.EnemyName).FirstOrDefault();

            if (enemyFound == null)
            {
                var enemyNewInfo = new BehaviorEnemyInfoModel()
                {
                    EnemyName            = behaviorPropertiesModel.EnemyName,
                    ConsecutiveMovements = GetNonRepeatingRandomConsecutiveMovements(),
                    IterationCounter     = 0,
                };

                behaviorEnemies.Add(enemyNewInfo);
            }
            MovementDirectionEnum movementDirection = MovementDirectionEnum.NotMoving;

            foreach (var singleEnemy in behaviorEnemies)
            {
                if (singleEnemy.EnemyName == behaviorPropertiesModel.EnemyName)
                {
                    singleEnemy.IterationCounter++;
                    movementDirection = (behaviorPropertiesModel.MovementDirection.HasValue)
                                                      ? (MovementDirectionEnum)behaviorPropertiesModel.MovementDirection
                                                      : MovementDirectionEnum.NotMoving;

                    if (singleEnemy.ConsecutiveMovements == singleEnemy.IterationCounter)
                    {
                        movementDirection = _movementDirectionManager.GetNonRepeatingRandomDirection(movementDirection);
                        singleEnemy.ConsecutiveMovements = GetNonRepeatingRandomConsecutiveMovements();
                        singleEnemy.IterationCounter     = 0;
                    }
                }
            }
            return(movementDirection);
        }