예제 #1
0
        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));
        }
예제 #2
0
    // 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);
    }
예제 #3
0
    // 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);
 }
예제 #5
0
    // 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
    }
예제 #6
0
    // 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);
    }
예제 #7
0
        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);
        }
예제 #8
0
    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;
    }
예제 #9
0
        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));
        }
예제 #10
0
    // 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
    }
예제 #11
0
        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();
        }
예제 #12
0
        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);
        }
예제 #13
0
 // optional onPanelClicked function when panel is clicked
 public override void onPanelClicked(BoardPanel bp)
 {
     // default does nothing...
 }
예제 #14
0
 // optional onBoardStabilize called by GameManager when board stabilize and gets a suggestion
 public override void onBoardStabilize(BoardPanel bp)
 {
     // default does nothing...
 }
예제 #15
0
 // optional onPlayerMove called by GameManager when player makes the next move
 public override void onPlayerMove(BoardPanel bp)
 {
     // default does nothing...
 }
예제 #16
0
 // 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...
 }
예제 #17
0
 // if the piece here can be switched around
 public override bool isSwitchable(BoardPanel bp)
 {
     return(false);
 }
예제 #18
0
 // 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);
 }
예제 #19
0
 // function to play the audio visuals of this panel
 public override void playAudioVisuals(BoardPanel bp)
 {
     // nothing...
 }
예제 #20
0
 // 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...
 }
예제 #21
0
 // 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);
 }
예제 #22
0
 // function to check if this board needs to be filled by gravity
 public override bool isFillable(BoardPanel bp)
 {
     return(false);
 }
예제 #23
0
 // function to check if pieces can be stolen from this box by gravity
 public override bool isStealable(BoardPanel bp)
 {
     return(true);
 }
예제 #24
0
 // if the piece here (if any) can be destroyed
 public override bool isDestructible(BoardPanel bp)
 {
     return(true);
 }
예제 #25
0
 // if the piece here (if any) can be destroyed / Matched
 public override bool isDestructible(BoardPanel bp)
 {
     // your logic here ( if needed )
     return(true);
 }
예제 #26
0
 // 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);
 }
예제 #27
0
 // if the piece here can be switched around - self explanatory?
 public override bool isSwitchable(BoardPanel bp)
 {
     // your logic here ( if needed )
     return(true);
 }
예제 #28
0
 // for external scripts to call, will indicate that the panel got hit
 public override bool gotHit(BoardPanel bp)
 {
     return(false);        // do nothing...
 }
예제 #29
0
 // for external scripts to call, will indicate that the panel got hit
 public override bool gotHit(BoardPanel bp)
 {
     return(false);
 }
예제 #30
0
 // if the piece here can be used to form a match
 public override bool isMatchable(BoardPanel bp)
 {
     return(true);
 }