Пример #1
0
        public Model(System.Windows.Forms.Panel canvas, int width, int height)
        {
            this.canvas = canvas;
            board       = new Field[width, height];
            this.Width  = width;
            this.Height = height;
            Field.adaptSize(Width, Height, canvas);
            mapgen();
            timer.Tick += Timer_Tick;
            player      = new MapObjects.Player(ref board[1, height / 2], 100, this);
            player.inventory.equipment.Add(new Inventory.Item(100, 20, Inventory.objecttype.SWORD, "magic Sword"));
            player.inventory.equipment.Add(new Inventory.Item(10, 20, Inventory.objecttype.POTION, "healing potion"));
            player.inventory.stuff.Add(new Inventory.Item(10, 20, Inventory.objecttype.BOW, "broken bow"));
            player.inventory.equipment.Add(new Inventory.Item(20, 50, Inventory.objecttype.BOMB, "bomb"));
            player.inventory.equipment.Add(new Inventory.Item(10, 20, Inventory.objecttype.ARMOR, "rags"));
            corps = new MapObjects.Stash(ref player.position, player.inventory, "corps");
            Field f = determineSpawnPosition();
            Field p = determineSpawnPosition();

            merchant = new MapObjects.Merchant(ref f, 100, this); //@todo merchant wird nicht gezeichnet
            monster.Add(new MapObjects.Monster(ref p, 100, this));
            interactables.Add(merchant);
            interactables.Add(player);
            interactables.AddRange(monster);
            timer.Interval = 10;
            timer.Enabled  = true;
        }
Пример #2
0
 //Vytvoření pole field
 public Field[,] initializeGameField()
 {
     field = new Field[9, 9];
     for (int i = 0; i < 81; i++)
     {
         int row = i / 9;
         int col = i % 9;
         int sqr = 0;
         if (row >= 0 && row <= 3)
         {
             sqr = col / 3;
         }
         if (row >= 3 && row <= 6)
         {
             sqr = (col / 3) + 3;
         }
         if (row >= 6 && row <= 9)
         {
             sqr = (col / 3) + 6;
         }
         field[row, col] = new Field {
             Value = 0, Writable = false, Square = sqr
         };
     }
     return(field);
 }
Пример #3
0
        public Map(string inMapFile)
        {
            if(FieldTypes.Types.Count < 1)
                new FieldTypes().load();

            TextReader reader = new StreamReader(inMapFile);
            List<string> lines = new List<string>();
            string line;
            int maxSize = 0;
            while((line = reader.ReadLine()) != null)
            {
                lines.Add(line);
                int size = line.Split(' ').Length;
                if(size > maxSize)
                    maxSize = size;
            }

            this.m_fields = new Field[maxSize, lines.Count];
            for(int i = 0; i < lines.Count; i++)
            {
                string[] fields = lines[i].Split(' ');
                for(int i2 = 0; i2 < fields.Length; i2++)
                {
                    string field = fields[i2];
                    int texture = Convert.ToInt32(field.Substring(0, 2), 16);
                    this.m_fields[i2, i] = new Field(FieldTypes.Types[texture]);
                }
            }
            reader.Close();
            reader.Dispose();
        }
Пример #4
0
 public PuzzlePiece(Field[,] matrix, Brush brush)
 {
     this.brush  = brush;
     this.matrix = matrix;
     width       = matrix.GetLength(1);
     height      = matrix.GetLength(0);
 }
Пример #5
0
        public Board()
        {
            board = new Field[buffer.WindowHeight, buffer.WindowHeight];
            for (int i = 1; i < board.GetLength(0)-1; i++)
                for (int j = 1; j < board.GetLength(1)-1; j++)
                {
                    int x = random.Next(0, 4);
                    if ((Field)x == Field.ROCK)
                        if (random.Next(3) < 2)
                            x = 1;
                                if ((Field)x == Field.DIAMOND)
                        if (random.Next(3) < 2)
                            x = 1;
                    board[i, j] = (Field)x;//Field.HAY;
                    if ((Field)x == Field.DIAMOND)
                        maxScore++;
                }

            for (int i = 0; i < board.GetLength(0); i++)
            {
                board[i, 0] = Field.WALL;
                board[i, buffer.WindowHeight - 1] = Field.WALL;
            }
            for (int i = 0; i < board.GetLength(1); i++)
            {
                board[0, i] = Field.WALL;
                board[buffer.WindowHeight - 1 , i] = Field.WALL;
            }

            board[random.Next(1, 30), random.Next(1, 30)] = Field.EXIT;

            FallingBlocks = new List<Pair>();
            DeadlyBlocks = new List<Pair>();
        }
Пример #6
0
        bool CheckArea(Field[,] board, int i, int j)
        {
            Field mines = Field.One;

            for (int x = i - 1; x <= i + 1; x++)
            {
                if (x < 0 || board.GetLength(0) <= x)
                {
                    continue;
                }

                for (int y = j - 1; y <= j + 1; y++)
                {
                    if (y < 0 || board.GetLength(1) <= y)
                    {
                        continue;
                    }

                    if (board[x, y].HasFlag(Field.Mine))
                    {
                        mines = (Field)((int)mines >> 1);
                    }
                }
            }
            mines = (Field)((int)mines << 1);

            return(board[i, j].HasFlag(mines));
        }
Пример #7
0
        public static bool CheckWinner(Field[,] table, bool PlayerOnesTurn, Position position) // Winning Conditions
        {
            string player = "X";

            if (!PlayerOnesTurn) // if PlayerOnesTurn isn't true the player X swaps to player O
            {
                player = "O";
            }
            //Console.WriteLine(table[position.column, 0].GetStatus().Equals(player) + " " + table[position.column, 0].GetStatus() + " " + player); was used to print if one of the certain parameters is true or false
            if (table[position.column, 0].GetStatus() == player && table[position.column, 1].GetStatus() == player && table[position.column, 2].GetStatus() == player) //Vertical
            {
                return(true);
            }
            if (table[0, position.row].GetStatus() == player && table[1, position.row].GetStatus() == player && table[2, position.row].GetStatus() == player) //Horizontal
            {
                return(true);
            }
            if (table[0, 0].GetStatus() == player && table[1, 1].GetStatus() == player && table[2, 2].GetStatus() == player) //Diagonal 1
            {
                return(true);
            }
            if (table[2, 0].GetStatus() == player && table[1, 1].GetStatus() == player && table[0, 2].GetStatus() == player) //Diagonal 2
            {
                return(true);
            }

            return(false);
        }
Пример #8
0
        /// <summary>
        /// #ctor
        /// </summary>
        /// <param name="bmp">Bitmap with map data</param>
        public Grid(Bitmap bmp)
        {
            this.size        = new Size(bmp.Width, bmp.Height);
            this.fields      = new Field[size.Width, size.Height];
            this.fieldWidth  = 1; //gridPanel.Width / size.Width;
            this.fieldHeight = 1; //gridPanel.Height / size.Height;
            this.bmp         = bmp;

            //load info from bitmap
            blockedPosition = new List <Point>();
            for (int i = 0; i < bmp.Width; i++)
            {
                for (int j = 0; j < bmp.Height; j++)
                {
                    this.fields[i, j]          = new Field();
                    this.fields[i, j].position = new Point(i, j);
                    if (!(bmp.GetPixel(i, j).R > 250))
                    {
                        blockedPosition.Add(new Point(i, j));
                        fields[i, j].blocked = true;
                    }
                }
            }

            this.map = WiccanRede.AI.Map.GetInstance(this);
            h        = new float[this.map.MapSize.X, this.map.MapSize.Y];
        }
Пример #9
0
        public MineField(int xLength, int yLength, Dictionary<MinesColors, int> mineColoring)
        {
            int numOfFields = xLength * yLength;
            int numOfMines = 0;
            foreach (var coloring in mineColoring)
            {
                numOfMines += coloring.Value;
            }

            if (xLength <= 0)
            {
                throw new ArgumentException("Value must be greater than 0", "xLength");
            }
            if (yLength <= 0)
            {
                throw new ArgumentException("Value must be greater than 0", "yLength");
            }
            if (numOfMines >= numOfFields)
            {
                throw new ArgumentException("Number of mines must be smaller than number of fields!", "numOfMines");
            }
            this._MineColoring = mineColoring;
            this._FieldsCount = numOfFields;
            this._MinesCount = numOfMines;
            this._Fields = new Field[xLength, yLength];
            this.CreateMineField();
        }
Пример #10
0
 public override Field GetPositionAfterAttack(Field[,] board, Field destination)
 {
     if (currentX == destination.transform.position.x)
     {
         // Atakujemy w pionie
         if (Mathf.Abs(currentY - destination.transform.position.y) <= 2)
         {
             return(board[currentX, currentY]);
         }
         else
         {
             return(board[currentX, (int)(destination.transform.position.y + (2 * (currentY - destination.transform.position.y) / Mathf.Abs(currentY - destination.transform.position.y)))]);
         }
     }
     else if (currentY == destination.transform.position.y)
     {
         // Atakujemy w poziomie
         if (Mathf.Abs(currentX - destination.transform.position.x) <= 2)
         {
             return(board[currentX, currentY]);
         }
         else
         {
             return(board[(int)(destination.transform.position.x + (2 * (currentX - destination.transform.position.x) / Mathf.Abs(currentX - destination.transform.position.x))), (int)(destination.transform.position.y)]);
         }
     }
     throw new System.NotImplementedException();
 }
Пример #11
0
        private bool IsJunction(Field field)
        {
            if (field.isPath == false)
            {
                return(false);
            }
            bool pathLeft  = false;
            bool pathRight = false;
            bool pathUp    = false;
            bool pathDown  = false;

            Field[,] maze = mazeArray;
            try {
                if (field.xCoord >= 1)
                {
                    pathLeft = maze[field.yCoord, field.xCoord - 1].isPath;
                }
                if (field.xCoord <= imageWidth - 2)
                {
                    pathRight = maze[field.yCoord, field.xCoord + 1].isPath;
                }
                if (field.yCoord > 0)
                {
                    pathUp = maze[field.yCoord - 1, field.xCoord].isPath;
                }
                if (field.yCoord <= imageHeigth - 2)
                {
                    pathDown = maze[field.yCoord + 1, field.xCoord].isPath;
                }
            }
            catch (Exception error) {
                MessageBox.Show("A handled Exception occured during junction finding: " + error);
            }
            return((pathUp || pathDown) && (pathLeft || pathRight));
        }
Пример #12
0
        public static int GetRowOfNearestIsFull(Field[,] _2DArr, int row, int col, int rows)
        {                              // based on  BREADTH-FIRST-SEARCH instead of recursion http://www8.cs.umu.se/kurser/TDBA36/VT02/lec5.html
            Queue queue = new Queue(); // https://www.guru99.com/c-sharp-queue.html

            queue.Enqueue(new object { });
            int currentRow = row;

            while (queue.Count > 0)
            {
                queue.Dequeue();
                if (_2DArr[currentRow, col].IsFull == true)
                {
                    break;
                }
                else
                {
                    currentRow++;
                    if (currentRow < rows)
                    {
                        queue.Enqueue(new object { });
                    }
                    else
                    {
                        currentRow = -1;
                    }
                }
            }
            return(currentRow);
        }
Пример #13
0
        private void AssignShipPartToField(Field[,] board, KeyValuePair <ShipType, int> ship, int shipLength, int column, int row, Direction direction)
        {
            for (int j = 0; j < shipLength; j++)
            {
                switch (direction)
                {
                case Direction.Up:
                    board[row - j, column].FieldValue = ship.Key.GetDescription();
                    board[row - j, column].FieldType  = FieldType.LiveShipPart;
                    break;

                case Direction.Down:
                    board[row + j, column].FieldValue = ship.Key.GetDescription();
                    board[row + j, column].FieldType  = FieldType.LiveShipPart;
                    break;

                case Direction.Left:
                    board[row, column - j].FieldValue = ship.Key.GetDescription();
                    board[row, column - j].FieldType  = FieldType.LiveShipPart;
                    break;

                case Direction.Right:
                    board[row, column + j].FieldValue = ship.Key.GetDescription();
                    board[row, column + j].FieldType  = FieldType.LiveShipPart;
                    break;
                }
            }
        }
Пример #14
0
        private void SetShipsRandlomlyOnBoard(Field[,] board)
        {
            var random = new Random();

            foreach (var ship in _shipsWithQuantity)
            {
                for (int i = 0; i < ship.Value;)
                {
                    var shipLength          = (int)ship.Key;
                    var randomColumnAtBoard = random.Next(BoardSize);
                    var randomRowAtBoard    = random.Next(BoardSize);
                    var randomDirection     = (Direction)random.Next(4);

                    var isShipFitToBoard = IsShipWillFitToBoard(shipLength, randomColumnAtBoard, randomRowAtBoard, randomDirection);

                    if (isShipFitToBoard == false)
                    {
                        continue;
                    }

                    var isExistShipInLine = IsInLineExistOtherShip(board, shipLength, randomColumnAtBoard, randomRowAtBoard, randomDirection);

                    if (isExistShipInLine)
                    {
                        continue;
                    }

                    AssignShipPartToField(board, ship, shipLength, randomColumnAtBoard, randomRowAtBoard, randomDirection);

                    i++;
                }
            }
        }
Пример #15
0
 private void PrepareGameBoard()
 {
     BoardForFirstPlayer = new Field[BoardSize, BoardSize];
     FillGameBoardWithEmptyFields(BoardForFirstPlayer);
     BoardForSecondPlayer = new Field[BoardSize, BoardSize];
     FillGameBoardWithEmptyFields(BoardForSecondPlayer);
 }
Пример #16
0
 public PathFinder(Field[,] m, Position origin, Position destination)
     : base(origin)
 {
     this.m           = m;
     this.origin      = origin;
     this.destination = destination;
 }
Пример #17
0
        public Field[,] Generate_Map(Point clickedPoint, ref Field[,] mapToChange)
        {
            List <Point> cordsForBombs = cordsForBombs_CONST;

            // Field[,] tempMap = map;


            cordsForBombs[clickedPoint.row * columns + clickedPoint.col] = new Point(-1, -1);
            foreach (Point offsetPoint in offset)
            {
                Point tempPoint = clickedPoint.Add_Point(offsetPoint);
                if (tempPoint.Inside_Boundries(rows, columns))
                {
                    cordsForBombs[tempPoint.row * columns + tempPoint.col] = new Point(-1, -1);
                }
            }

            cordsForBombs.RemoveAll(check);

            bombCords = Bomb_Cords_Generator(cordsForBombs);
            foreach (Point pkt in bombCords)
            {
                mapToChange[pkt.row, pkt.col].bomb = true;
                foreach (Point offsetPoint in offset)
                {
                    Point toAddBomb = pkt.Add_Point(offsetPoint);
                    if (toAddBomb.Inside_Boundries(rows, columns))
                    {
                        mapToChange[toAddBomb.row, toAddBomb.col].nBombs += 1;
                    }
                }
            }
            return(mapToChange);
        }
Пример #18
0
 public static Field[,] GetView(Field[,] field, Angle Angle)
 {
     Field[,] newField = new Field[11, 11];
     for (int y = 0; y < 11; y++)
     {
         for (int x = 0; x < 11; x++)
         {
             if (Angle == Angle.Up)
             {
                 newField[x, y] = field[x, y];
             }
             else if (Angle == Angle.Down)
             {
                 newField[x, y] = field[10 - x, 10 - y];
             }
             else if (Angle == Angle.Right)
             {
                 newField[x, y] = field[10 - y, x];
             }
             else if (Angle == Angle.Left)
             {
                 newField[x, y] = field[y, 10 - x];
             }
         }
     }
     return(newField);
 }
        private Tuple <int, int> GetFirstFieldCordinatesWithLiveShipPart(Field[,] fields)
        {
            Field            firstFieldWithLiveShipPart = null;
            Tuple <int, int> cordinates = null;

            for (int i = 0; i < _gameBoard.BoardSize; i++)
            {
                for (int j = 0; j < _gameBoard.BoardSize; j++)
                {
                    var field = fields[i, j];
                    if (field.FieldType == FieldType.LiveShipPart)
                    {
                        firstFieldWithLiveShipPart = field;
                        cordinates = new Tuple <int, int>(i, j);
                        break;
                    }
                }
            }

            if (firstFieldWithLiveShipPart == null)
            {
                throw new Exception("Could not find live ship part field!");
            }

            return(cordinates);
        }
Пример #20
0
 public Map(int width = 10, int height = 21)
 {
     Width  = width;
     Height = height;
     array  = new Field[width, height];
     Clear();
 }
        private Tuple <int, int> GetFirstFreeFieldInBoardPlayerBoard(Field[,] fields)
        {
            Field            firstFreeField = null;
            Tuple <int, int> cordinates     = null;

            for (int i = 0; i < _gameBoard.BoardSize; i++)
            {
                for (int j = 0; j < _gameBoard.BoardSize; j++)
                {
                    var field = fields[i, j];
                    if (field.FieldType == FieldType.Free)
                    {
                        firstFreeField = field;
                        cordinates     = new Tuple <int, int>(i, j);
                        break;
                    }
                }
            }

            if (firstFreeField == null)
            {
                throw new Exception("Could not find free field!");
            }

            return(cordinates);
        }
Пример #22
0
        public FactoryAnthill(Field[,] map, int widthWorld, int heightWorld, AntQueen queen)
        {
            _queen = queen;
            FactoryAntQueen   factoryQueen      = new FactoryAntQueen();
            FactoryAntPicker  factoryAntPicker  = new FactoryAntPicker();
            FactoryFood       factoryFood       = new FactoryFood();
            FactoryAntFighter factoryAntFighter = new FactoryAntFighter();

            _heightWorld = heightWorld;
            _widthWorld  = widthWorld;
            _map         = map;
            _stackObjet  = new Stack();
            _stackAnt    = new Stack();
            _stackAnt.Push(queen ?? factoryQueen.CreateCharacter());
            for (var i = 0; i < 5; i++)
            {
                _stackAnt.Push(factoryAntFighter.CreateCharacter());
            }
            for (var i = 0; i < 20; i++)
            {
                _stackAnt.Push(factoryAntPicker.CreateCharacter());
            }
            for (var i = 0; i < 450; i++)
            {
                _stackObjet.Push(factoryFood.CreateObject());
            }
        }
Пример #23
0
    public void Init(FieldMapData data)
    {
        Clear();

        horizontalFields = fieldsFactory.Create(data.HorizontalFields, Field.TypeEnum.Horizontal);
        verticalFields   = fieldsFactory.Create(data.VerticalFields, Field.TypeEnum.Vertical);
    }
Пример #24
0
        private void ResetButton_Click(object sender, EventArgs e)
        {
            Stop = true;
            t1.Abort();
            StartStopButton.Text = "Start";
            Snakes.Clear();
            Generation = 0;
            StopPoint  = 0;
            for (int i = 0; i < 100; i++)
            {
                Snakes.Add(new Snake(rand));
            }
            PlayingField = new Field[NextField.X, NextField.Y];
            NewField();
            GenerationLabel.Text = Convert.ToString(Generation);
            int k = 0;

            for (int i = 0; i < Snakes.Count; i++)
            {
                if (Snakes[i].IsAlive)
                {
                    k++;
                }
            }
            AllSnakesLabel.Text    = Convert.ToString(k);
            CounterSnakeLabel.Text = Convert.ToString(StopPoint);
            DrawField();
        }
Пример #25
0
        public override string ToString()
        {
            // Save the original puzzle to string
            // Json start
            string puzzle = "[\n";

            for (int y = 0; y < this.Height; y++)
            {
                // Add the outer array beginning
                puzzle += "[";
                for (int x = 0; x < this.Width; x++)
                {
                    // Add the inner array
                    puzzle += this.puzzle[x, y].ToString();
                    if (x != this.Width - 1)
                    {
                        puzzle += ",";
                    }
                }
                // Add the outer array ending
                puzzle += "]";
                if (y != this.Height - 1)
                {
                    puzzle += ",";
                }
                puzzle += "\n";
            }
            // Json end
            puzzle += "]";
            return(puzzle);
        }
Пример #26
0
        private bool IsInLineExistOtherShip(Field[,] board, int shipLength, int column, int row, Direction direction)
        {
            for (int j = 0; j < shipLength; j++)
            {
                Field specificBoardField = null;

                switch (direction)
                {
                case Direction.Up:
                    specificBoardField = board[row - j, column];
                    break;

                case Direction.Down:
                    specificBoardField = board[row + j, column];
                    break;

                case Direction.Left:
                    specificBoardField = board[row, column - j];
                    break;

                case Direction.Right:
                    specificBoardField = board[row, column + j];
                    break;
                }

                if (specificBoardField.FieldType == FieldType.LiveShipPart)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Board" /> class.
        /// </summary>
        /// <param name="rows">Number of rows on the board.</param>
        /// <param name="columns">Number of columns on the board.</param>
        /// <param name="minesCount">Number of mines on the board.</param>
        public Board(int rows, int columns, int minesCount)
        {
            if (rows < 1)
            {
                throw new ArgumentOutOfRangeException("rows", rows, "Rows cannot not be less then one !!!");
            }

            if (columns < 1)
            {
                throw new ArgumentOutOfRangeException("columns", columns, "Columns cannot not be less then one !!!");
            }

            if (minesCount < 1 || rows * columns < minesCount)
            {
                throw new ArgumentOutOfRangeException(
                    "minesCount",
                    minesCount,
                    string.Format("The minesCount must be between 1 and {0}!!!", rows * columns));
            }

            this.rows = rows;
            this.columns = columns;
            this.minesCount = minesCount;
            this.fields = new Field[rows, columns];

            for (int row = 0; row < this.rows; row++)
            {
                for (int column = 0; column < this.columns; column++)
                {
                    this.fields[row, column] = new Field();
                }
            }

            this.SetMines();
        }
Пример #28
0
 public Board()
 {
     board = new Field[15, 15];
     for (int i = 0; i < 15; i++)
     {
         for (int j = 0; j < 15; j++)
         {
             if (tripleWord.Contains(i * 15 + j))
             {
                 board[i, j] = new Field(Field.Types.TripleWord, i, j);
             }
             else if (doubleWord.Contains(i * 15 + j))
             {
                 board[i, j] = new Field(Field.Types.DoubleWord, i, j);
             }
             else if (tripleLetter.Contains(i * 15 + j))
             {
                 board[i, j] = new Field(Field.Types.TripleLetter, i, j);
             }
             else if (doubleLetter.Contains(i * 15 + j))
             {
                 board[i, j] = new Field(Field.Types.DoubleLetter, i, j);
             }
             else
             {
                 board[i, j] = new Field(Field.Types.Normal, i, j);
             }
         }
     }
 }
Пример #29
0
 public Board()
 {
     board = new Field[15,15];
     for (int i=0; i <15; i++)
     {
         for (int j = 0; j < 15; j++)
         {
             if (tripleWord.Contains(i * 15 + j))
             {
                 board[i, j] = new Field(Field.Types.TripleWord, i, j);
             }
             else if (doubleWord.Contains(i * 15 + j))
             {
                 board[i, j] = new Field(Field.Types.DoubleWord, i, j);
             }
             else if (tripleLetter.Contains(i * 15 + j))
             {
                 board[i, j] = new Field(Field.Types.TripleLetter, i, j);
             }
             else if (doubleLetter.Contains(i * 15 + j))
             {
                 board[i, j] = new Field(Field.Types.DoubleLetter, i, j);
             }
             else
             {
                 board[i, j] = new Field(Field.Types.Normal, i, j);
             }
         }
     }
 }
Пример #30
0
    // Initiate level
    private void Awake()
    {
        levelManagerInstance = this;

        Time.timeScale   = 1;
        hasGameEnded     = false;
        deadEnemiesCount = 0;

        LoadSaveData();

        playerBasePosition.x = n / 2;
        playerBasePosition.y = m / 2;

        fields = new Field[n, m];

        InitFields();
        GenerateFloor();
        ChooseEnemySpawnPoints();
        GenerateBase();
        InitPlayer();

        pathFinder = new Pathfinder(fields, n, m);

        GenerateObsticles();
        GenerateBorderWall();
    }
Пример #31
0
        public void printLevel(Player player, Field[,] _fieldArray, Field[,] _fieldArrayTop)
        {
            Console.Clear();
            printBanner();
            for (int y = 0; y < _fieldArray.GetLength(0); y++)
            {
                for (int x = 0; x < _fieldArray.GetLength(1); x++)
                {
                    if (_fieldArrayTop[y, x].icon == ".")
                    {
                        Console.Write(_fieldArray[y, x].icon);
                    }
                    //if chest is NOT ontop of destination OR is destination OR is player use fieldArrayTop
                    else if (_fieldArrayTop[y, x].icon == "0" || _fieldArrayTop[y, x].icon == "@" || _fieldArrayTop[y, x].icon == "o" && _fieldArray[y, x].icon != "0")
                    {
                        Console.Write(_fieldArrayTop[y, x].icon);
                    }
                    else
                    {
                        Console.Write(_fieldArray[y, x].icon);
                    }
                }
                Console.WriteLine();
            }

            //debug purpose
            for (int y = 0; y < _fieldArrayTop.GetLength(0); y++)
            {
                for (int x = 0; x < _fieldArrayTop.GetLength(1); x++)
                {
                    Console.Write(_fieldArrayTop[y, x].icon);
                }
                Console.WriteLine();
            }
        }
Пример #32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Board" /> class.
        /// </summary>
        /// <param name="rows">Number of rows on the board.</param>
        /// <param name="columns">Number of columns on the board.</param>
        /// <param name="minesCount">Number of mines on the board.</param>
        public Board(int rows, int columns, int minesCount)
        {
            if (rows < 1)
            {
                throw new ArgumentOutOfRangeException("rows", rows, "Rows cannot not be less then one !!!");
            }

            if (columns < 1)
            {
                throw new ArgumentOutOfRangeException("columns", columns, "Columns cannot not be less then one !!!");
            }

            if (minesCount < 1 || rows * columns < minesCount)
            {
                throw new ArgumentOutOfRangeException(
                          "minesCount",
                          minesCount,
                          string.Format("The minesCount must be between 1 and {0}!!!", rows * columns));
            }

            this.rows       = rows;
            this.columns    = columns;
            this.minesCount = minesCount;
            this.fields     = new Field[rows, columns];

            for (int row = 0; row < this.rows; row++)
            {
                for (int column = 0; column < this.columns; column++)
                {
                    this.fields[row, column] = new Field();
                }
            }

            this.SetMines();
        }
Пример #33
0
        private static List <Item>[] GetAllDiagonals(Field[,] fields)
        {
            var list = new List <List <Item> >();

            for (int i = 0; i < ReversiBoard.BoardSize; i++)
            {
                var items = new List <Item>();
                int x = i, y = 0;
                var max = ReversiBoard.BoardSize - i;
                for (int j = 0; j < max; j++)
                {
                    items.Add(new Item(x, y, fields[x, y]));
                    x++;
                    y++;
                }

                list.Add(items);
                items = new List <Item>();
                x     = 0;
                y     = i;
                max   = i + 1;
                for (int j = 0; j < max; j++)
                {
                    items.Add(new Item(x, y, fields[x, y]));
                    x++;
                    y--;
                }

                list.Add(items);
            }

            return(list.ToArray());
        }
Пример #34
0
        public Board(string[] b,int score)
        {
            maxScore = score;
            board = new Field[b.Count(), b[0].Count()];
            for (int i = 0; i < board.GetLength(0); i++)
                for (int j = 0; j < board.GetLength(1); j++)
                    switch (b[i][j])
                    {
                        case '.':
                            board[i, j] = Field.HAY;
                            break;
                        case '#':
                            board[i, j] = Field.WALL;
                            break;
                        case '@':
                            board[i, j] = Field.EMPTY;
                            break;
                        case '&':
                            board[i, j] = Field.DIAMOND;
                            break;
                        case 'Q':
                            board[i, j] = Field.ROCK;
                            break;
                        case 'E':
                            board[i, j] = Field.EXIT;
                            break;
                    }

            FallingBlocks = new List<Pair>();
            DeadlyBlocks = new List<Pair>();
        }
Пример #35
0
 public UpdatePack(List <Player> playerList, Field[,] playingField, List <Field> trapList)
 {
     this.PlayerList   = playerList;
     this.PlayingField = playingField;
     this.TrapList     = trapList;
     this.hash         = this.GetHashCode();
 }
Пример #36
0
        public Game(DataGame data)
        {
            InitializeNulls();
            // Make new game with config
            settings = data;

            board = new Field[2 * settings.GoalLen + settings.TaskLen, settings.BoardWidth];
            for (int y = 0; y < 2 * settings.GoalLen + settings.TaskLen; y++)
            {
                for (int x = 0; x < settings.BoardWidth; x++)
                {
                    board[y, x] = new Field();
                }
            }
            playersDictionary = new Dictionary <int, Player>(2 * settings.PlayersPerTeam);
            redTeam           = new List <int>(settings.PlayersPerTeam); // used for broadcast ip reference, fast lookup without plDict iterating
            blueTeam          = new List <int>(settings.PlayersPerTeam);
            gameName          = settings.Name;


            // Only when board is ready and set up with fields, start adding players
            Piece piece1 = new Piece();

            piece1.pos_x = 0;
            piece1.pos_y = 4;



            Console.WriteLine("Rows:{0}, Cols:{1}", board.GetLength(0), board.GetLength(1));
        }
Пример #37
0
 /// <summary>
 /// Creates map with empty fields
 /// </summary>
 /// <param name="mapDimension">edge length of map</param>
 public Map(int mapDimension)
 {
     fields = new Field[mapDimension, mapDimension];
     for (int i = 0; i < fields.GetLength(0); i++)
         for (int j = 0; j < fields.GetLength(1); j++)
             fields[i, j] = new Field();
     dimension = mapDimension;
 }
Пример #38
0
 public Minefield(Difficulty difficulty, Vector2 displayPos)
 {
     this.sizeX = difficulty.sizeX;
     this.sizeY = difficulty.sizeY;
     this.mines = difficulty.mines;
     this.displayPos = displayPos;
     this.map = new Field[sizeX, sizeY];
     rnd = new Random();
     this.generate();
 }
Пример #39
0
        public Map(int rowsNumber, int colsNumber, 
            string mapPath, Dictionary<Marker, int> imc)
        {
            map = new Field[rowsNumber, colsNumber];
            this.RowsNumber = rowsNumber;
            this.ColsNumber = colsNumber;

            initialMarkersCount = imc;

            LoadMap(mapPath);
        }
Пример #40
0
 void CreateWalkingGrid()
 {
     grid = new Field[width,height];
     for (int x = 0; x < width; x++) {
         for (int y = 0; y < height; y++) {
             Vector3 position = new Vector3(x, 1.5f, y);
             bool isWalkable = !(Physics.CheckSphere(position,0.49F, 1 << unwalkableMask.value));//
             grid[x,y] = new Field(isWalkable, position);
         }
     }
 }
Пример #41
0
 public Field(int mineFieldCoordsX, int minefieldCoordsY, Vector2 displayPos, ref Field[,] map)
 {
     this.pos = displayPos;
     this.mineFieldCoordsX = mineFieldCoordsX;
     this.mineFieldCoordsY = minefieldCoordsY;
     this.fsFieldState = FieldState.unrevealed;
     this.map = map;
     this.texture = manager.contentManager.fieldTexUnrevealed;
     this.font = manager.contentManager.fntMinesNerby;
     this.rect = new Rectangle((int)pos.X, (int)pos.Y, 16, 16);
 }
Пример #42
0
        public PlayBoard(System.Windows.Forms.GroupBox container)
        {
            fields = new Field[10,10];

              for (int j = 0; j < 10; j++)
              {
            for (int i = 0; i < 10; i++)
            {
              fields[i, j] = new Field(i, j, container);
            }
              }
        }
Пример #43
0
        public Board(int w, int h, int dificulty)
        {
            this.width = w;
            this.height = h;
            this.fields = new Field[w, h];
            this.allFields = w * h;
            // obtížnost - čím vetší čislo proměnné dificulty, tím méně bomb na desce
            this.mineFields = allFields / dificulty;
            this.clearFields = allFields - mineFields;

            FillFields();
            SetMines();
            SetMinesAround();
        }
Пример #44
0
		public Map(char[,] mapString)
		{
			fields = new Field[mapString.GetLength(0), mapString.GetLength(1)];
			for (int i = 0; i < mapString.GetLength(0); ++i)
			{
				for (int j = 0; j < mapString.GetLength(1); ++j)
				{
					switch (mapString[i, j])
					{
						case '.':
							fields[i, j] = new Floor(j,i);
							break;
						case '#':
							fields[i, j] = new Wall(j, i);
							break;
					}
				}
			}
		}
Пример #45
0
        public RenderManager()
        {
            this.currentScreenState = ScreenState.BEGINSCREEN;

            RenderManager.instance = this;
            this.textureList = new TextureList();
            this.textureList.load();

            this.fieldArr = this.getField();

            this.renderWidth = this.fieldArr.GetLength(0) * fieldSize;
            this.renderHeight = this.fieldArr.GetLength(1) * fieldSize;

            this.tick();

            this.initSound();
            this.startBGMusic();

            done = false;
        }
Пример #46
0
 public void Clear()
 {
     balls = new List<Ball> ();
     monsters = new List<Monster> ();
     fields = new Field[Width, Height];
     for (int i = 0; i < Width; i++) {
         for (int j = 0; j < Height; j++) {
             fields [i, j] = new Field ();
             if (i == 0 || j == 0 || i + 1 == Width || j + 1 == Height) {
                 fields [i, j].Full = true;
             } else {
                 fields [i, j].Full = false;
             }
             fields [i, j].X = i;
             fields [i, j].Y = j;
         }
     }
     Player = new Player (0, 0);
     Player.BaseField = fields [0, 0];
     renderer.RefreshBackground (fields);
 }
Пример #47
0
	void initializeField() {
		field = new Field[numH, numV];

		// fill interior:
		for (int h = 0; h < numH; h++) {
			for (int v = 0; v < numV; v++) {
				field [h, v].h = h;
				field [h, v].v = v;
				if (h != 0 && h != numH - 1 && v != 0 && v != numV - 1) {
					notWay.Add(field [h, v]);
					SpawnWall ('D', h, v);
					SpawnWall ('L', h, v);
					SpawnWall ('U', h, v);
					SpawnWall ('R', h, v);
				} else  {
					lisWay.Add(field [h, v]);
					field [h, v].isWay = true; // border is way
				}

			}
		}
	}
Пример #48
0
 public void tick()
 {
     this.fieldArr = this.getField();
     this.playerMovementSpeed = GameManager.getInstance().getPlayer().getMovementSpeed();
 }
Пример #49
0
        public GameMatrix(int row, int col,bool includeWalls)
        {
            this.Rows = row;
            this.Colums = col;
            this.includeBorderWalls = includeWalls;
            matrix = new Field[Rows, Colums];

            this.SetCentreCordinates();
            this.FillWithEmptyFields();
            if (this.includeBorderWalls)
            {
                this.CreateBorderWalls();
            }
            this.GenerateFoodField();
        }
Пример #50
0
 //フィールドのクリア
 public void clearField()
 {
     field = new Field[fieldSize.Width, fieldSize.Height];
     for (int x = 0; x < fieldSize.Width; x++)
     {
         for (int y = 0; y < fieldSize.Height; y++)
         {
             field[x, y] = new Field();
         }
     }
     initiation = new bool[2] { true, true };
 }
Пример #51
0
        //初期化処理群
        void myConstractor(int cardNum, int handCardNum, Size fieldSize, Size cardSize, string[] deckIndexes = null)
        {
            this.fieldSize = fieldSize;
            this.cardSize = cardSize;
            this.cardNum = cardNum;
            this.handCardNum = handCardNum;
            messageList = new List<string>();
            //フィールド初期化
            field = new Field[fieldSize.Width, fieldSize.Height];
            for (int x = 0; x < fieldSize.Width; x++)
            {
                for (int y = 0; y < fieldSize.Height; y++)
                {
                    field[x, y] = new Field();
                }
            }
            //カード初期化
            deck = new List<Card>[max_Player];
            handCard = new List<Card>[max_Player];
            //山札を作成
            if (deckIndexes == null) deckIndexes = new string[max_Player];
            foreach (var deckIndex in deckIndexes.Select((v, i) => new { v, i }))
            {
                if (deckIndex.v == "" || deckIndex.v == null)
                {
                    deck[deckIndex.i] = Enumerable.Range(0, cardNum).Select(t => Card.RandomCardGenerator()).ToList();
                }
                else
                {
                    deck[deckIndex.i] = new List<Card>(Card.deckList[deckIndex.v].Select(t => new Card(((int[])t.elems.ToArray().Clone()).ToList(), t.imgPath)));
                }

                //山札をシャッフル
                Card.suffleCards(ref deck[deckIndex.i]);
            }
            initiation = new bool[max_Player];
            for(int i = 0; i < max_Player; i++)
            {
                //手札を作成
                handCard[i] = new List<Card>();
                //イニシエーション
                initiation[i] = true;
            }
            //Card.SerializeCards(card_1p);

            //ドロー
            for (int i = 0; i < handCardNum; i++)
            {
                for (int j = 0; j < max_Player; j++)
                {
                    draw();
                    next();
                }
            }
        }
Пример #52
0
        /// <summary>
        /// Calculates the proportions and positions of all fields by taking the current scale rate of this playground
        /// </summary>
        private void CalculateFields()
        {
            bool firstStarted = false;
            if (fields == null)
            {
                firstStarted = true;
                fields = new Field[PLAYGROUND_SIZE, PLAYGROUND_SIZE];
            }

            for (int r = 0; r < PLAYGROUND_SIZE; r++)
            {
                for (int c = 0; c < PLAYGROUND_SIZE; c++)
                {
                    Vector2 pos = new Vector2((float)(GridLeft + (c * FieldWidth)), (float)(GridTop + (r * FieldHeight)));
                    if (fields[r, c] == null)
                    {
                        fields[r, c] = new Field(pos, new System.Windows.Size(FieldWidth, FieldHeight), c, r);
                    }
                    else
                    {
                        fields[r, c].SetProperties(pos, new System.Windows.Size(FieldWidth, FieldHeight));
                        if (fields[r, c].ReferencedShip != null)
                        {
                            fields[r, c].ReferencedShip.UpdatePosition();
                        }
                    }

                    // This global variables will only be set at the first time the calculating is done
                    if (firstStarted)
                    {
                        if (r == 0 && c == PLAYGROUND_SIZE - 1)
                        {
                            DeviceCache.RightOfMinimap = new Vector2((float)(pos.X + FieldWidth + 20), pos.Y);
                        }
                        else if (r == PLAYGROUND_SIZE - 1 && c == 0)
                        {
                            if (this.PlaygroundMode == Logic.Enum.PlaygroundMode.Normal)
                            {
                                DeviceCache.BelowGrid = Convert.ToInt32(pos.Y + FieldHeight + 20);
                            }
                            else
                            {
                                DeviceCache.BelowSmallGrid = Convert.ToInt32(pos.Y + FieldHeight + 20);
                            }
                        }
                    }
                }
            }
        }
Пример #53
0
 public Map()
 {
     this.m_fields = new Field[50, 50];
 }
Пример #54
0
        private void LoadLevel(int id)
        {
            // if id > amount of levels, go to fist lvl
            id %= _lvlTmp.Length;

            // X and Y swapped and turned 90°
            var sizeX = _lvlTmp[id].GetLength(1);
            var sizeY = _lvlTmp[id].GetLength(0);

            _levelFeld = new Field[sizeX, sizeY];
            FieldCount = 0;

            for (var y = 0; y < sizeY; y++)
                for (var x = 0; x < sizeX; x++)
                {
                    // colh
                    // var fType = (Field.FieldTypes) _lvlTmp[id][sizeY - 1 - y, x];
                    var fType = (Field.FieldTypes)_lvlTmp[id][y, x];
                    if (fType == Field.FieldTypes.FtNull) continue;

                    _levelFeld[x, y] = new Field(this, ++FieldCount, x, y, fType);

                    // set start coordinates
                    if (fType == Field.FieldTypes.FtStart)
                    {
                        _startXy[0] = x;
                        _startXy[1] = y;
                    }
                }

            _camTranslation = float4x4.CreateTranslation((float) -(sizeX - 1)*100, (float) -(sizeY - 1)*100, 150);
            ResetLevel();
        }
Пример #55
0
 // Use this for initialization
 void Start()
 {
     board = new Field[10, 10];
             for (int x=0; x<10; x++) {
                     for (int y=0; y<10; y++) {
                             board [x, y] = Instantiate (fieldToPlace, new Vector3 (x, y, 0.1f), Quaternion.identity) as Field;
                             board [x, y].transform.parent = this.transform;
                             board [x, y].board = this;
                     }
             }
             startField = board [0, 0];
             endField = board [9, 9];
             updateRouting ();
 }