Exemple #1
0
        public static void Do(Field field)
        {
            DX = new Dictionary<Directions, int>
            {
                { Directions.N, 0 },
                { Directions.S, 0 },
                { Directions.E, 1 },
                { Directions.W, -1 }
            };

            DY = new Dictionary<Directions, int>
            {
                { Directions.N, -1 },
                { Directions.S, 1 },
                { Directions.E, 0 },
                { Directions.W, 0 }
            };

            OPPOSITE = new Dictionary<Directions, Directions>
            {
                { Directions.N, Directions.S },
                { Directions.S, Directions.N },
                { Directions.E, Directions.W },
                { Directions.W, Directions.E }
            };

            Point randomPos = new Point();
            randomPos.X = new Random(DateTime.Now.Millisecond).Next(0, field.Size.X);
            randomPos.Y = new Random(DateTime.Now.Millisecond).Next(0, field.Size.Y);
            CarvePassages(randomPos.X, randomPos.Y, field.Cells);
            ValuesToBorders(field);
        }
Exemple #2
0
        public Engine()
            : base()
        {
            // load settings
            Resolution = new Point(Settings.Resolution.X,
                                Settings.Resolution.Y);

            Fieldsize = new Point(Settings.FieldSize.X,
                                  Settings.FieldSize.Y);

            InitialBombs = Settings.Bombs;
            Scale = Settings.Scale;
            CorrectionScale = Settings.CorrectionScale;
            Port = Settings.Port;
            initialTime = Settings.Time;
            initialMaxHP = 100;
            currentTime = initialTime;

            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferHeight = Settings.Resolution.Y;
            graphics.PreferredBackBufferWidth = Settings.Resolution.X;
            graphics.ApplyChanges();

            PlayerData = new Player.Data(initialMaxHP);

            this.playField = new Playfield.Field(this, Resolution, Fieldsize, InitialBombs);

            Point TimerPosition = new Point();
            TimerPosition.X = 5;
            TimerPosition.Y = (Resolution.Y - 83);
            this.Timer = new PlayerFeedback.CountdownTimer(this, initialTime, TimerPosition);
            Timer.IsEnabled = true;
            
            this.Info = new PlayerFeedback.InfoView(this, PlayerData, new Point(220, Resolution.Y - 60));
            
            this.GameOverScreen = new PlayerFeedback.GameOverView(this, PlayerData.Score);

            this.tutorial = new PlayerFeedback.Tutorial(this);

            Content.RootDirectory = "Content";
        }
Exemple #3
0
        private static void ValuesToBorders(Field field)
        {
            int rows = field.Cells.GetLength(1);
            int columns = field.Cells.GetLength(0);            

            for (int y = 0; y < rows; y++)
            {
                field.Cells[0, y].Borders[3] = true;
                for (int x = 0; x < columns; x++)
                {
                    var directions = (Directions)field.Cells[x, y].Value;

                    if (!directions.HasFlag(Directions.N))
                        field.Cells[x, y].Borders[0] = true;

                    if (!directions.HasFlag(Directions.E))
                        field.Cells[x, y].Borders[1] = true;
                }
            }

            // top border
            for (int i = 0; i < columns; i++)
            {
                field.Cells[i, 0].Borders[0] = true;
            }

            // bottom border
            for (int i = 0; i < columns; i++)
            {
                field.Cells[i, rows - 1].Borders[2] = true;
            }
        }