public void FillBoardWithShipsAndFire() { Board board = new Board(5); Assert.Equal(5, board.BoardDimensions); Assert.True(board.Id > 0); var ships = new List <Ship>(); for (int i = 0; i < 10; i++) { ships.Add(new Ship { Layout = ShipLayoutEnum.Horizontal, ShipLength = 2, ShipSymbol = string.Format("Ship %d", i) }); } foreach (Ship s in ships) { Assert.True(board.PlaceShip(s)); } var boardPanel = new BoardPanel { X = 1, Y = 1 }; Assert.True(board.Fire(boardPanel)); }
// function to check if pieces can fall into this board box // ( AKA piece want to come in? Welcome~! ) public override bool allowsGravity(BoardPanel bp) { int listNum = boardA.IndexOf(bp.master); if (listNum >= 0) { int[] arrayRef = getExitPath(boardB[listNum]); if (arrayRef[0] >= 0 && arrayRef[0] < gm.boardWidth && arrayRef[1] >= 0 && arrayRef[1] < gm.boardHeight) // within bounds { if (boardA[listNum].isFilled && !boardB[listNum].isFilled && !boardA[listNum].isFalling) // if there is a piece ready to teleport { boardB[listNum].piece = boardA[listNum].piece; // moves the piece in memory boardB[listNum].piece.master = boardB[listNum]; // sync the master data boardA[listNum].piece = null; // moves the piece visually instantly boardB[listNum].piece.thisPiece.transform.position = boardB[listNum].position; // cancels any tweening still running LeanTween.cancel(boardB[listNum].piece.thisPiece); // mostly its the after-effect drop boardB[listNum].isFalling = false; // reset board status ( as pre-caution ) gm.dropPieces(arrayRef[0], arrayRef[1]); // start the gravity check on the other side } if (gm.countUnfilled(boardB[listNum].arrayRef[0], boardB[listNum].arrayRef[1], true) > 0 && !boardB[listNum].isFilled) { return(true); // still has boxes to fill, allow more in } } } return(false); }
// function to play the audio visuals of this panel public override void playAudioVisuals(BoardPanel bp) { // define your audio visual call here... // e.g. > // master.gm.audioScript.playSound(PlayFx.YOUR DEFINED AUDIO); // master.gm.animScript.doAnim(animType.YOUR DEFINED ANIM, master.arrayRef[0], master.arrayRef[1] ); }
private void FrmBoard_Load(object sender, EventArgs e) { //this.Left = 0; //this.Top = 0; this.Left = 1920 - Width; this.Top = 1080 - Height; BoardPanel.Show(); writingBoard.Initialize(BoardPanel.Handle, BoardPanel.ClientSize.Height, BoardPanel.ClientSize.Width); }
// for external scripts to call, if splash damage hits correct panel type, perform the hit public override bool splashDamage(BoardPanel bp) { // define your panel characteristic... typically durability--; else, do nothing... // don't forget to include "playAudioVisuals(bp);" if needed... return(false); // default behaviour // return statement, // if true - panel skin will refresh and panel will be active for other checks // if false - panel skin will NOT refresh and panel acts as though nothing happened }
// function to check if pieces can fall into this board box public override bool allowsGravity(BoardPanel bp) { int emptyCount = bp.master.gm.countBlockedUnfilled(bp.master.arrayRef[0], bp.master.arrayRef[1], true); if (emptyCount > 0) { return(true); } return(false); }
public bool PlaceShip([FromRoute] int boardId, [FromBody] BoardPanel boardPanel) { Board board = cache.Get <Board>(boardId); bool result = board.Fire(boardPanel); if (result) { cache.Set(boardId, board); } return(result); }
public MyForm(Game model) { var mainTable = CreateMainTable(); var table = BoardPanel.CreateGameBoardPanel(model); var statTable = StatTable.CreateStatPanel(model); mainTable.Controls.Add(table, 0, 0); mainTable.Controls.Add(statTable, 1, 0); Controls.Add(mainTable); model.GameEnded += GameEndMessage; }
public void FireOnAnEmptyBoard() { Board board = new Board(5); Assert.Equal(5, board.BoardDimensions); Assert.True(board.Id > 0); var boardPanel = new BoardPanel { X = 1, Y = 1 }; Assert.False(board.Fire(boardPanel)); }
// for external scripts to call, will indicate that the panel got hit public override bool gotHit(BoardPanel bp) { // your extra/custom code here... base.gotHit(bp); // default behaviour call function ( if needed ) // ====== the default behaviour below - as reference playAudioVisuals(bp); // play audio visual for selected panels bp.durability--; return(true); // tell controller that a hit registered.. ( will swap object skin according to durability ) // ====== end of default behaviour reference // return statement, // if true - panel skin will refresh and panel will be active for other checks // if false - panel skin will NOT refresh and panel acts as though nothing happened }
private void button1_Click(object sender, EventArgs e) { MenuPanel.Hide(); TextBox txt = new TextBox(); txt.Text = "Game Panel"; GamePanel.Controls.Add(txt); GamePanel.Show(); Image Archer = Image.FromFile(@"C:\Users\kyle.marshall\Source\Repos\Jordans_Game\Jordans_Game\P1Archer.png"); //ceate pieces Piece P1A = new Piece(Archer, 110, 30); pieces.Add(P1A); BoardPanel.Show(); }
private void InitializeComponent() { SuspendLayout(); ClientSize = new Size(1200, 800); Board = new BoardPanel(controller); Edit = new EditPanel(controller); Statistics = new StatisticsPanel(controller); Result = new Label(); Result.Height = 100; Result.Font = new Font(Result.Font.FontFamily, 15); var MultiPanel = new FlowLayoutPanel { FlowDirection = FlowDirection.TopDown, Dock = DockStyle.Fill }; MultiPanel.Controls.Add(Result); MultiPanel.Controls.Add(Board); MultiPanel.Controls.Add(Edit); var TotalPanel = new FlowLayoutPanel { FlowDirection = FlowDirection.LeftToRight, Dock = DockStyle.Fill }; TotalPanel.Controls.Add(MultiPanel); TotalPanel.Controls.Add(Statistics); Controls.Add(MultiPanel); Name = "FourInARow"; ResumeLayout(false); }
// optional onPanelClicked function when panel is clicked public override void onPanelClicked(BoardPanel bp) { // default does nothing... }
// optional onBoardStabilize called by GameManager when board stabilize and gets a suggestion public override void onBoardStabilize(BoardPanel bp) { // default does nothing... }
// optional onPlayerMove called by GameManager when player makes the next move public override void onPlayerMove(BoardPanel bp) { // default does nothing... }
// optional onDestroy function to define extra behaviours // not the same as being hit... this is when the panel is destroyed completely and changing types public override void onPanelDestroy(BoardPanel bp) { // default does nothing... }
// if the piece here can be switched around public override bool isSwitchable(BoardPanel bp) { return(false); }
// function to check if pieces can fall into this board box // ( AKA piece want to come in? Welcome~! ) public override bool allowsGravity(BoardPanel bp) { // your logic here ( if needed ) return(true); }
// function to play the audio visuals of this panel public override void playAudioVisuals(BoardPanel bp) { // nothing... }
// for external scripts to call, if splash damage hits correct panel type, perform the hit public override bool splashDamage(BoardPanel bp) { return(false); // do nothing... }
// function to check if this board is a solid panel // ( AKA piece, NO ENTRY!! ROADBLOCK~!- IMPORTANT, not the same of allowsGravity()~! // this function determines if pieces will landslide it's neighbouring piece to fill bottom blocks) public override bool isSolid(BoardPanel bp) { return(false); }
// function to check if this board needs to be filled by gravity public override bool isFillable(BoardPanel bp) { return(false); }
// function to check if pieces can be stolen from this box by gravity public override bool isStealable(BoardPanel bp) { return(true); }
// if the piece here (if any) can be destroyed public override bool isDestructible(BoardPanel bp) { return(true); }
// if the piece here (if any) can be destroyed / Matched public override bool isDestructible(BoardPanel bp) { // your logic here ( if needed ) return(true); }
// function to check if this board is a solid panel // ( AKA piece, NO ENTRY!! ROADBLOCK~!- IMPORTANT, not the same of allowsGravity()~! // this function determines if pieces will landslide it's neighbouring piece to fill bottom blocks) public override bool isSolid(BoardPanel bp) { // your logic here ( if needed ) return(false); }
// if the piece here can be switched around - self explanatory? public override bool isSwitchable(BoardPanel bp) { // your logic here ( if needed ) return(true); }
// for external scripts to call, will indicate that the panel got hit public override bool gotHit(BoardPanel bp) { return(false); // do nothing... }
// for external scripts to call, will indicate that the panel got hit public override bool gotHit(BoardPanel bp) { return(false); }
// if the piece here can be used to form a match public override bool isMatchable(BoardPanel bp) { return(true); }