예제 #1
0
        //this function is called in the game-engine. We first check if the nextmove is possible (the move from userinput) if its possible we set that move, if its impossible
        //a gamebreaking event has been fired by the CollisionDector or we try the CurrentMove and based on that outcome we move/stop/break te game.
        public void ProcessMove(MovableObject sprite)
        {
            if (CollisionDetecter.ObjectCollision(PlaygroundObjects, sprite, sprite.NextMove) == Collision.Clear)
            {
                sprite.CurrentMove = sprite.NextMove;
            }
            else if (CollisionDetecter.ObjectCollision(PlaygroundObjects, sprite, sprite.CurrentMove) !=
                     Collision.Clear)
            {
                sprite.CurrentMove = sprite.NextMove = Move.Stop;
            }

            UpdatePosition(sprite);
        }
예제 #2
0
        private int _stepsInDirection; // necessary for smooth movement of enemy

        public Position(GameValues gameValues)
        {
            _gameValues       = gameValues;
            CollisionDetecter = new CollisionDetecter(_gameValues);
            _random           = new Random();
            _enemyMoves       = new List <Move>
            {
                Move.Left,
                Move.Right,
                Move.Down,
                Move.Up
            };
            _lastMove         = new Move();
            _stepsInDirection = 0;
        }
예제 #3
0
 //determines if direction is possible
 private bool PossibleMove(MovableObject enemy, Move move) =>
 CollisionDetecter.ObjectCollision(PlaygroundObjects, enemy, move) == Collision.Clear;