Exemplo n.º 1
0
        public Maze(String character, Maze.Difficulty difficulty)
        {
            gameDifficulty = difficulty;
            InitializeComponent();
            CreateGrid();
            textGrid = InsertWalls();
            AddBottomButtons();
            goggles = new TextBlock();
            ImageBrush  myBrush = new ImageBrush();
            Image       image   = new Image();
            BitmapImage bi      = new BitmapImage(new Uri(filePath + @"\goggles.png"));

            image.Source        = bi;
            myBrush.ImageSource = image.Source;
            goggles.Background  = myBrush;
            int    i = 6, j = 3;
            Random rnd = new Random();

            while (textGrid[i - 1][j - 1] == 'x')
            {
                i = rnd.Next(1, 20);
                j = rnd.Next(1, 20);
            }
            gogglesLocation[0] = i;
            gogglesLocation[1] = j;
            Grid.SetColumn(goggles, j);
            Grid.SetRow(goggles, i);
            this.grid.Children.Add(goggles);
            InstantiateCharacter(character.ToLower(), fishLocation);
            InstantiateCharacter("shark", sharkLocation);
            AddCharacterMovement();
            TrainShark();
            AddSharkMovement();
        }
Exemplo n.º 2
0
        private void DifficultySelect(object sender, RoutedEventArgs e)
        {
            ListBox     listbox = (ListBox)sender;
            ListBoxItem item    = (ListBoxItem)listbox.SelectedItem;

            this.selectedDifficulty = (Maze.Difficulty)item.Content;
            readyToPlay[1]          = true;
            if (this.readyToPlay[0] && this.readyToPlay[1])
            {
                foreach (Button button in FindVisualChildren <Button>(this.grid))
                {
                    button.IsEnabled = true;
                }
            }
        }
Exemplo n.º 3
0
        private void ChangeDifficulty()
        {
            Array array = Enum.GetValues(typeof(Maze.Difficulty));

            for (int i = 0; i < array.Length; i++)
            {
                if ((Maze.Difficulty)array.GetValue(i) == difficulty)
                {
                    int newIndex = (i + 1) % array.Length;
                    difficulty = (Maze.Difficulty)array.GetValue(newIndex);

                    NewMaze(false);
                    break;
                }
            }
        }