internal void Shoot(Game game, ConsoleKey key)
        {
            (int x, int y)direction = DirectionMenager.PassDirection(key);
            if (direction.x == 0 && direction.y == 0)
            {
                return;
            }
            (int x, int y)bullet = game.userService.User.Key;
            Board board = game.boardService.Board;

            do
            {
                bullet.x += direction.x;
                bullet.y += direction.y;
                if (game.assetService.IsAsset(bullet))
                {
                    if (game.assetService.GetAsset(bullet).Symbol != "d")
                    {
                        return;
                    }
                    else
                    {
                        game.gameStateManager.ScoreDaniel(game);
                        return;
                    }
                }
            } while (bullet.x >= 0 &&
                     bullet.x < board.Width &&
                     bullet.y >= 0 &&
                     bullet.y < board.Height);
        }
 private void Move(ConsoleKey key)
 {
     (int ofX, int ofY)modification = DirectionMenager.PassDirection(key);
     game.userActionManager.MoveUser(modification, game);
     game.gameStateManager.HasDanielBeenCought(game);
     new DanielManager((Daniel)game.assetService.GetAsset(AssetsNamesEnum.Daniel.ToString())).RunDaniel(game);
 }
        internal void ChopTree(Game game, ConsoleKey key)
        {
            Tree tree = new Tree();

            (int x, int y)direction = DirectionMenager.PassDirection(key);
            int X = user.X + direction.x;
            int Y = user.Y + direction.y;

            if (X >= 0 &&
                X < game.boardService.Board.Width &&
                Y >= 0 &&
                Y < game.boardService.Board.Height &&
                game.boardService.Board.PlayArea[Y].Substring(X, 1) == tree.Symbol)
            {
                game.assetService.RemoveFromAssets(game.assetService.GetAsset((X, Y)));
                game.boardManager.RemoveSymbolFromPlayArea((X, Y));
            }
        }
Exemple #4
0
        public void RunDaniel(Game game)
        {
            Random random    = new Random();
            Daniel daniel    = game.assetService.GetAsset(AssetsNamesEnum.Daniel.ToString()) as Daniel;
            Daniel newDaniel = daniel;

            game.assetManager.DisposeAsset(daniel);
            User user = game.userService.User;

            (int higher, int lower)Y = newDaniel.Y > user.Y ? (newDaniel.Y, user.Y) : (user.Y, newDaniel.Y);
            (int higher, int lower)X = newDaniel.X > user.X ? (newDaniel.X, user.X) : (user.X, newDaniel.Y);
            int distance = Y.higher - Y.lower >= X.higher - X.lower ? (X.higher - X.lower) : (Y.higher - Y.lower);

            if (distance < 11)
            {
                bool placePossible = false;
                do
                {
                    int newX            = newDaniel.X;
                    int newY            = newDaniel.Y;
                    int randomDirection = random.Next(1, 10);
                    var key             = DirectionMenager.ConvertIntToConsoleKey(randomDirection);
                    (int x, int y)modificators = DirectionMenager.PassDirection(key);
                    newX += modificators.x;
                    newY += modificators.y;
                    if (newX >= 0 &&
                        newX < game.boardService.Board.Width &&
                        newY >= 0 &&
                        newY < game.boardService.Board.Height)
                    {
                        if (!game.assetService.IsAsset((newX, newY)))
                        {
                            placePossible = true;
                            newDaniel.X  += modificators.x;
                            newDaniel.Y  += modificators.y;
                        }
                    }
                } while (!placePossible);
            }
            game.assetManager.IntroduceAsset(newDaniel);
        }