Exemplo n.º 1
0
 public Game(Image minCurrentPlayer)
 {
     board                 = new Board();
     settingWindow         = SettingsWindow.getInstance();
     this.minCurrentPlayer = minCurrentPlayer;
     computer              = new Computer(board);
     resetGame();
 }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            game           = new Game(iAnimalRound);
            settingsWindow = SettingsWindow.getInstance();

            lPoints.DataContext          = game;
            itemControlBoard.ItemsSource = game.board.fields;
        }
Exemplo n.º 3
0
        public List <Point> predatorsPosition()
        {
            List <Point> predatorsPosition = new List <Point>();;

            for (int i = 0; i < fields.Count; i++)
            {
                for (int j = 0; j < fields[i].Count; j++)
                {
                    if (fields[i][j].Image == SettingsWindow.getInstance().PredatorImage)
                    {
                        predatorsPosition.Add(new Point(i, j));
                    }
                }
            }
            return(predatorsPosition);
        }
Exemplo n.º 4
0
        public Board()
        {
            fields = new ObservableCollection <ObservableCollection <Field> >();
            for (int i = 0; i < BOARD_HIGHT; i++)
            {
                fields.Add(new ObservableCollection <Field>());
                for (int j = 0; j < BOARD_WIDTH; j++)
                {
                    fields[i].Add(new Field(null, i, j));
                }
            }

            activeFields = new Stack <Point>();
            activeAnimal = new Point(-1, -1);

            settingsWindow = SettingsWindow.getInstance();
        }
Exemplo n.º 5
0
        private bool attackMove()
        {
            // 'Klikniecie' na tygrysy
            for (int i = 0; i < board.fields.Count; i++)
            {
                for (int j = 0; j < board.fields[i].Count; j++)
                {
                    if (board.fields[i][j].Image == SettingsWindow.getInstance().PredatorImage)
                    {
                        board.colorFieldsToMove(i, j, true);
                    }
                }
            }

            // Dodanie zagrozonych
            List <Point> dangerousHerbivore = new List <Point>();

            for (int i = 0; i < board.fields.Count; i++)
            {
                for (int j = 0; j < board.fields[i].Count; j++)
                {
                    if (board.fields[i][j].Active == FieldState.Attack)
                    {
                        dangerousHerbivore.Add(new Point(i, j));
                    }
                }
            }
            board.clearColorFieldsToMove();

            // Przesuniecie zagrozonych
            foreach (var i in dangerousHerbivore)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (randWayMove(i.X, i.Y))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 6
0
        private void randMove()
        {
            int chosenX = -1;
            int chosenY = -1;

            while (true)
            {
                // Znalezienie zwierzaka
                while (true)
                {
                    chosenX = rand.Next(Board.BOARD_HIGHT);
                    chosenY = rand.Next(Board.BOARD_WIDTH);
                    if (board.fields[chosenX][chosenY].Image == SettingsWindow.getInstance().HerbivoreImage)
                    {
                        break;
                    }
                }

                if (randWayMove(chosenX, chosenY) == true)
                {
                    return;
                }
            }
        }