Пример #1
0
        public GameField()
        {
            InitializeComponent();
            Id = Guid.NewGuid();
            Items.Add(Id, this);

            Start = new StartForm(this);
            Start.ShowDialog();

            if (Start.IsFinish)
                return;

            SetNames(Start);
            SetScore();
            ShowPlayers(Start);
            lblActivePlayer.Text = Player.GetByActiveIndex(Game.ActivePlayer) + "!";

            Sector sector;
            foreach (var sec in Game.SectorMatrix)
            {
                sector = new Sector(Game, sec);
                Controls.Add(sector);
                sector.MouseClick += OnSectorMouseClick;
                foreach (var ball in Sector.BallMatrix)
                {
                    BallPoint bp = new BallPoint(sector, ball);
                    bp.Click += OnBallPointClick;
                    sector.Controls.Add(bp);
                }
            }
            IsBallNotSector = true;
            MinimumSize = new Size(SectorCount * FieldStep + FieldLeft, SectorCount * FieldStep + FieldTop);
        }
Пример #2
0
 public Player(Game game,string name, BallPoint.BallColor color)
 {
     Id = Guid.NewGuid();
     Name = name;
     PlayerColor = color;
     HorizLine = 0;
     MaxHLine = 0;
     VertLine = 0;
     MaxVLine = 0;
     DiagLeftLine = 0;
     MaxDLLine = 0;
     DiagRightLine = 0;
     MaxDRLine = 0;
     Items.Add(Id, this);
 }
Пример #3
0
 private void CreatePlayer(string name, BallPoint.BallColor color, int count)
 {
     Player player = new Player(this, name, color);
     AddPlayer(player);
     player.ActiveIndex = count;
 }
Пример #4
0
 private void CheckLine(BallPoint ball, BallPoint prevball, string dimention)
 {
     Player player = Player.GetByColor(prevball.PointColor);
     if (ball.PointColor == prevball.PointColor)
     {
         if (prevball.PointColor != BallPoint.BallColor.white) //оба одинаковые цветные
             IncLine(player, dimention);
     } //оба белые игнорируем
     else //ball.PointColor != currPlayer.PlayerColor
     {
         if (ball.PointColor == BallPoint.BallColor.white) //текущий белый, предыдущий цветной
         {
             SetLineToZero(player, dimention);
             player = Player.GetByName("WhiteBalls");
         }
         else //ball.PointColor != BallPoint.BallColor.white //оба разные и текущий цветной
         {
             if (player.Name != "WhiteBalls") //оба цветные
                 SetLineToZero(player, dimention);
             player = ball.Player;
             IncLine(player, dimention);
         }
     }
     return; //player;
 }
Пример #5
0
 public static Player GetByColor(BallPoint.BallColor color)
 {
     foreach (var player in Items.Values)
         if (player.PlayerColor == color)
             return player;
     return null;
 }