Beispiel #1
0
 private void HighlightPirate(Label sender, Pirate pirate1)
 {
     if (pirate1.IsNotNull())
     {
         sender.Font = new Font(sender.Font.FontFamily, 6, FontStyle.Bold);
     }
     else
     {
         sender.Font = new Font(sender.Font.FontFamily, 6, FontStyle.Regular);
     }
 }
Beispiel #2
0
        private void GameMove(object sender, MouseEventArgs e)
        {
            if (sender as Label == null)
            {
                return;
            }

            var position   = gameField.GetPositionFromControl((Label)sender);
            var targetCell = field.Cells(position.Column, position.Row);

            if (e.Button == MouseButtons.Right)
            {
                var add = "";

                label1.Text = string.Format("col={0}  row={1} {2}", targetCell.Position.Column, targetCell.Position.Row, add);

                var pirates = field.GetPirates(targetCell);
                if (pirates.Any())
                {
                    label2.Text = string.Format("Pirates {0} {1}", pirates.Count, pirates[0].TeamType);
                }
                else
                {
                    label2.Text = "No Pirates";
                }

                return;
            }


            if (pirate.IsNotNull())
            {
                var changedCells = field.MovePirateTo(pirate, targetCell);

                if (changedCells.NotEmpty())
                {
                    RedrawCells(changedCells);
                }
                else
                {
                    field.SelectPirate(targetCell);
                }

                if (field.CurrentPlayer.CurrentTeam.NoMoreActivePirates())
                {
                    NextPlayer();
                }
            }

            pirate = field.SelectPirate(targetCell);
            HighlightPirate((Label)sender, pirate);
        }