コード例 #1
0
ファイル: Table.cs プロジェクト: killbug2004/WSProf
        public Table(EMFCanvasLog emfInfo)
        {
            m_Valid = true;
            GridResolver gr = new GridResolver(emfInfo.Lines);
            gr.Execute(emfInfo.Text, emfInfo.FilledAreas);
            m_HorizBounds = gr.HorizontalBoundaries;
            m_VertBounds = gr.VerticalBoundaries;

            if (m_HorizBounds.Count <= 1 || m_VertBounds.Count <= 1)
            {
                m_Valid = false;
                return;
            }

            m_cells = new Cell[m_HorizBounds.Count - 1, m_VertBounds.Count - 1];

            FlagMergedCells(gr.MergedCells);

            ScaleCells(emfInfo.Text);

            PutTextInCells(emfInfo.Text);
                            
            SetCellsColour(emfInfo.FilledAreas);

            SetBorders(emfInfo.BorderAreas);

            EstablishJustification();
        }
コード例 #2
0
ファイル: MinerGame.cs プロジェクト: vbre/tasks_cs2
 public MinerGame(string userName, int width, int height, int countOfBombs)
 {
     this.userName = userName;
     Width = width;
     Height = height;
     this.field = CreateRandomField(height, width, countOfBombs);
 }
コード例 #3
0
ファイル: Map.cs プロジェクト: Ring-r/sandbox
 public void CreateLand(int iCount, int jCount, float gravity, float resistance)
 {
     this.cells = new Cell[iCount, jCount];
     // this.FillHeights (rand);
     this.FillGravity(gravity);
     this.FillResistance(resistance);
 }
コード例 #4
0
ファイル: Map.cs プロジェクト: jmschrack/LudumDare33
        public Map(int _Size_X, int _Size_Y)
        {
            this._Size_X = _Size_X;
            this._Size_Y = _Size_Y;

            if (_Size_X > 100 || _Size_Y > 100)
            {
                Debug.LogWarning("You are making quite a big map. Just a friendly reminder that it can take a long time:"
                                + "\n" + " size_X is " + _Size_X + " size_Y is " + _Size_Y);
            }

            if (_Size_X < 4 || size_Y < 4)
            {
                Debug.LogWarning("Values for size_X and size_Y may be too small. Just a friendly reminder of your values:"
                                + "\n" + " size_X is " + _Size_X + " size_Y is " + _Size_Y);
            }

            /* All map sizes should be odd numbered due to a maze algorithm we're using. */
            if (_Size_X % 2 != 1)
            {
                Debug.LogError("Value for size_X is even. For maze generation methods we recommend odd numbers."
                                + "\n" + "I'm gonna +1 your size for you. You may change this through code.");
                this._Size_X++;
            }
            if (_Size_Y % 2 != 1)
            {
                Debug.LogError("Value for size_Y is even. For maze generation methods we recommend odd numbers."
                                + "\n" + "I'm gonna +1 your size for you. You may change this through code.");
                this._Size_Y++;
            }

            _CellsOnMap = new Cell[this._Size_X, this._Size_Y];
            MethodLibrary.ResetCellsOnMap(this, "Abyss");
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: Elusive138/Minesweeper
        public MainForm()
        {
            InitializeComponent();

            grid = new Cell[9,9];
            Random rand = new Random();

            List<Point> potentialMineLocations = new List<Point>(grid.Length);

            for (int i = 0; i < grid.GetLength(0); i++)
            {
                for (int j = 0; j < grid.GetLength(1); j++)
                {
                    potentialMineLocations.Add(new Point(i, j));
                }
            }

            for (int i = 0; i < 10; i++)
            {
                Point x = potentialMineLocations[rand.Next(potentialMineLocations.Count)];
                grid[x.X, x.Y] = new MineCell();
            }

            for (int i = 0; i < grid.GetLength(0); i++)
            {
                for (int j = 0; j < grid.GetLength(1); j++)
                {
                    if (grid[i, j] is MineCell)
                        continue;

                    grid[i, j] = new SafeCell();
                    ((SafeCell)grid[i, j]).CellValue = GetNeighbouringCellCount(i, j);
                }
            }
        }
コード例 #6
0
ファイル: Field.cs プロジェクト: Sckorn/battleships
    public Field(string fieldName, int player)
    {
        CustomError ce = new CustomError("Field", "constructor");
        this.cells = new Cell[this.byX, this.byY];

        for (int i = 0; i < this.byX; i++)
        {
            for (int j = 0; j < this.byY; j++)
            {
                this.cells[i, j] = new Cell(i, j);
            }
        }

        Morpher mphr = GameObject.Find("Morpher").GetComponent<Morpher>();
        mphr.InstAField(fieldName, ref this.realObjectReference);
        if (player == 1)
        {
            this.crossHair = mphr.InstACross().GetComponent<GUITexture>();
            this.allocatingShips = true;
        }
        else
        {
            this.allocatingShips = false;
        }

        EventManager.OnResize += this.ResizeAfterCreate;
    }
コード例 #7
0
 public Field(int rows, int cols, int mines)
 {
     this.field = InitializeGrid(rows, cols);
     this.mines = mines;
     this.rows = rows;
     this.columns = cols;
 }
コード例 #8
0
        /// <summary>
        /// Initialises a new instance of a Generation.
        /// </summary>
        /// <param name="universeSize">Size of the universe.</param>
        public Generation(int universeSize)
        {
            universe = new Cell[universeSize, universeSize];
            UniverseSize = universeSize;

            Initialise();
        }
コード例 #9
0
        /* Constructors */
        public AbstractBoard()
        {
            // Initialize fields
            _boardCells = new Cell[GetBoardSize(), GetBoardSize()];

            _rowCells = new Coordinate[GetBoardSize()][];
            _columnCells = new Coordinate[GetBoardSize()][];
            _blockCells = new Coordinate[GetBoardSize()][];

            for (int i = 0; i != GetBoardSize(); i++)
            {
                _rowCells[i] = new Coordinate[GetBoardSize()];
                _columnCells[i] = new Coordinate[GetBoardSize()];
                _blockCells[i] = new Coordinate[GetBoardSize()];
            }

            for (int i = 0; i != GetBoardSize(); i++)
            {
                for (int j = 0; j != GetBoardSize(); j++)
                {
                    // Instantiate cell
                    _boardCells[i, j] = new Cell();

                    // Add references to cell
                    Coordinate cell = new Coordinate(i, j);
                    _rowCells[i][j] = cell;
                    _columnCells[j][i] = cell;
                    _blockCells[GetBlockPosition(i, j)][GetCellPosition(i, j)] = cell;
                }
            }

            Console.WriteLine("Board created");
        }
コード例 #10
0
ファイル: Field.cs プロジェクト: BBennett42/conwaysgameoflife
        public Field(int width, int height, int cellLength, Texture2D cell, int offset, int interval, GameOfLife main)
        {
            this.width = width;
            this.height = height;
            this.cellLength = cellLength;
            this.offset = offset;
            this.main = main;
            changedCells = new Queue<Cell>();
            pq = new PseudoQueue<Cell>();
            WidthInCells = width;
            HeightInCells = height;
            Interval = interval;
            Bounds = new Rectangle(offset, offset, width * cellLength, height * cellLength);

            CellTexture = cell;
            field = new Cell[width,height];

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    field[i, j] = new Cell(i * cellLength + offset, j * cellLength + offset, cellLength);
                }
            }
        }
コード例 #11
0
        public ParallelActor(Ball[] balls, Cell[,] grid, int start, int end, bool last)
        {
            this.balls = balls;
            gridColumns = grid.GetLength(1);
            gridRows = end - start;

            if (last)
            {
                partOfgrid = new Cell[gridRows, gridColumns];
                for (int i = start; i < end; i++)
                {
                    for (int j = 0; j < gridColumns; j++)
                    {
                        partOfgrid[i - start, j] = grid[i, j];
                    }
                }
                Work = LastWork;
            } else
            {
                Work = UsualWork;
                partOfgrid = new Cell[gridRows+1, gridColumns];
                for (int i = start; i < end+1; i++)
                {
                    for (int j = 0; j < gridColumns; j++)
                    {
                        partOfgrid[i - start, j] = grid[i, j];
                    }
                }
            }
        }
コード例 #12
0
ファイル: Grid.cs プロジェクト: hua2001/grain-growth
        public Grid(int width, int height, bool periodic)
        {
            this.Width = width;
            this.Height = height;
            this.periodic = periodic;

            // Initialize cells
            this.cells = new Cell[height, width];

            for (int i = 0; i < height; ++i)
            {
                for (int j = 0; j < width; ++j)
                {
                    this.cells[i, j] = new Cell();
                }
            }

            // Setup neighbors
            this.ResetCurrentCellPosition();

            do
            {

                this.CurrentCell.Neighbors = this.NeighborhoodOfCurrentCell;
            } while (this.Next());
        }
コード例 #13
0
ファイル: Board.cs プロジェクト: klacs/Minesweeper
        public bool GameOver; //todo

        public Board()
        {
            NumCol = 10;
            NumRow = 10;

            Cells = InitializeGame(NumRow, NumCol);
        }
コード例 #14
0
		public static void Recalculate(INavigationTarget target) {
			cellSize = target.CellSize;
			width = target.XCells;
			height = target.ZCells;
			maxHeight = target.MaxHeight;
			maxSlope = target.MaxSlope;
			worldOffset = new Vector3(-width * cellSize / 2f, 0, -height * cellSize / 2f);

			linearCost = cellSize;
			diagonalCost = (float)Math.Sqrt(2) * cellSize;

			var halfCell = new Vector3(cellSize / 2, 0, cellSize / 2);
			cells = new Cell[width, height];

			// Scan the area of the mesh from above to find the walkable parts
			int xLength = cells.GetLength(0);
			int zLength = cells.GetLength(1);
			for (int x = 0; x < xLength; x++) {
				for (int z = 0; z < zLength; z++) {
					cells[x, z] = new Cell {
						Center = worldOffset + new Vector3(x * cellSize, maxHeight, z * cellSize) + halfCell,
						X = x,
						Z = z
					};

					target.SetCellIntersections(cells[x, z]);
				}
			}
		}
コード例 #15
0
    public void GenerateBoard(int boardWidth, int boardHeight)
    {
        boardCells = new Cell[boardHeight, boardWidth];
        currentBoardValues = new byte[boardHeight, boardWidth];

        for (int i = 0; i < boardHeight; i++)
        {
            for (int j = 0; j < boardWidth; j++)
            {
                GameObject cell = null;

                if (i == 0) //cell is on the bottom row
                    cell = Instantiate(BottomBoardCell) as GameObject;
                else
                    cell = Instantiate(BoardCell) as GameObject;
                cell.transform.parent = transform;

                BoxCollider2D box = cell.GetComponent<BoxCollider2D>();
                cell.transform.localPosition = new Vector3((box.size.x + 0.22f) * cell.transform.localScale.x * j,
                                                           box.size.y * cell.transform.localScale.y * i,
                                                           0);

                Cell c = cell.GetComponent<Cell>();
                c.row = i;
                c.col = j;
                c.value = 2;
                boardCells[i, j] = c;
                currentBoardValues[i, j] = c.value;

            }
        }
    }
コード例 #16
0
ファイル: Board.cs プロジェクト: moconno/ConnectFour
        //Initial board creation
        public Board(int x, int y, int r)
        {
            length = x;

            width = y;

            connectR = r;

            board = new Cell[length, width];

            for (int i = 0; i < length; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    Cell cell = new Cell(i, j);

                    if (i == length - 1)
                    {
                        cell.isPlayable(true);
                    }

                    board[i, j] = cell;
                }
            }
        }
コード例 #17
0
ファイル: World.cs プロジェクト: calebthompson/School
        public World(int width, int height, 
            int grassBurnTime, int brushBurnTime, int treeBurnTime,
            double grassToGrassChance, double grassToBrushChance, double grassToTreeChance,
            double brushToGrassChance, double brushToBrushChance, double brushToTreeChance,
            double treeToGrassChance, double treeToBrushChance, double treeToTreeChance,
            bool synchronous)
        {
            rand = new Random();
            this.synchronous = synchronous;
            this.width = width;
            this.height = height;

            this.grassToGrassChance = grassToGrassChance;
            this.grassToBrushChance = grassToBrushChance;
            this.grassToTreeChance = grassToTreeChance;

            this.brushToGrassChance = brushToGrassChance;
            this.brushToBrushChance = brushToBrushChance;
            this.brushToTreeChance = brushToTreeChance;

            this.treeToGrassChance = treeToGrassChance;
            this.treeToBrushChance = treeToBrushChance;
            this.treeToTreeChance = treeToTreeChance;

            grid = new Cell[width, height];
            for (int x = 0; x < width; x++)
                for (int y = 0; y < height; y++)
                    grid[x, y] = new Cell(this, (Cell.CellType)rand.Next(5), grassBurnTime, brushBurnTime, treeBurnTime);
        }
コード例 #18
0
ファイル: FieldCells.cs プロジェクト: hxzpily/arkanoid_battle
        private void createGrid(int mapID)
        {
            presetID = mapID;
            //creating empty field

            cells = new Cell[rowsCount, columnsCount];
            for (int i = 0; i < rowsCount; i++)
            {
                for (int j = 0; j < columnsCount; j++)
                {
                    var cell = new Cell(i, j, BRICK_WIDTH, BRICK_HEIGHT);
                    cell.cleared += onCellCleared;
                    cells[i, j] = cell;
                }
            }

            //fill it with cells
            string[] presetData = roomLink.maps.getMapCode(mapID).Split(new[] {'|'});
            int cellI = 0;
            int cellJ = 0;
            int brickID = 0;
            for (int i = 0; i < presetData.Length; i++)
            {
                string[] cellData = presetData[i].Split(new[] {','});
                cellJ = Convert.ToInt16(cellData[0]);
                cellI = Convert.ToInt16(cellData[1]);
                brickID = Convert.ToInt16(cellData[2]);
                cells[cellI, cellJ].attachBrick(brickID);
            }
        }
コード例 #19
0
ファイル: Map.cs プロジェクト: jondbridges/ancillary
    public Map(int width, int height)
    {
        this.width = width;
        this.height = height;

        cells = new Cell[width, height];
    }
コード例 #20
0
ファイル: Field.cs プロジェクト: Sckorn/battleships
 public Field()
 {
     CustomError ce = new CustomError("Field", "constructor");
     this.cells = new Cell[this.byX, this.byY];
     GUITexture gt = new GUITexture();
     Jobster jb = GameObject.Find("jobster").GetComponent<Jobster>();
 }
コード例 #21
0
ファイル: Board.cs プロジェクト: maxchernin/Csharp-MemoryGame
 public Board(int i_Rows, int i_Columns)
 {
     r_BoardData = new Cell[i_Rows, i_Columns];
     m_Rows = i_Rows;
     m_Columns = i_Columns;
     CreateBoard(i_Rows, i_Columns);
 }
コード例 #22
0
ファイル: Maze.cs プロジェクト: simonpucher/MazeGenerator
 public Maze(int width, int height)
 {
     this.Height = height;
     this.Width = width;
     Board = new Cell[height, width];
     Initialise();
 }
コード例 #23
0
ファイル: ReadMap.cs プロジェクト: Pete107/Mir2
        private void LoadMapCellsv0(byte[] fileBytes)
        {
            int offSet = 0;
            Width = BitConverter.ToInt16(fileBytes, offSet);
            offSet += 2;
            Height = BitConverter.ToInt16(fileBytes, offSet);
            Cells = new Cell[Width, Height];

            offSet = 52;

            clippingZone = new Bitmap(Width, Height);

            LockBitmap BitLock = new LockBitmap(clippingZone);
            BitLock.LockBits();

            for (int x = 0; x < Width; x++)
                for (int y = 0; y < Height; y++)
                {
                    if (Cells[x, y] == null)
                        BitLock.SetPixel(x, y, Color.WhiteSmoke);

                    if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0)
                        BitLock.SetPixel(x, y, Color.Black);

                    offSet += 2;

                    if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0)
                        BitLock.SetPixel(x, y, Color.Black);

                    offSet += 10;
                }
            BitLock.UnlockBits();
            clippingZone.Dispose();
        }
コード例 #24
0
ファイル: RandomBoard.cs プロジェクト: jxl31/GameOfLife
        public RandomBoard()
        {
            // size of the 2d array playing board
            Size = new Point(Game1.cellnoX, Game1.cellnoY);

            lastKState = Keyboard.GetState();

            // setting it up like cell[400,200] and cellState[bool[400],bool[200]];
            cell = new Cell[Size.X, Size.Y];
            cellState = new bool[Size.X, Size.Y];

            //filling up the playing board with cell in place
            //initializing every cell state to be either true or false according to the random variable
            for (i = 0; i < Size.X; i++)
            {
                for (j = 0; j < Size.Y; j++)
                {
                    cell[i, j] = new Cell(new Point(i, j));
                    int flagbool = random.Next(2);
                    if (flagbool == 1)
                    {
                        cell[i, j].Alive = false;
                        cellState[i, j] = false;
                    }
                    else if (flagbool == 0)
                    {
                        cell[i, j].Alive = true;
                        cellState[i, j] = true;
                    }
                }
            }

            //setting clock to 0
            timer = TimeSpan.Zero;
        }
コード例 #25
0
        public World(int dimension)
        {
            // minimum dimension is 10
            if (dimension < 10)
            {
                throw new ArgumentOutOfRangeException();
            }
            else
            {
                // create an extra row on top and bottom so each cell has exactly 8 neighbors
                /* -- hypothetical 2 x 2 board is created as 4 x 4 board

                    3 5 5 3
                    5 8 8 5
                    5 8 8 5
                    3 5 5 3

                */
                this.dimension = dimension + 2;
                this._currentworld = new Cell[this.dimension, this.dimension];
                for (int i = 0; i < this.dimension; i++)
                {
                    for (int j = 0; j < this.dimension; j++)
                    {
                        this._currentworld[i, j] = new Cell();
                    }
                }
            }
        }
コード例 #26
0
ファイル: Map.cs プロジェクト: treytomes/ASCIIWorld2
		protected Map(int rows, int columns)
		{
			_cells = new Cell[rows, columns];
			Bounds = new RectI(0, 0, columns, rows);
			Rows = rows;
			Columns = columns;
		}
コード例 #27
0
ファイル: Board.cs プロジェクト: jxl31/GameOfLife
        public Board()
        {
            // size of the 2d array playing board
            Size = new Point(Game1.cellnoX, Game1.cellnoY);

            lastKState = Keyboard.GetState();

            // setting it up like cell[400,200] and cellState[bool[400],bool[200]];
            cell = new Cell[Size.X, Size.Y];
            cellState = new bool[Size.X, Size.Y];

            //filling up the playing board with cell in place
            //initializing every cell state to be false by default
            for (i = 0; i < Size.X; i++)
            {
                for (j = 0; j < Size.Y; j++)
                {
                    cell[i, j] = new Cell(new Point(i, j));
                    cellState[i, j] = false;
                }
            }

            //setting clock to 0
            timer = TimeSpan.Zero;
        }
コード例 #28
0
ファイル: Worksheet.cs プロジェクト: dyselon/cscribe
 public Worksheet(string title, uint rows, uint cols)
 {
     this.title = title;
     this.rows = rows;
     this.cols = cols;
     data = new Cell[rows,cols];
 }
コード例 #29
0
ファイル: Program.cs プロジェクト: JorgeAndd/Flooding
        // PLACEHOLDER: Constructor with hard coded board values for test purposes
        public Board()
        {
            height = 4;
            length = 4;

            board = new Cell[height, length];

            board[0, 0] = new Cell(2,0);
            board[1, 0] = new Cell(7,0);
            board[2, 0] = new Cell(2,0);
            board[3, 0] = new Cell(4,2);

            board[0, 1] = new Cell(0,0);
            board[1, 1] = new Cell(10,0);
            board[2, 1] = new Cell(5,2);
            board[3, 1] = new Cell(1,3);

            board[0, 2] = new Cell(2,2);
            board[1, 2] = new Cell(6,0);
            board[2, 2] = new Cell(3,5);
            board[3, 2] = new Cell(5,3);

            board[0, 3] = new Cell(1,3);
            board[1, 3] = new Cell(7,8);
            board[2, 3] = new Cell(6,2);
            board[3, 3] = new Cell(4,3);
        }
コード例 #30
0
ファイル: World.cs プロジェクト: calebthompson/School
        public World(int width, int height, Rule rule)
        {
            int[,] seedRule = { {0,2,2,2,2,2,2,2,2,0,0,0,0,0,0},
                                {2,1,7,0,1,4,0,1,4,2,0,0,0,0,0},
                                {2,0,2,2,2,2,2,2,0,2,0,0,0,0,0},
                                {2,7,2,0,0,0,0,2,1,2,0,0,0,0,0},
                                {2,1,2,0,0,0,0,2,1,2,0,0,0,0,0},
                                {2,0,2,0,0,0,0,2,1,2,0,0,0,0,0},
                                {2,7,2,0,0,0,0,2,1,2,0,0,0,0,0},
                                {2,1,2,2,2,2,2,2,1,2,2,2,2,2,0},
                                {2,0,7,1,0,7,1,0,7,1,1,1,1,1,2},
                                {0,2,2,2,2,2,2,2,2,2,2,2,2,2,0} };
            this.height = height;
            this.width = width;
            grid = new Cell[width, height];

            //initialize cells
            for (int x = 0; x < width; x++)
                for (int y = 0; y < height; y++)
                    grid[x, y] = new Cell(this, Cell.CellState.Nothing, rule);

            // create initial loop
            int startX = width/2 - 7;
            int startY = height/2 - 5;
            for (int x = 0; x < 10; x++)
                for (int y = 0; y < 15; y++)
                {
                    grid[startX + x, startY + y].State = (Cell.CellState)seedRule[y, x];
                    Console.WriteLine('[' + x + ',' + y + ']');
                }
        }
コード例 #31
0
ファイル: Rules.cs プロジェクト: dovh/openu
 public override bool Criteria(Cell[,] N)
 {
     // detect previous state
     return(N[1, 1].State == Cell.state.Move);
 }
コード例 #32
0
ファイル: Rules.cs プロジェクト: dovh/openu
        public override void Output(Cell[,] N, ref Cell cell)
        {
            Cell center = N[1, 1];

            // Check if still I want some one who does not want me.
            //   that is, In stage select2 I did not found some one around me who likes me.

            bool mismatch = false;

            if (center.Direction == Cell.direction.UpLeft && N[0, 0].Direction != Cell.direction.DownRight)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.Up && N[1, 0].Direction != Cell.direction.Down)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.UpRight && N[2, 0].Direction != Cell.direction.DownLeft)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.Left && N[0, 1].Direction != Cell.direction.Right)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.Right && N[2, 1].Direction != Cell.direction.Left)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.DownLeft && N[0, 2].Direction != Cell.direction.UpRight)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.Down && N[1, 2].Direction != Cell.direction.Up)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.DownRight && N[2, 2].Direction != Cell.direction.UpLeft)
            {
                mismatch = true;
            }

            if (mismatch || center.Direction == Cell.direction.None)
            {
                //  in this case, keep on moving
                //    radomly select an empty cell to move to (avoid borders).

                HashSet <int> keys = new HashSet <int>();

                while (keys.Count != Cell.neighbors.Length)
                {
                    // get random neighbor
                    int key = (int)(CA.NextRandom * Cell.neighbors.Length);
                    keys.Add(key);

                    // if neigbor is epmty and not a border, set direction to it.
                    Cell.neighbor Ni = Cell.neighbors[key];
                    if (N[Ni.x, Ni.y].IsEmpty() && !N[Ni.x, Ni.y].IsBorder())
                    {
                        cell.Direction = Ni.dir;
                        break;
                    }
                }
                ;
            }
        }
コード例 #33
0
        public static void Save(Cell[,] cells)
        {
            // Verify the directory exists
            if (!Directory.Exists(EXPORT_DIRECTORY))
            {
                Directory.CreateDirectory(EXPORT_DIRECTORY);
            }

            // Save a CSV file for f, g, and h
            using (StreamWriter file = new StreamWriter(EXPORT_DIRECTORY + @"\f.csv"))
            {
                for (int rowIndex = 0; rowIndex < cells.GetLength(0); rowIndex++)
                {
                    for (int columnIndex = 0; columnIndex < cells.GetLength(1); columnIndex++)
                    {
                        file.Write(cells[rowIndex, columnIndex].GetFScore());

                        if (columnIndex == cells.GetLength(1) - 1)
                        {
                            file.WriteLine();
                        }
                        else
                        {
                            file.Write(",");
                        }
                    }
                }
            }

            using (StreamWriter file = new StreamWriter(EXPORT_DIRECTORY + @"\g.csv"))
            {
                for (int rowIndex = 0; rowIndex < cells.GetLength(0); rowIndex++)
                {
                    for (int columnIndex = 0; columnIndex < cells.GetLength(1); columnIndex++)
                    {
                        file.Write(cells[rowIndex, columnIndex].GetGScore());

                        if (columnIndex == cells.GetLength(1) - 1)
                        {
                            file.WriteLine();
                        }
                        else
                        {
                            file.Write(",");
                        }
                    }
                }
            }

            using (StreamWriter file = new StreamWriter(EXPORT_DIRECTORY + @"\h.csv"))
            {
                for (int rowIndex = 0; rowIndex < cells.GetLength(0); rowIndex++)
                {
                    for (int columnIndex = 0; columnIndex < cells.GetLength(1); columnIndex++)
                    {
                        file.Write(cells[rowIndex, columnIndex].GetHScore());

                        if (columnIndex == cells.GetLength(1) - 1)
                        {
                            file.WriteLine();
                        }
                        else
                        {
                            file.Write(",");
                        }
                    }
                }
            }
        }
コード例 #34
0
 // For tests only
 public PlayWindow()
 {
     matrix = b.getBoard();
     InitializeComponent();
     setupBoard();
 }
コード例 #35
0
 public void ChangeBoard(Cell[,] board)//changes the board to solved
 {
     this.board = board;
 }
コード例 #36
0
 public Block(Cell[,] board)
 {
     this.board = board;
 }
コード例 #37
0
 public Row(Cell[,] board)
 {
     this.board = board;
 }
コード例 #38
0
    public List <Vector2Int> FindPathToTarget(Vector2Int startPos, Vector2Int endPos, Cell[,] grid)
    {
        Node startNode = new Node(startPos, null, 0, CalculateH(startPos, endPos));

        openNodes   = new List <Node>();
        closedNodes = new List <Node>();

        openNodes.Add(startNode);

        while (openNodes.Count > 0)
        {
            Node currentNode = null;
            foreach (Node node in openNodes)
            {
                if (currentNode == null || node.FScore < currentNode.FScore)
                {
                    currentNode = node;
                    if (currentNode.position == endPos)
                    {
                        List <Vector2Int> pathNodes = new List <Vector2Int>();
                        List <Vector2Int> path      = new List <Vector2Int>();
                        pathNodes.Add(currentNode.position);
                        while (currentNode.parent != null)
                        {
                            currentNode = currentNode.parent;
                            pathNodes.Add(currentNode.position);
                        }

                        for (int i = pathNodes.Count - 1; i >= 0; i--)
                        {
                            path.Add(pathNodes[i]);
                        }

                        return(path);
                    }
                }
            }

            openNodes.Remove(currentNode);
            List <Vector2Int> neighbours = CheckNeighbours(currentNode, grid);

            foreach (Vector2Int neighbour in neighbours)
            {
                Node neighbourNode = new Node(neighbour, currentNode, CalculateG(currentNode, startPos, neighbour), CalculateH(neighbour, endPos));

                if (!openNodes.Contains(neighbourNode))
                {
                    openNodes.Add(neighbourNode);
                }
            }
        }

        return(null);
    }
コード例 #39
0
 public MinesweeperGrid(int gridSizeParam, int minesCountParam, Cell[,] cellGridParam)
 {
     _gridSize   = gridSizeParam;
     _minesCount = minesCountParam;
     CellGrid    = cellGridParam;
 }
コード例 #40
0
    public void Initialize()
    {
        TextAsset textAsset = Resources.Load <TextAsset>("test");

        Grid = ParseMap(textAsset.text);
    }
コード例 #41
0
ファイル: AStar.cs プロジェクト: maxhubminer/code-samples
 public AStar(Cell[,] grid, Cell start, Cell target)
 {
     this.grid   = grid;
     this.start  = start;
     this.target = target;
 }
コード例 #42
0
    // Run one simulation step
    public void Simulate(ref Cell[,] cells)
    {
        float flow = 0;

        // Reset the diffs array
        for (int x = 0; x < cells.GetLength(0); x++)
        {
            for (int y = 0; y < cells.GetLength(1); y++)
            {
                Diffs[x, y] = 0;
            }
        }

        // Main loop
        for (int x = 0; x < cells.GetLength(0); x++)
        {
            for (int y = 0; y < cells.GetLength(1); y++)
            {
                // Get reference to Cell and reset flow
                Cell cell = cells[x, y];
                cell.ResetFlowDirections();

                // Validate cell
                if (cell.Type == CellType.Solid)
                {
                    cell.Liquid = 0;
                    continue;
                }
                if (cell.Liquid == 0)
                {
                    continue;
                }
                if (cell.Settled)
                {
                    continue;
                }
                if (cell.Liquid < MinValue)
                {
                    cell.Liquid = 0;
                    continue;
                }

                // Keep track of how much liquid this cell started off with
                float startValue     = cell.Liquid;
                float remainingValue = cell.Liquid;
                flow = 0;

                // Flow to bottom cell
                if (cell.Bottom != null && cell.Bottom.Type == CellType.Blank)
                {
                    // Determine rate of flow
                    flow = CalculateVerticalFlowValue(cell.Liquid, cell.Bottom) - cell.Bottom.Liquid;
                    if (cell.Bottom.Liquid > 0 && flow > MinFlow)
                    {
                        flow *= FlowSpeed;
                    }

                    // Constrain flow
                    flow = Mathf.Max(flow, 0);
                    if (flow > Mathf.Min(MaxFlow, cell.Liquid))
                    {
                        flow = Mathf.Min(MaxFlow, cell.Liquid);
                    }

                    // Update temp values
                    if (flow != 0)
                    {
                        remainingValue  -= flow;
                        Diffs[x, y]     -= flow;
                        Diffs[x, y + 1] += flow;
                        cell.FlowDirections[(int)FlowDirection.Bottom] = true;
                        cell.Bottom.Settled = false;
                    }
                }

                // Check to ensure we still have liquid in this cell
                if (remainingValue < MinValue)
                {
                    Diffs[x, y] -= remainingValue;
                    continue;
                }

                // Flow to left cell
                if (cell.Left != null && cell.Left.Type == CellType.Blank)
                {
                    // Calculate flow rate
                    flow = (remainingValue - cell.Left.Liquid) / 4f;
                    if (flow > MinFlow)
                    {
                        flow *= FlowSpeed;
                    }

                    // constrain flow
                    flow = Mathf.Max(flow, 0);
                    if (flow > Mathf.Min(MaxFlow, remainingValue))
                    {
                        flow = Mathf.Min(MaxFlow, remainingValue);
                    }

                    // Adjust temp values
                    if (flow != 0)
                    {
                        remainingValue  -= flow;
                        Diffs[x, y]     -= flow;
                        Diffs[x - 1, y] += flow;
                        cell.FlowDirections[(int)FlowDirection.Left] = true;
                        cell.Left.Settled = false;
                    }
                }

                // Check to ensure we still have liquid in this cell
                if (remainingValue < MinValue)
                {
                    Diffs[x, y] -= remainingValue;
                    continue;
                }

                // Flow to right cell
                if (cell.Right != null && cell.Right.Type == CellType.Blank)
                {
                    // calc flow rate
                    flow = (remainingValue - cell.Right.Liquid) / 3f;
                    if (flow > MinFlow)
                    {
                        flow *= FlowSpeed;
                    }

                    // constrain flow
                    flow = Mathf.Max(flow, 0);
                    if (flow > Mathf.Min(MaxFlow, remainingValue))
                    {
                        flow = Mathf.Min(MaxFlow, remainingValue);
                    }

                    // Adjust temp values
                    if (flow != 0)
                    {
                        remainingValue  -= flow;
                        Diffs[x, y]     -= flow;
                        Diffs[x + 1, y] += flow;
                        cell.FlowDirections[(int)FlowDirection.Right] = true;
                        cell.Right.Settled = false;
                    }
                }

                // Check to ensure we still have liquid in this cell
                if (remainingValue < MinValue)
                {
                    Diffs[x, y] -= remainingValue;
                    continue;
                }

                // Flow to Top cell
                if (cell.Top != null && cell.Top.Type == CellType.Blank)
                {
                    flow = remainingValue - CalculateVerticalFlowValue(remainingValue, cell.Top);
                    if (flow > MinFlow)
                    {
                        flow *= FlowSpeed;
                    }

                    // constrain flow
                    flow = Mathf.Max(flow, 0);
                    if (flow > Mathf.Min(MaxFlow, remainingValue))
                    {
                        flow = Mathf.Min(MaxFlow, remainingValue);
                    }

                    // Adjust values
                    if (flow != 0)
                    {
                        remainingValue  -= flow;
                        Diffs[x, y]     -= flow;
                        Diffs[x, y - 1] += flow;
                        cell.FlowDirections[(int)FlowDirection.Top] = true;
                        cell.Top.Settled = false;
                    }
                }

                // Check to ensure we still have liquid in this cell
                if (remainingValue < MinValue)
                {
                    Diffs[x, y] -= remainingValue;
                    continue;
                }

                // Check if cell is settled
                if (startValue == remainingValue)
                {
                    cell.SettleCount++;
                    if (cell.SettleCount >= 10)
                    {
                        cell.ResetFlowDirections();
                        cell.Settled = true;
                    }
                }
                else
                {
                    cell.UnsettleNeighbors();
                }
            }
        }

        // Update Cell values
        for (int x = 0; x < cells.GetLength(0); x++)
        {
            for (int y = 0; y < cells.GetLength(1); y++)
            {
                cells[x, y].Liquid += Diffs[x, y];
                if (cells[x, y].Liquid < MinValue)
                {
                    cells[x, y].Liquid  = 0;
                    cells[x, y].Settled = false;    //default empty cell to unsettled
                }
            }
        }
    }
コード例 #43
0
 public void Initialize(Cell[,] cells)
 {
     Diffs = new float[cells.GetLength(0), cells.GetLength(1)];
 }
コード例 #44
0
ファイル: Rules.cs プロジェクト: dovh/openu
 public override bool Criteria(Cell[,] N)
 {
     return(N[1, 1].State != Cell.state.Move);
 }
コード例 #45
0
 public abstract void GetPossibleMoves(Cell[,] board, Piece piece);
コード例 #46
0
ファイル: Board.cs プロジェクト: nirster/MemoryGame
 private Board(int i_Lines, int i_Cols)
 {
     r_NumOfLines  = i_Lines;
     r_NumOfCols   = i_Cols;
     r_CellsMatrix = new Cell[i_Lines, i_Cols];
 }
コード例 #47
0
 public Column(Cell[,] board)
 {
     this.board = board;
 }
コード例 #48
0
ファイル: Board.cs プロジェクト: rattanasuk/ProjectGame
 public Board()
 {
     gameBoard = new Cell[BOARD_SIZE, BOARD_SIZE];
     resetBoard();
 }
コード例 #49
0
        private Cell[,] board = new Cell[9, 9];//the board


        public SudokuBoard(Cell[,] board)//constructor
        {
            this.board = board;
        }
コード例 #50
0
        public void LoadTMX(TmxMap tmx)
        {
            Width      = tmx.Width;
            Height     = tmx.Height;
            TileWidth  = tmx.TileWidth;
            TileHeight = tmx.TileHeight;

            foreach (TmxTileset ts in tmx.Tilesets)
            {
                var tileSheet = GetTileSheet(ts.Image.Source);

                // Loop over the tilesheet and calculate rectangles indicating where
                // each Tile resides. Note that we need to account for Tiled's margin
                // and spacing settings
                var wStart = ts.Margin;
                var wInc   = ts.TileWidth + ts.Spacing;
                var wEnd   = ts.Image.Width - (ts.Image.Width % (ts.TileWidth + ts.Spacing));

                var hStart = ts.Margin;
                var hInc   = ts.TileHeight + ts.Spacing;
                var hEnd   = ts.Image.Height - (ts.Image.Height % (ts.TileHeight + ts.Spacing));

                var id = ts.FirstGid;
                for (var h = hStart; h < hEnd; h += hInc)
                {
                    for (var w = wStart; w < wEnd; w += wInc)
                    {
                        var tile = new Tile(id);
                        tile.TileSheet = tileSheet;
                        tile.Rectangle = new Rectangle(w, h, ts.TileWidth, ts.TileHeight);

                        TileTypes.Add(tile);
                        id += 1;
                    }
                }

                foreach (TmxTilesetTile tile in ts.Tiles)
                {
                    Tile.ById[ts.FirstGid + tile.Id].InitProps(tile.Properties);
                }
            }

            // Now that we know what all the tiles look like, we can
            // start splitting up the layers and packing them into cells
            Cells = new Cell[Width, Height];

            for (var i = 0; i < Width; i++)
            {
                for (var j = 0; j < Height; j++)
                {
                    Cells[i, j] = new Cell(this, i, j);
                }
            }

            foreach (TmxLayer tmxLayer in tmx.Layers)
            {
                foreach (TmxLayerTile tmxTile in tmxLayer.Tiles)
                {
                    var tileType = Tile.ById[tmxTile.Gid];
                    var cell     = Cells[tmxTile.X, tmxTile.Y];

                    if (tileType.Flags.Creature)
                    {
                        // We found a creature!
                        var cre = tileType.Flags.Player ? new Player() : new Creature();

                        // Find the creature's second animation tile by looking one row down in the tileset
                        var secondTile = Tile.ById[tmxTile.Gid + (tileType.TileSheet.Width / TileWidth)];
                        cre.Tiles = new List <Tile>()
                        {
                            tileType, secondTile
                        };

                        cre.Move(cell);
                    }
                    else if (tileType.Flags.Item)
                    {
                        // We found an item!
                        var item = new Item();
                        item.Tile = tileType;
                        cell.Items.Add(item);
                    }
                    else
                    {
                        cell.Tiles.Add(tileType);
                    }
                }
            }
        }
コード例 #51
0
 private void InitCells()
 {
     _cells = InstantiateCells(_board.fields);
 }
コード例 #52
0
ファイル: Board.cs プロジェクト: eNuoTiZ/Minesweeper
    public IEnumerator ResizeBoard(float newCellRatio, bool reset = true)
    {
        //Debug.Log("RESIZEBOARD!");
        loadingSlider.value = 0;

        initializing = true;

        int currentWidth  = Width;
        int currentHeight = Height;

        bool cellRatioChanged = CellRatio != newCellRatio;
        bool levelChanged     = Level != Options.Instance.SelectedLevel;

        CellRatio = newCellRatio;

        float startBoardPanelHeight = _boardPanel.GetComponent <RectTransform>().rect.height;
        float startBoardPanelWidth  = _boardPanel.GetComponent <RectTransform>().rect.width;
        float cellHeight            = PrefabHelper.Instance.CellPrefab.GetComponent <RectTransform>().rect.height *CellRatio;
        float cellWidth             = PrefabHelper.Instance.CellPrefab.GetComponent <RectTransform>().rect.width *CellRatio;
        //Debug.Log("Height: " + startBoardPanelHeight + " - Width: " + startBoardPanelWidth);
        //Debug.Log("Cell dimension: " + cellHeight);

        float widthOffset = 0;

        System.Diagnostics.Stopwatch sw;

        if (reset)
        {
            nbGoodFlags   = 0;
            nbFlags       = 0;
            boardExploded = false;
            gameStarted   = false;
            gameEnded     = false;
            gamePaused    = false;
            startTime     = 0;

            sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            if (currentWidth != Width || currentHeight != Height || cellRatioChanged)
            {
                DestroyAllCells(true);
            }
            else
            {
                DestroyAllCells();
            }
            sw.Stop();
            //Debug.Log("DestroyAllCells() took " + sw.Elapsed);

            Width  = (int)Mathf.Floor(startBoardPanelWidth / cellWidth);
            Height = (int)Mathf.Floor(startBoardPanelHeight / cellHeight);

            if (currentWidth != Width || currentHeight != Height || cellRatioChanged)
            {
                widthOffset = (startBoardPanelWidth - (Width * cellWidth)) / 2;

                //Debug.Log("Nb width: " + Width + " - Nb height " + Height);

                Cells = new Cell[Height, Width];
            }

            Level     = Options.Instance.SelectedLevel;
            BombCount = GetBombNumber();
        }
        //else
        //{
        //    Cell[,] tempCellArray = RotateBoardClockwise(_board.Cells);
        //    int oldWidth = Width;
        //    Width = Height;
        //    Height = oldWidth;

        //    widthOffset = (startBoardPanelHeight - (Width * cellWidth)) / 2;

        //    //DestroyAllCells();

        //    _board.Cells = new Cell[Height, Width];
        //    Array.Copy(tempCellArray, _board.Cells, tempCellArray.Length);
        //}

        //Debug.Log("Offset: " + widthOffset);

        sw = new System.Diagnostics.Stopwatch();
        sw.Start();

        int nbCells = Width * Height;

        loadingSlider.minValue = 0;
        loadingSlider.maxValue = nbCells;
        int loadingCounter = 1;

        for (int row = 0; row < Height; row++)
        {
            for (int col = 0; col < Width; col++)
            {
                if (reset)
                {
                    //System.Diagnostics.Stopwatch sw2 = new System.Diagnostics.Stopwatch();
                    //sw2.Start();

                    if (currentWidth != Width || currentHeight != Height || cellRatioChanged)
                    {
                        GameObject newCell = Instantiate(PrefabHelper.Instance.CellPrefab);
                        newCell.transform.localScale = new Vector3(CellRatio, CellRatio, CellRatio);
                        newCell.transform.position   = new Vector3((cellWidth * col) + widthOffset, -cellHeight * row, newCell.transform.position.z);
                        newCell.transform.SetParent(_boardPanel.transform, false);

                        Button button = newCell.GetComponent <Button>();

                        newCell.AddComponent(typeof(CellComponent));

                        var cell = newCell.GetComponent <CellComponent>();
                        cell.row = row;
                        cell.col = col;

                        Cells[row, col] = new Cell(newCell, Width, row, col);
                    }

                    if (firstInit && _gameData != null && !cellRatioChanged)
                    {
                        InitializeCellFromSaveGame(Cells[row, col], row, col);
                    }
                    else
                    {
                        Cells[row, col].NbBomb   = 0;
                        Cells[row, col].Content  = Cell.CONTENT.EMPTY;
                        Cells[row, col].State    = Cell.STATE.COVERED;
                        Cells[row, col].Selected = false;
                    }

                    //sw2.Stop();
                    //Debug.Log("Cell initialization took " + sw2.Elapsed);
                }
                else
                {
                    _board.Cells[row, col]._cell.transform.position = new Vector3((cellWidth * col) + widthOffset, -cellHeight * row, _board.Cells[row, col]._cell.transform.position.z);
                }

                loadingSlider.value = loadingCounter;
                loadingCounter++;
            }

            yield return(null);
        }
        sw.Stop();
        //Debug.Log("Init board " + sw.Elapsed);

        if (reset)
        {
            if (_gameData == null || cellRatioChanged || levelChanged)
            {
                sw = new System.Diagnostics.Stopwatch();
                sw.Start();

                _gameData = new GameData(Width, Height);
                InitializeBoardBombs();

                sw.Stop();
                //Debug.Log("InitializeBoardBombs() took " + sw.Elapsed);
            }

            GameObject.FindGameObjectWithTag("LoadingPanel").GetComponent <Animator>().Play("LoadingPanelClose");
            GameObject.FindGameObjectWithTag("BackgroundBlackPanel").GetComponent <Animator>().Play("BackgroundBlackPanelDisable");
        }

        initializing = false;
        firstInit    = false;

        if (gamePaused)
        {
            gamePaused = false;
        }
    }
コード例 #53
0
ファイル: TestClass.cs プロジェクト: Mihawk93/LabyrinthFights
        public void TestRamasserWeapon()
        {
            Labyrinthe maze = new Labyrinthe();

            char[,] matchar = TestInitialisation(maze, "..\\..\\theMaze.txt");
            Cell[,] cells   = maze.CharToCell(matchar);

            FightersFactory factory         = new FightersFactory();
            Fighters        fighterStore    = new Fighters(factory);
            List <Position> positionsLibres = maze.PositionLibres(cells);
            Random          rand            = new Random();
            int             index           = rand.Next(positionsLibres.Count);

            maze.SpawnCombatant(matchar, positionsLibres, index);
            Position rdmPosFighter = positionsLibres[index];
            Fighter  fighter       = fighterStore.AskForAFighter(rdmPosFighter);

            positionsLibres.Remove(fighter.pos);
            maze.Displaychar(matchar);

            WeaponsFactory factory2    = new WeaponsFactory();
            Weapons        weaponStore = new Weapons(factory2);
            Random         rand2       = new Random();
            int            index2      = rand2.Next(positionsLibres.Count);

            maze.SpawnWeapon(matchar, positionsLibres, index2);
            Position rdmPosWeapon = positionsLibres[index2 - 1];
            Weapon   weapon       = weaponStore.AskForWeapon(rdmPosWeapon);

            positionsLibres.Remove(weapon.pos);
            maze.Displaychar(matchar);
            Console.WriteLine("Position du fighter" + fighter.pos);
            Console.WriteLine("Nombre de fighter" + fighterStore.fightersList.Count());

            while (matchar[fighter.Sud().coord_X, fighter.Sud().coord_Y] != '2')
            {
                Weapon weap = maze.ChercheWeapon(weaponStore.ListWeapons, fighter);

                if (weap.pos.coord_X != 0 && weap.pos.coord_Y != 0)
                {
                    fighter.weapons.Add(weap);
                    weap.pos.coord_X = 0;
                    weap.pos.coord_Y = 0;
                }
                matchar = maze.Deplacement(matchar, fighter);
                Console.WriteLine("Nombre de fighter" + fighterStore.fightersList.Count());
                maze.Displaychar(matchar);
                Console.Clear();

                Console.WriteLine("Position du fighter" + fighter.pos);
                Console.WriteLine("rdmposweapon:" + rdmPosWeapon);
                Console.WriteLine(weap.pos);
            }
            if (matchar[fighter.Sud().coord_X, fighter.Sud().coord_Y] == '2')
            {
                maze.Displaychar(matchar);
                matchar[fighter.pos.coord_X, fighter.pos.coord_Y] = '0';
                fighter.pos = fighter.Sud();
                matchar[fighter.pos.coord_X, fighter.pos.coord_Y] = 'X';
                Console.ReadKey();
                Console.Clear();
                maze.Displaychar(matchar);
                Console.ReadKey();
                Console.Clear();
                Console.WriteLine();
                Console.Write("Arme du fighter: ");
                Console.WriteLine(fighter.weapons.Count());
                Console.Write("Arme dans la liste: ");
                Console.WriteLine(weaponStore.ListWeapons.Count());
                Console.Write("End of the game");
            }
        }
コード例 #54
0
ファイル: TestClass.cs プロジェクト: Mihawk93/LabyrinthFights
        public void TestCombat()
        {
            Labyrinthe maze = new Labyrinthe();

            char[,] matchar = TestInitialisation(maze, "..\\..\\mazeJoute.txt");
            Cell[,] cells   = maze.CharToCell(matchar);

            FightersFactory factory         = new FightersFactory();
            Fighters        fighterStore    = new Fighters(factory);
            List <Position> positionsLibres = maze.PositionLibres(cells);
            Random          rand            = new Random();
            int             index           = rand.Next(positionsLibres.Count);

            maze.SpawnCombatant(matchar, positionsLibres, index);
            Position rdmPosFighter1 = positionsLibres[index];
            Fighter  fighter1       = fighterStore.AskForAFighter(rdmPosFighter1);

            positionsLibres.Remove(fighter1.pos);
            maze.Displaychar(matchar);
            Random rand1  = new Random();
            int    index1 = rand1.Next(positionsLibres.Count);

            maze.SpawnCombatant(matchar, positionsLibres, index1);
            Position rdmPosFighter2 = positionsLibres[index1];
            Fighter  fighter2       = fighterStore.AskForAFighter(rdmPosFighter2);

            positionsLibres.Remove(fighter2.pos);
            maze.Displaychar(matchar);

            WeaponsFactory factory2    = new WeaponsFactory();
            Weapons        weaponStore = new Weapons(factory2);
            Random         rand2       = new Random();
            int            index2      = rand2.Next(positionsLibres.Count);

            maze.SpawnWeapon(matchar, positionsLibres, index2);
            Position rdmPosWeapon = positionsLibres[index2];
            Weapon   weapon       = weaponStore.AskForWeapon(rdmPosWeapon);

            positionsLibres.Remove(weapon.pos);
            maze.Displaychar(matchar);

            Random rand3  = new Random();
            int    index3 = rand3.Next(positionsLibres.Count);

            maze.SpawnWeapon(matchar, positionsLibres, index3);
            Position rdmPosWeapon2 = positionsLibres[index3];
            Weapon   weapon2       = weaponStore.AskForWeapon(rdmPosWeapon2);

            positionsLibres.Remove(weapon2.pos);

            Random rand4  = new Random();
            int    index4 = rand4.Next(positionsLibres.Count);

            maze.SpawnWeapon(matchar, positionsLibres, index4);
            Position rdmPosWeapon3 = positionsLibres[index4];
            Weapon   weapon3       = weaponStore.AskForWeapon(rdmPosWeapon3);

            positionsLibres.Remove(weapon3.pos);

            Random rand5  = new Random();
            int    index5 = rand5.Next(positionsLibres.Count);

            maze.SpawnWeapon(matchar, positionsLibres, index5);
            Position rdmPosWeapon4 = positionsLibres[index5];
            Weapon   weapon4       = weaponStore.AskForWeapon(rdmPosWeapon4);

            positionsLibres.Remove(weapon4.pos);

            Random rand6  = new Random();
            int    index6 = rand6.Next(positionsLibres.Count);

            maze.SpawnWeapon(matchar, positionsLibres, index6);
            Position rdmPosWeapon5 = positionsLibres[index6];
            Weapon   weapon5       = weaponStore.AskForWeapon(rdmPosWeapon5);

            positionsLibres.Remove(weapon5.pos);

            Random rand7  = new Random();
            int    index7 = rand7.Next(positionsLibres.Count);

            maze.SpawnWeapon(matchar, positionsLibres, index7);
            Position rdmPosWeapon6 = positionsLibres[index7];
            Weapon   weapon6       = weaponStore.AskForWeapon(rdmPosWeapon6);

            positionsLibres.Remove(weapon6.pos);

            Random rand8  = new Random();
            int    index8 = rand8.Next(positionsLibres.Count);

            maze.SpawnWeapon(matchar, positionsLibres, index8);
            Position rdmPosWeapon7 = positionsLibres[index8];
            Weapon   weapon7       = weaponStore.AskForWeapon(rdmPosWeapon7);

            positionsLibres.Remove(weapon7.pos);

            Random rand9  = new Random();
            int    index9 = rand9.Next(positionsLibres.Count);

            maze.SpawnWeapon(matchar, positionsLibres, index9);
            Position rdmPosWeapon8 = positionsLibres[index9];
            Weapon   weapon8       = weaponStore.AskForWeapon(rdmPosWeapon8);

            positionsLibres.Remove(weapon8.pos);

            Random rand10  = new Random();
            int    index10 = rand10.Next(positionsLibres.Count);

            maze.SpawnWeapon(matchar, positionsLibres, index10);
            Position rdmPosWeapon9 = positionsLibres[index10];
            Weapon   weapon9       = weaponStore.AskForWeapon(rdmPosWeapon9);

            positionsLibres.Remove(weapon9.pos);



            maze.Displaychar(matchar);
            Console.WriteLine("Position du fighter 1: " + fighter1.pos);
            Console.WriteLine("Position du fighter 2: " + fighter2.pos);
            Console.WriteLine("Nombre de fighter" + fighterStore.fightersList.Count());

            while (matchar[fighter1.Sud().coord_X, fighter1.Sud().coord_Y] != '2' && matchar[fighter2.Sud().coord_X, fighter2.Sud().coord_Y] != '2')
            {
                Weapon weap1 = maze.ChercheWeapon(weaponStore.ListWeapons, fighter1);
                Weapon weap2 = maze.ChercheWeapon(weaponStore.ListWeapons, fighter2);

                if (weap1.pos.coord_X != 0 && weap1.pos.coord_Y != 0)
                {
                    fighter1.weapons.Add(weap1);
                    fighter1.Dégats  += weap1.dégats;
                    weap1.pos.coord_X = 0;
                    weap1.pos.coord_Y = 0;
                }
                if (weap2.pos.coord_X != 0 && weap2.pos.coord_Y != 0)
                {
                    fighter2.weapons.Add(weap2);
                    fighter2.Dégats  += weap2.dégats;
                    weap2.pos.coord_X = 0;
                    weap2.pos.coord_Y = 0;
                }

                matchar = CheckFight(matchar, fighterStore, fighter1, fighter2);

                if (fighter1.Hp > 0)
                {
                    matchar = maze.Deplacement(matchar, fighter1);
                }

                matchar = CheckFight(matchar, fighterStore, fighter1, fighter2);

                if (fighter2.Hp > 0)
                {
                    matchar = maze.Deplacement(matchar, fighter2);
                }

                matchar = CheckFight(matchar, fighterStore, fighter1, fighter2);

                Console.WriteLine("Nombre de fighter" + fighterStore.fightersList.Count());
                maze.Displaychar(matchar);


                Console.WriteLine("Position du fighter 1: " + fighter1.pos);
                Console.WriteLine("Dégat du fighter 1: " + fighter1.Dégats);
                Console.WriteLine("PV du fighter 1: " + fighter1.Hp);
                Console.WriteLine("Position du fighter 2: " + fighter2.pos);
                Console.WriteLine("Dégat du fighter 2: " + fighter2.Dégats);
                Console.WriteLine("PV du fighter 2: " + fighter2.Hp);
                Console.WriteLine("rdmposweapon:" + rdmPosWeapon);

                Console.ReadKey();
                Console.Clear();
            }
            if (matchar[fighter1.Sud().coord_X, fighter1.Sud().coord_Y] == '2')
            {
                maze.Displaychar(matchar);
                matchar[fighter1.pos.coord_X, fighter1.pos.coord_Y] = '0';
                fighter1.pos = fighter1.Sud();
                matchar[fighter1.pos.coord_X, fighter1.pos.coord_Y] = 'X';
                Console.ReadKey();
                Console.Clear();
                maze.Displaychar(matchar);
                Console.ReadKey();
                Console.Clear();
                Console.WriteLine();
                Console.Write("Arme du fighter: ");
                Console.WriteLine(fighter1.weapons.Count());
                Console.Write("Arme dans la liste: ");
                Console.WriteLine(weaponStore.ListWeapons.Count());
                Console.Write("End of the game");
            }
        }
コード例 #55
0
    // Start is called before the first frame update
    void Start()
    {
        // Singleton
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        // Initialize size of map
        map = new Cell[width, height];
        Queue <Cell> floors = new Queue <Cell>();

        // Randomly disperse walls onto map
        for (int x = 0; x <= map.GetUpperBound(0); x++)
        {
            for (int y = 0; y <= map.GetUpperBound(1); y++)
            {
                // 50-50 chance of cell becoming a wall
                if (Random.Range(0, 100) < initialWallPlacementProbability)
                {
                    map[x, y] = new Cell(x, y, 1);
                }
                else
                {
                    map[x, y] = new Cell(x, y, 0);
                }
            }
        }

        // Run algorithm for input iterations
        for (int i = 0; i < iterations - 1; i++)
        {
            Cell[,] newMap = new Cell[width, height];
            for (int x = 0; x <= map.GetUpperBound(0); x++)
            {
                for (int y = 0; y <= map.GetUpperBound(1); y++)
                {
                    if (Cell.MooresNeighborhood(map, x, y) >= wallThreshold)
                    {
                        newMap[x, y] = new Cell(x, y, 1);
                    }
                    else
                    {
                        newMap[x, y] = new Cell(x, y, 0);
                    }
                }
            }
            map = newMap;
        }

        // Final iteration we add all floors to queue
        Cell[,] finalMap = new Cell[width, height];
        for (int x = 0; x <= map.GetUpperBound(0); x++)
        {
            for (int y = 0; y <= map.GetUpperBound(1); y++)
            {
                if (Cell.MooresNeighborhood(map, x, y) >= wallThreshold)
                {
                    finalMap[x, y] = new Cell(x, y, 1);
                }
                else
                {
                    finalMap[x, y] = new Cell(x, y, 0);
                    floors.Enqueue(finalMap[x, y]);
                }
            }
        }
        map = finalMap;


        // Room Creation
        while (floors.Count > 0)
        {
            Cell current = floors.Dequeue();
            if (current.visited == false)
            {
                Room newRoom = new Room();
                CreateRoom(current, newRoom);
                Room.rooms.Add(newRoom);
            }
        }

        Room largestRoom = Room.rooms[0];

        // Find largest room
        foreach (Room curRoom in Room.rooms)
        {
            if (curRoom.edgeCells.Count > largestRoom.edgeCells.Count)
            {
                largestRoom = curRoom;
            }
        }

        // If a room is not connected to the largest room, connect nearest rooms until it is
        // This assures connectivity to all rooms
        foreach (Room curRoom in Room.rooms)
        {
            while (!curRoom.connectedRooms.Contains(largestRoom))
            {
                ConnectionInformation cellsToConnect = curRoom.FindNearestUnconnected();

                List <Cell> path = AStar.Search(map, cellsToConnect.startCell, cellsToConnect.endCell);
                foreach (Cell cell in path)
                {
                    // Use connectionSize to fill in connection cells
                    for (int i = -connectionSize; i <= connectionSize; i++)
                    {
                        for (int j = -connectionSize; j <= connectionSize; j++)
                        {
                            int tempX = cell.x + i;
                            int tempY = cell.y + j;
                            if (tempX >= 0 && tempX <= map.GetUpperBound(0) && tempY >= 0 && tempY <= map.GetUpperBound(1))
                            {
                                map[tempX, tempY].value = 0;
                            }
                        }
                    }
                }
                curRoom.connectedRooms.UnionWith(cellsToConnect.targetRoom.connectedRooms);
            }
        }
        // Create list that will be used for furnishing
        List <Cell> randomOrder = new List <Cell>();

        // Placement of walls and floors
        for (int x = 0; x <= map.GetUpperBound(0); x++)
        {
            for (int y = 0; y <= map.GetUpperBound(1); y++)
            {
                if (map[x, y].value == 1)
                {
                    Instantiate(wall, new Vector3(x, y, 0), Quaternion.identity);
                }
                else if (map[x, y].value == 0)
                {
                    Instantiate(ground, new Vector3(x, y, 0), Quaternion.identity);
                    // Add floors to list used for furnishing
                    randomOrder.Add(map[x, y]);
                }
            }
        }

        // Furnishing
        for (int i = 0; i < furnishingIterations; i++)
        {
            Shuffle(randomOrder);

            Cell[,] newMap = (Cell[, ])map.Clone();
            foreach (Cell curCell in randomOrder)
            {
                if (map[curCell.x, curCell.y].value == 0)
                {
                    foreach (GameObject obj in furniture)
                    {
                        Furniture curFurniture = obj.GetComponent <Furniture>();
                        if (curFurniture.CanSpawn(map, curCell.x, curCell.y))
                        {
                            curFurniture.Spawn(curCell.x, curCell.y);
                            newMap[curCell.x, curCell.y].value = curFurniture.myValue;
                            break;
                        }
                    }
                }
            }
            map = newMap;
        }

        // Assure required amounts are met
        foreach (GameObject obj in furniture)
        {
            Furniture curFurniture = obj.GetComponent <Furniture>();
            int       count        = 0;
            while (curFurniture.GetAmount() < curFurniture.requiredAmount)
            {
                if (count > maxFurnishingIterations)
                {
                    Debug.LogError("Could not create level with required furniture");
                    Debug.Break();
                    break;
                }

                Shuffle(randomOrder);

                foreach (Cell curCell in randomOrder)
                {
                    if (map[curCell.x, curCell.y].value == 0 && curFurniture.CanSpawn(map, curCell.x, curCell.y))
                    {
                        curFurniture.Spawn(curCell.x, curCell.y);
                        map[curCell.x, curCell.y].value = curFurniture.myValue;
                        break;
                    }
                }
                count++;
            }
        }
    }
コード例 #56
0
ファイル: TestClass.cs プロジェクト: Mihawk93/LabyrinthFights
        public void TestDeplacement()
        {
            Labyrinthe maze = new Labyrinthe();

            char[,] matchar = TestInitialisation(maze, "..\\..\\theMaze.txt");
            Cell[,] cells   = maze.CharToCell(matchar);
            FightersFactory factory         = new FightersFactory();
            Fighters        fighterStore    = new Fighters(factory);
            List <Position> positionsLibres = maze.PositionLibres(cells);

            maze.RepartitionCombatants(matchar, positionsLibres, fighterStore);
            maze.Displaychar(matchar);
            Console.WriteLine();

            Fighter fighter1 = fighterStore.fightersList[0];
            Fighter fighter2 = fighterStore.fightersList[1];
            Fighter fighter3 = fighterStore.fightersList[2];

            maze.Displaychar(matchar);
            Console.WriteLine();
            while (matchar[fighter1.Est().coord_X, fighter1.Est().coord_Y] != '2' && matchar[fighter2.Est().coord_X, fighter2.Est().coord_Y] != '2' && matchar[fighter3.Est().coord_X, fighter3.Est().coord_Y] != '2')
            {
                matchar = maze.Deplacement(matchar, fighter1);
                matchar = maze.Deplacement(matchar, fighter2);
                matchar = maze.Deplacement(matchar, fighter3);
                Console.Clear();
                maze.Displaychar(matchar);
                Console.ReadKey();
            }
            if (matchar[fighter1.Est().coord_X, fighter1.Est().coord_Y] == '2')
            {
                matchar[fighter1.pos.coord_X, fighter1.pos.coord_Y] = '0';
                fighter1.pos = fighter1.Est();
                matchar[fighter1.pos.coord_X, fighter1.pos.coord_Y] = 'X';
                Console.Clear();
                maze.Displaychar(matchar);
                Console.ReadKey();
                Console.Clear();
                Console.Write("End of the game");
            }
            if (matchar[fighter2.Est().coord_X, fighter2.Est().coord_Y] == '2')
            {
                matchar[fighter2.pos.coord_X, fighter2.pos.coord_Y] = '0';
                fighter2.pos = fighter2.Est();
                matchar[fighter2.pos.coord_X, fighter2.pos.coord_Y] = 'X';
                Console.Clear();
                maze.Displaychar(matchar);
                Console.ReadKey();
                Console.Clear();
                Console.Write("End of the game");
            }
            if (matchar[fighter3.Est().coord_X, fighter3.Est().coord_Y] == '2')
            {
                matchar[fighter3.pos.coord_X, fighter3.pos.coord_Y] = '0';
                fighter3.pos = fighter3.Est();
                matchar[fighter3.pos.coord_X, fighter3.pos.coord_Y] = 'X';
                Console.Clear();
                maze.Displaychar(matchar);
                Console.ReadKey();
                Console.Clear();
                Console.Write("End of the game");
            }
        }
コード例 #57
0
ファイル: Rules.cs プロジェクト: dovh/openu
        public override void Output(Cell[,] N, ref Cell cell)
        {
            Cell center = N[1, 1];

            // Check if I want some one who does not want me.
            bool mismatch = false;

            if (center.Direction == Cell.direction.UpLeft && N[0, 0].Direction != Cell.direction.DownRight)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.Up && N[1, 0].Direction != Cell.direction.Down)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.UpRight && N[2, 0].Direction != Cell.direction.DownLeft)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.Left && N[0, 1].Direction != Cell.direction.Right)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.Right && N[2, 1].Direction != Cell.direction.Left)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.DownLeft && N[0, 2].Direction != Cell.direction.UpRight)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.Down && N[1, 2].Direction != Cell.direction.Up)
            {
                mismatch = true;
            }
            else if (center.Direction == Cell.direction.DownRight && N[2, 2].Direction != Cell.direction.UpLeft)
            {
                mismatch = true;
            }

            if (mismatch)
            {
                // in this case, check if some one else who stand next to you like you and still a better choise than the one you have.
                //   select one among all heighbors directed to the center, sorted by round odered.
                if (N[0, 0].Direction == Cell.direction.DownRight && N[0, 0].Match(center) > center.Match())
                {
                    cell.Direction = Cell.direction.UpLeft;
                }
                else if (N[1, 0].Direction == Cell.direction.Down && N[1, 0].Match(center) > center.Match())
                {
                    cell.Direction = Cell.direction.Up;
                }
                else if (N[2, 0].Direction == Cell.direction.DownLeft && N[2, 0].Match(center) > center.Match())
                {
                    cell.Direction = Cell.direction.UpRight;
                }
                else if (N[0, 1].Direction == Cell.direction.Right && N[0, 1].Match(center) > center.Match())
                {
                    cell.Direction = Cell.direction.Left;
                }
                else if (N[2, 1].Direction == Cell.direction.Left && N[2, 1].Match(center) > center.Match())
                {
                    cell.Direction = Cell.direction.Right;
                }
                else if (N[0, 2].Direction == Cell.direction.UpRight && N[0, 2].Match(center) > center.Match())
                {
                    cell.Direction = Cell.direction.DownLeft;
                }
                else if (N[1, 2].Direction == Cell.direction.Up && N[1, 2].Match(center) > center.Match())
                {
                    cell.Direction = Cell.direction.Down;
                }
                else if (N[2, 2].Direction == Cell.direction.UpLeft && N[2, 2].Match(center) > center.Match())
                {
                    cell.Direction = Cell.direction.DownRight;
                }
            }
        }
コード例 #58
0
ファイル: Rules.cs プロジェクト: dovh/openu
 public override bool Criteria(Cell[,] N)
 {
     return(true);
 }
コード例 #59
0
ファイル: Program.cs プロジェクト: Mihawk93/LabyrinthFights
        static void Main(string[] args)
        {
            //Initialisation
            string        file       = "..\\..\\theMaze.txt";
            Labyrinthe    maze       = new Labyrinthe();
            List <string> liststring = maze.ReadFile(file);

            char[,] matchar = maze.ConvertListStringToMatChar(liststring);
            Cell[,] cells   = maze.CharToCell(matchar);
            List <Position> positionsLibres = maze.PositionLibres(cells);


            //Répartion Combatants
            FightersFactory factoryFighter = new FightersFactory();
            Fighters        fighterStore   = new Fighters(factoryFighter);

            maze.RepartitionCombatants(matchar, positionsLibres, fighterStore);

            maze.fighterList = fighterStore.fightersList;

            //Répartion Weapons
            WeaponsFactory factoryWeapons = new WeaponsFactory();
            Weapons        weaponStore    = new Weapons(factoryWeapons);

            maze.RepartitionWeapon(matchar, positionsLibres, weaponStore);

            //Stockage des Combatants
            Fighter fighter1 = fighterStore.fightersList[0]; //Bleu
            Fighter fighter2 = fighterStore.fightersList[1]; //Vert
            Fighter fighter3 = fighterStore.fightersList[2]; //Blanc



            //Stockage des Armes
            Weapon weapon1 = weaponStore.ListWeapons[0];
            Weapon weapon2 = weaponStore.ListWeapons[1];
            Weapon weapon3 = weaponStore.ListWeapons[2];
            Weapon weapon4 = weaponStore.ListWeapons[3];
            Weapon weapon5 = weaponStore.ListWeapons[4];
            Weapon weapon6 = weaponStore.ListWeapons[5];
            Weapon weapon7 = weaponStore.ListWeapons[6];
            Weapon weapon8 = weaponStore.ListWeapons[7];
            Weapon weapon9 = weaponStore.ListWeapons[8];


            //Boucle du jeu
            while (matchar[fighter1.Est().coord_X, fighter1.Est().coord_Y] != '2' && matchar[fighter2.Est().coord_X, fighter2.Est().coord_Y] != '2' && matchar[fighter3.Est().coord_X, fighter3.Est().coord_Y] != '2')
            {
                Weapon weap1 = maze.ChercheWeapon(weaponStore.ListWeapons, fighter1);
                Weapon weap2 = maze.ChercheWeapon(weaponStore.ListWeapons, fighter2);
                Weapon weap3 = maze.ChercheWeapon(weaponStore.ListWeapons, fighter3);

                if (weap1.pos.coord_X != 0 && weap1.pos.coord_Y != 0)
                {
                    fighter1.weapons.Add(weap1);
                    fighter1.Dégats  += weap1.dégats;
                    weap1.pos.coord_X = 0;
                    weap1.pos.coord_Y = 0;
                }
                if (weap2.pos.coord_X != 0 && weap2.pos.coord_Y != 0)
                {
                    fighter2.weapons.Add(weap2);
                    fighter2.Dégats  += weap2.dégats;
                    weap2.pos.coord_X = 0;
                    weap2.pos.coord_Y = 0;
                }
                if (weap3.pos.coord_X != 0 && weap3.pos.coord_Y != 0)
                {
                    fighter3.weapons.Add(weap3);
                    fighter3.Dégats  += weap3.dégats;
                    weap3.pos.coord_X = 0;
                    weap3.pos.coord_Y = 0;
                }

                matchar = CheckFight(matchar, fighterStore, fighter1, fighter2);
                matchar = CheckFight(matchar, fighterStore, fighter1, fighter3);
                if (fighter1.Hp > 0)
                {
                    matchar = maze.Deplacement(matchar, fighter1);
                }

                matchar = CheckFight(matchar, fighterStore, fighter2, fighter1);
                matchar = CheckFight(matchar, fighterStore, fighter2, fighter3);
                if (fighter2.Hp > 0)
                {
                    matchar = maze.Deplacement(matchar, fighter2);
                }


                matchar = CheckFight(matchar, fighterStore, fighter3, fighter1);
                matchar = CheckFight(matchar, fighterStore, fighter3, fighter2);
                if (fighter3.Hp > 0)
                {
                    matchar = maze.Deplacement(matchar, fighter3);
                }

                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("Nombre de fighter: " + fighterStore.fightersList.Count());
                Console.WriteLine("Position du fighter 1 : " + fighter1.pos);
                Console.WriteLine("Arme du fighter 1: " + fighter1.weapons.Count());
                Console.WriteLine("Dégat du fighter1 : " + fighter1.Dégats);
                Console.WriteLine("PV du fighter1 : " + fighter1.Hp);
                Console.ResetColor();

                Console.WriteLine();

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Position du fighter 2 : " + fighter2.pos);
                Console.WriteLine("Arme du fighter 2: " + fighter2.weapons.Count());
                Console.WriteLine("Dégat du fighter2 : " + fighter2.Dégats);
                Console.WriteLine("PV du fighter2 : " + fighter2.Hp);
                Console.ResetColor();

                Console.WriteLine();

                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Position du fighter 3 : " + fighter3.pos);
                Console.WriteLine("Arme du fighter 3: " + fighter3.weapons.Count());
                Console.WriteLine("Dégat du fighter3 : " + fighter3.Dégats);
                Console.WriteLine("PV du fighter3 : " + fighter3.Hp);
                Console.ResetColor();

                Console.WriteLine();
                maze.Displaychar(matchar);
                //Console.ReadKey();
                Console.WriteLine();
                Console.Clear();
            }

            //Condition pour finir la partie
            if (matchar[fighter1.Est().coord_X, fighter1.Est().coord_Y] == '2')
            {
                matchar[fighter1.pos.coord_X, fighter1.pos.coord_Y] = '0';
                fighter1.pos = fighter1.Est();
                matchar[fighter1.pos.coord_X, fighter1.pos.coord_Y] = 'X';
                Console.Clear();
                maze.Displaychar(matchar);
                Console.WriteLine("End of the game");
                Console.WriteLine("Combatant 1 a gagné");
            }
            if (matchar[fighter2.Est().coord_X, fighter2.Est().coord_Y] == '2')
            {
                matchar[fighter2.pos.coord_X, fighter2.pos.coord_Y] = '0';
                fighter2.pos = fighter2.Est();
                matchar[fighter2.pos.coord_X, fighter2.pos.coord_Y] = 'X';
                Console.Clear();
                maze.Displaychar(matchar);
                Console.WriteLine("End of the game");
                Console.WriteLine("Combatant 2 a gagné");
            }
            if (matchar[fighter3.Est().coord_X, fighter3.Est().coord_Y] == '2')
            {
                matchar[fighter3.pos.coord_X, fighter3.pos.coord_Y] = '0';
                fighter3.pos = fighter3.Est();
                matchar[fighter3.pos.coord_X, fighter3.pos.coord_Y] = 'X';
                Console.Clear();
                maze.Displaychar(matchar);
                Console.WriteLine("End of the game");
                Console.WriteLine("Combatant 3 a gagné");
            }



            Console.ReadKey();
        }
コード例 #60
0
 public Board()
 {
     Grid = new Cell[COLS, ROWS];
     InitBoard();
 }