示例#1
0
        private static void DifferentElements(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int delta, Panel MainPanel)
        {
            switch (gameField[i, j + delta].Type)
            {
            case "Gold":
                Gold.IncreaseCount(10);
                SkipSecondElements(gameField, pictureField, i, j, delta, 0, MainPanel);
                _prevSecond = new FreeArea();
                SecondUpdate(i, j, delta, 0, gameField, pictureField, _prevSecond, new SecondPlayer(), MainPanel);
                break;

            case "SimpleEnemy":
            case "BlindEnemy":
                DieFromEnemy(gameField, pictureField, i, j, delta, MainPanel);
                break;

            case "ExitDoor":
                ExitGame(gameField, pictureField, i, j, delta, new SecondPlayer(), MainPanel);
                break;

            case "Teleport":
                Teleportation(gameField, pictureField, i, j, delta, new SecondPlayer(), MainPanel);
                break;

            case "RandomPrize":
                RandomPrize(gameField, pictureField, i, j, delta, 0, new SecondPlayer(), MainPanel);
                break;

            default:
                SkipSecondElements(gameField, pictureField, i, j, delta, 0, MainPanel);
                break;
            }
        }
示例#2
0
        private void InitFieldArray(int fx, int fy)
        {
            if (fileldArray != null)
            {
                //clean field
                int lx = fileldArray.GetLength(0);
                int ly = fileldArray.GetLength(1);
                for (int iy = 0; iy <= ly - 1; iy++)
                {
                    for (int ix = 0; ix <= lx - 1; ix++)
                    {
                        fileldArray[ix, iy].Clean();
                    }
                }
            }

            fileldArray = new GameCell[fx, fy];

            for (int iy = 0; iy <= fy - 1; iy++)
            {
                for (int ix = 0; ix <= fx - 1; ix++)
                {
                    if (fileldArray[ix, iy] is GameCell)
                    {
                        fileldArray[ix, iy].Clean();
                    }
                    else
                    {
                        fileldArray[ix, iy] = new GameCell(ix, iy, CellMode.Empty, CellMode.Empty, WinMode.None);
                    }
                }
            }
        }
示例#3
0
 private static void SkipElements(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int x, int y, Panel MainPanel)
 {
     gameField[i, j] = _prevEnemy;
     Update(i, j, x, y, gameField, pictureField, _prevEnemy, new SimpleEnemy(), MainPanel);
     _prevEnemy = gameField[i + y, j + x];
     gameField[i + y, j + x] = new SimpleEnemy();
 }
示例#4
0
        private void showBoard()
        {
            GameCell[,] boardCells = r_GameManager.BoardGameCells;

            StringBuilder gameBoardStringBuilder = new StringBuilder(" ");

            for (int i = 0; i < r_GameManager.BoardSize; i++)
            {
                gameBoardStringBuilder.AppendFormat(" {0} ", i + 1);
            }

            gameBoardStringBuilder.Append(Environment.NewLine);

            for (int i = 0; i < r_GameManager.BoardSize; i++)
            {
                gameBoardStringBuilder.AppendFormat("{0}| ", (char)(i + 'A'));
                for (int j = 0; j < r_GameManager.BoardSize; j++)
                {
                    gameBoardStringBuilder.AppendFormat("{0}| ",
                                                        (boardCells[i, j].Value == Enums.eCellValue.Blank) ?
                                                        " " :
                                                        boardCells[i, j].Value.ToString());
                }
                gameBoardStringBuilder.Append(Environment.NewLine);
                gameBoardStringBuilder.AppendLine("  " + new string('=', r_GameManager.BoardSize * 3));
            }

            Console.WriteLine(gameBoardStringBuilder);
        }
示例#5
0
        public State(GameCell[,] field, GameState gs)
        {
            Inside = new string[field.GetLength(0), field.GetLength(1)];
            Moles  = new List <string>();
            Plants = new List <string>();

            for (var i = 0; i < field.GetLength(0); i++)
            {
                for (var j = 0; j < field.GetLength(1); j++)
                {
                    if (field[i, j].P != null)
                    {
                        Plants.Add("P" + field[i, j].P.Id + ": " + field[i, j].P.Health);
                    }

                    foreach (var m in field[i, j].M)
                    {
                        Moles.Add("M" + m.Id + (m.Gender == Gender.Male ? "M" : "F") + ": " + m.Health);
                    }

                    Inside[i, j] = (field[i, j]?.P?.Health > 0 ? "P" + field[i, j].P.Id + " " : "") +
                                   (field[i, j]?.C != null ? "C " : "") +
                                   field[i, j]?.M.Aggregate("",
                                                            (current, tmp) => current + "M" + tmp.Id + (tmp.Gender == Gender.Male ? "M " : "F "));
                }
            }

            Plants.Add(string.Empty);
            Plants.Add(gs == GameState.СWiNs ? "Cottager wins!" : gs == GameState.MWiNs ? "Moles wins!" : "");
        }
示例#6
0
        public String Render(GameCell[,] GameField,
                             GamePoint User,
                             int DimX,
                             int DimY,
                             String CellUser, String CellEmpty)
        {
            String temp = "";

            for (int yy = 0; yy < DimY; yy++)
            {
                for (int xx = 0; xx < DimX; xx++)
                {
                    if (yy == User.Y && xx == User.X)
                    {
                        temp += CellUser;
                    }
                    else
                    {
                        temp += CellEmpty;
                    }
                }
                temp += Environment.NewLine;
            }
            return(temp);
        }
示例#7
0
 protected static void SkipElements(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int x, int y, GameCell p, Panel MainPanel)
 {
     gameField[i, j] = _prev;
     Update(i, j, x, y, gameField, pictureField, p, _prev, MainPanel);
     _prev = gameField[i + y, j + x];
     gameField[i + y, j + x] = p;
 }
示例#8
0
 private static void SkipSecondElements(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int x, int y, Panel MainPanel)
 {
     gameField[i, j] = _prevSecond;
     SecondUpdate(i, j, x, y, gameField, pictureField, _prevSecond, new SecondPlayer(), MainPanel);
     _prevSecond             = gameField[i + y, j + x];
     gameField[i + y, j + x] = new SecondPlayer();
 }
示例#9
0
        public void GenerateField(Panel MainPanel, string name)
        {
            string ars   = File.ReadAllText("Data\\Levels\\" + name + ".json");
            Matrix field = JsonConvert.DeserializeObject <Matrix>(ars);

            string[,] gameField = field.Field;
            int he = field.H;
            int wi = field.W;

            GameCell[,] myField        = new GameCell[he, wi];
            PictureBox[,] pictureField = new PictureBox[he, wi];
            for (int i = 0; i < he; i++)
            {
                for (int j = 0; j < wi; j++)
                {
                    myField[i, j]      = FieldGenerator[Convert.ToChar(gameField[i, j])];
                    pictureField[i, j] = new PictureBox()
                    {
                        Size     = new Size(30, 30),
                        SizeMode = PictureBoxSizeMode.StretchImage,
                        Location = new Point(j * 30, i * 30),
                        Image    = new Bitmap(myField[i, j].Image)
                    };
                    MainPanel.Controls.Add(pictureField[i, j]);
                    if (myField[i, j].Type == "Teleport")
                    {
                        int[] coordInts = { i, j };
                        TeleportCoords.Add(coordInts);
                    }
                }
            }
            curField = myField;
            curPics  = pictureField;
        }
示例#10
0
        protected static void RandomPrize(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int x, int y, GameCell p, Panel MainPanel)
        {
            MoveOnFreeArea(i, j, y, x, gameField, p);
            Update(i, j, x, y, gameField, pictureField, new FreeArea(), p, MainPanel);
            var rnd   = new Random();
            int index = rnd.Next(1, 5);

            switch (index)
            {
            case 1:
                for (int k = 0; k < 5; k++)
                {
                    Gold.IncreaseCount(20);
                }
                break;

            case 2:
                Gold.SetGoldCount();
                break;

            case 3:
                MessageBox.Show("YOU LOOSE!");
                break;
            }
        }
        public GameBoard(double dimension, int size)
        {
            InputTransparent = true;
            _size            = size;
            //    BackgroundColor = Color.FromHex("142F54");
            _spacing     = dimension * .01;
            Padding      = RowSpacing = ColumnSpacing = _spacing;
            WidthRequest = HeightRequest = dimension;

            _cells = new GameCell[_size, _size];

            for (int index = 0; index < _size; index++)
            {
                RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });
            }

            _childDimension = (dimension - (_spacing * (size + 1))) / size;

            BuildGrid((x, y) => BuildBackgroundGrid(_childDimension));

            BuildGrid((x, y) =>
            {
                var cell     = new GameCell(_childDimension);
                _cells[x, y] = cell;
                return(cell);
            });
        }
示例#12
0
 public Board(GameCell[,] cells, Vector2 size)
 {
     this.cells    = cells;
     this.size     = size;
     this.players  = new List <Player>();
     this.monsters = new List <Monster>();
 }
示例#13
0
        protected void Initialise()
        {
            Random random = new Random();

            int x = 1;
            int y = 1;

            visibleCellsWide = 11;
            visibleCellsHigh = 8;
            cellsIndex       = new GameCell[this.level.GetWidth(), this.level.GetHeight()];

            while (y < visibleCellsHigh + cellOverflow)
            {
                x = 1;
                while (x < visibleCellsWide + cellOverflow)
                {
                    if (random.Next(1, 4) == 3)
                    {
                        CreateCell(x, y);
                    }

                    x++;
                }

                y++;
            }
        }
示例#14
0
 protected static void SkipElementsCreator(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int x, int y, GameCell p, Panel MainPanel)
 {
     gameField[i, j] = _prev;
     UpdateCreator(i, j, x, y, gameField, pictureField, _prev, new Cursor(), MainPanel);
     _prev = gameField[i + y, j + x];
     gameField[i + y, j + x] = new Cursor();
 }
示例#15
0
 private static void ArrowKeys(GameCell[,] gameField, int i, int j, int y, int x, int param1, int param2, Panel MainPanel, PictureBox[,] pictureField)
 {
     if (param1 > param2)
     {
         SkipElementsCreator(gameField, pictureField, i, j, x, y, new Cursor(), MainPanel);
     }
 }
示例#16
0
文件: Maze.cs 项目: dymara/Bomberman
    private void CreateFindings(ArrayList destructibleCubes, float cubeWidth, GameCell[,] cells, PositionConverter positionConverter, LevelConfig levelConfig)
    {
        for (int i = 0; i < levelConfig.findingExtraBombsCount; i++)
        {
            CreateFindingObject(destructibleCubes, cubeWidth, cells, positionConverter, extraBombFindingPrefab, i, extraBombFindingMinimap);
        }

        for (int i = 0; i < levelConfig.findingExtraLivesCount; i++)
        {
            CreateFindingObject(destructibleCubes, cubeWidth, cells, positionConverter, extraLifeFindingPrefab, i, extraLifeFindingMinimap);
        }

        for (int i = 0; i < levelConfig.findingBombRangeCount; i++)
        {
            CreateFindingObject(destructibleCubes, cubeWidth, cells, positionConverter, rangeBombFindingPrefab, i, rangeBombFindingMinimap);
        }

        for (int i = 0; i < levelConfig.findingFasterMovingCount; i++)
        {
            CreateFindingObject(destructibleCubes, cubeWidth, cells, positionConverter, fasterMovingFindingPrefab, i, fasterMovingFindingMinimap);
        }

        for (int i = 0; i < levelConfig.findingRemoteDetonationCount; i++)
        {
            CreateFindingObject(destructibleCubes, cubeWidth, cells, positionConverter, remoteDetonationFindingPrefab, i, remoteDetonationFindingMinimap);
        }
    }
示例#17
0
文件: Map.cs 项目: ValerCheck/Snaky
 public Map(int width, int height)
 {
     _width  = width;
     _height = height;
     _cells  = new GameCell[_height, _width];
     FillMap();
 }
示例#18
0
文件: Coin.cs 项目: khrpnv/LodeRunner
 public static void ForThread(GameCell[,] gameField, PictureBox[,] pictureField, Panel MainPanel)
 {
     while (ThreadFlag)
     {
         SimpleMovement(gameField, pictureField, MainPanel);
         Thread.Sleep(200);
     }
 }
示例#19
0
 public Board(int i_Height, int i_Width)
 {
     m_BoardGameMat = new GameCell[i_Height, i_Width];
     r_Rows         = i_Height;
     r_Cols         = i_Width;
     initialBoard();
     randomizeBoard();
 }
示例#20
0
 public void Init(Game game)
 {
     this.game = game;
     gameCells = new GameCell[game.Size, game.Size];
     RenderBackground();
     RefreshView();
     CheckGameState();
 }
示例#21
0
文件: Coin.cs 项目: khrpnv/LodeRunner
 private static void SkipElements(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int x, int y, Panel MainPanel)
 {
     _changeDir++;
     gameField[i, j] = _prevCoin;
     Update(i, j, x, y, gameField, pictureField, _prevCoin, new Coin(), MainPanel);
     _prevCoin = gameField[i + y, j + x];
     gameField[i + y, j + x] = new Coin();
 }
示例#22
0
 private static void GeneralDestroy(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int deltay, int deltax, Panel MainPanel)
 {
     gameField[i + deltay, j + deltax] = new Destructed();
     DestrCoords.Add(i + deltay);
     DestrCoords.Add(j + deltax);
     _click++;
     Update(i, j, deltax, deltay, gameField, pictureField, new Destructed(), new Player(), MainPanel);
 }
示例#23
0
 public Board(int i_Height, int i_Width)
 {
     m_BoardGameMat = new GameCell[i_Height, i_Width];
     m_Rows         = i_Height;
     m_Cols         = i_Width;
     InitialBoard();
     RandomizeBoard();
 }
示例#24
0
        public Game(GameSettings gameSettings)
        {
            _settings = gameSettings;
            Field     = new GameCell[_settings.GameFieldHeight, _settings.GameFieldWidth];

            SetMines();

            SetGameFieldElementsValues();
        }
示例#25
0
 internal Board(int i_Height, int i_Width)
 {
     r_Height           = i_Height;
     r_Width            = i_Width;
     m_RemainingCouples = (r_Height * r_Width) / 2;
     m_BoardCells       = createBoard();
     shuffleBoard();
     m_UnRevealedCells = createUnRevealedCellsList();
 }
示例#26
0
        public GameWorld(string playerCompanyName, int playerMoney, int groundLevel, int width, int height)
        {
            this.playerData  = new Dictionary <string, PlayerData>();
            this.gameMap     = new GameCell[height, width];
            this.groundLevel = groundLevel;

            this.playerCompanyName = playerCompanyName;
            AddPlayer(playerCompanyName, playerMoney);
        }
示例#27
0
    void Start()
    {
        HappinessGameInfo.PuzzleInit();

        RectTransform rt = (RectTransform)transform;

        float cellWidth  = rt.rect.width / HappinessGameInfo.PuzzleSize;
        float cellHeight = rt.rect.height / HappinessGameInfo.PuzzleSize;
        float largeSize  = Mathf.Min(cellHeight, cellWidth);

        int topRowCount = HappinessGameInfo.PuzzleSize >> 1;
        int botRowCount = HappinessGameInfo.PuzzleSize - topRowCount;

        // Make sure bottom row is the smaller of the two
        while (topRowCount < botRowCount)
        {
            topRowCount++;
            botRowCount--;
        }
        float smallSize  = Mathf.Min(cellWidth / topRowCount, cellHeight / 2);
        int   halfTopRow = topRowCount >> 1;
        float topRowLeft = (smallSize * halfTopRow);

        if ((topRowCount & 1) == 0)
        {
            topRowLeft -= (smallSize / 2);
        }
        int   halfBotRow = botRowCount >> 1;
        float botRowLeft = (smallSize * halfBotRow);

        if ((botRowCount & 1) == 0)
        {
            botRowLeft -= (smallSize / 2);
        }


        Cells = new GameCell[HappinessGameInfo.PuzzleSize, HappinessGameInfo.PuzzleSize];
        for (int y = 0; y < HappinessGameInfo.PuzzleSize; y++)
        {
            for (int x = 0; x < HappinessGameInfo.PuzzleSize; x++)
            {
                // Create the cell
                string   cellName = string.Format("Cell_{0}_{1}", x, y);
                GameCell gc       = new GameObject(cellName, typeof(RectTransform), typeof(GameCell)).GetComponent <GameCell>();
                gc.transform.SetParent(transform);
                gc.GetComponent <RectTransform>().SetAnchorAndPivot(AnchorPresets.TopLeft, PivotPresets.TopLeft);
                gc.Setup(x, y, cellWidth, cellHeight, largeSize, smallSize, topRowCount, botRowCount, topRowLeft, botRowLeft);

                // Add the frame
                Instantiate(FramePrefab, gc.transform, false);
                Cells[x, y]   = gc;
                gc.CellDialog = CellDialog;
            }
        }

        CellDialog.Init();
    }
示例#28
0
 private static void DestroyCells(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int delta, Panel MainPanel)
 {
     if (gameField[i + 1, j + delta].Type != "Ground" || gameField[i, j + delta].Type != "FreeArea" ||
         gameField[i, j + delta].Type == "Ground" || i + 1 == gameField.GetLength(0) - 1 || gameField[i, j + delta].Type == "SimpleEnemy")
     {
         return;
     }
     GeneralDestroy(gameField, pictureField, i, j, 1, delta, MainPanel);
 }
示例#29
0
 protected static void DownArrowMovement(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, Player p, Panel MainPanel)
 {
     if (gameField[i + 1, j].Type != "Ladder")
     {
         return;
     }
     MoveOnLadder(i, j, 1, 0, gameField, p);
     Update(i, j, 0, 1, gameField, pictureField, p, new Ladder(), MainPanel);
 }
示例#30
0
 protected static void UpArrowMovement(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, Player p, Panel MainPanel)
 {
     if ((gameField[i + 1, j].Type != "Ladder" || gameField[i - 1, j].Type == "FreeArea" || gameField[i - 1, j] is Ground) && !(gameField[i + 1, j] is Ground) || gameField[i - 1, j].Type != "Ladder")
     {
         return;
     }
     MoveOnLadder(i, j, -1, 0, gameField, p);
     Update(i, j, 0, -1, gameField, pictureField, p, new Ladder(), MainPanel);
 }
示例#31
0
文件: GameGrid.cs 项目: penryu/Life
        public GameGrid(int width, int height)
        {
            FIELD_WIDTH = width;
            FIELD_HEIGHT = height;

            field = new GameCell[FIELD_WIDTH, FIELD_HEIGHT];

            InitializeCells();
        }
示例#32
0
 public MinerGame(int rowNumber, int collNumber)
 {
     isGameEmpty = true;
     gameField = new GameCell[rowNumber, collNumber];
     for (int i = 0; i < rowNumber; i++)
     {
         for (int j = 0; j < collNumber; j++)
         {
             gameField[i,j] = new GameCell(isEmpty: true, isOpened: false);
         }
     }
     gameFieldWidth = collNumber;
     gameFieldHeight = rowNumber;
 }
示例#33
0
 public MinerGame(int rowNumber, int collNumber, int countOfBombs)
 {
     isGameEmpty = false;
     gameField = new GameCell[rowNumber,collNumber];
     for (int i = 0; i < rowNumber; i++)
     {
         for (int j = 0; j < collNumber; j++)
         {
             gameField[i, j] = new GameCell(isEmpty: true, isOpened: false);
         }
     }
     gameFieldWidth = rowNumber;
     gameFieldHeight = collNumber;
     while (countOfBombs != 0)
     {
         int i = rand.Next(0, rowNumber);
         int j = rand.Next(0, collNumber);
         if (SetBomb(i, j))
         {
             countOfBombs--;
         }
     }
 }
示例#34
0
 public SetValuesMathod(GameCell[,] field)
     : base(field.GetLength(0), field.GetLength(1))
 {
     _field = field;
 }
示例#35
0
 public OpenCellsMathod(GameCell[,] field)
     : base(field.GetLength(0), field.GetLength(1))
 {
     _field = field;
     OpenedCells = new List<Cell>();
 }