예제 #1
0
 /// <summary>
 /// Interact with a moving object that enters this Base's cell.
 /// </summary>
 /// <param name="movingObject">Object that enters this Base's cell.</param>
 public override void InteractWithMovingObject(MovableObject movingObject)
 {
     movingObject.MovingDirection = this.PointDirection;
 }
예제 #2
0
 /// <summary>
 /// Interact with a moving object that enters this Spawner's cell.
 /// </summary>
 /// <param name="movingObject">Object that enters this Spawner's cell.</param>
 public override void InteractWithMovingObject(MovableObject movingObject)
 {
     movingObject.Turn();
 }
예제 #3
0
        /// <summary>
        /// Spawn a new MovableObject on the board.
        /// </summary>
        private void Spawn()
        {
            // Determine movement direction of the new MovableObject
            Direction objectMovementDirection = this.SpawnDirection;

            if (objectMovementDirection == Direction.Random)
            {
                objectMovementDirection = DirectionUtils.GetRandomDirection();
            }

            // Determine the turning direction of the new MovableObject
            Direction objectTurnDirection = GameSettings.TurnDirection;

            if (objectTurnDirection == Direction.Random)
            {
                objectTurnDirection = DirectionUtils.GetRandomHorizontalDirection();
            }

            // Calculate the starting cell based on the movement direction
            int objectStartCol = this.CellCol;
            int objectStartRow = this.CellRow;

            switch (objectMovementDirection)
            {
            case Direction.Up:
                objectStartRow--;
                break;

            case Direction.Down:
                objectStartRow++;
                break;

            case Direction.Right:
                objectStartCol++;
                break;

            case Direction.Left:
                objectStartCol--;
                break;

            default:
                throw new Exception(String.Format("Spawner is using an unknown or invalid Direction value: {0}", objectMovementDirection));
            }

            // Determine if this is a positive or negative object
            int objectScore = GameSettings.ObjectScore;

            if (GameSettings.RANDOM.NextDouble() <= GameSettings.ProbabilityOfNegativeSpawn)
            {
                objectScore = GameSettings.NegativeObjectScore;
            }

            MovableObject newObject = new MovableObject(objectStartCol, objectStartRow, objectMovementDirection, objectTurnDirection, objectScore, GameSettings.CellsPerMove);

            if (this.ObjectSpawnedHandler != null)
            {
                this.ObjectSpawnedHandler(newObject, null);
            }

            this.SpawnedObjects.Add(newObject);
        }
예제 #4
0
 /// <summary>
 /// Interact with a moving object that enters this Base's cell.
 /// </summary>
 /// <param name="movingObject">Object that enters this Base's cell.</param>
 public override void InteractWithMovingObject(MovableObject movingObject)
 {
     this.Player.UpdateScore(movingObject.PointValue);
 }