Esempio n. 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void tmrEnergyGain_Tick(object sender, EventArgs e)
 {
     // Player Left
     foreach (PictureBox pbx in lstPlayersLeft)
     {
         CPlayer playerL = dctPbxVSPlayer[pbx];
         // Enerji güncelleniyor
         // Enerji her durumda düþüyor
         if (playerL.Energy < 100)
         {
             playerL.Energy++;
         }
     }
 }
Esempio n. 2
0
        public void fillPlayerInfo(CPlayer player)
        {
            lblPosition.Text      = player.Position.ToString();
            lblTotalDistance.Text = player.TotalDistance.ToString();
            lblGoalScored.Text    = player.nOfGoal.ToString();
            lblnOfShoots.Text     = player.nOfShoot.ToString();
            lblnOfPasses.Text     = player.nOfPass.ToString();
            lblnOfDribblings.Text = player.nOfDribble.ToString();

            tbarSpeed.Value    = (int)player.Speed;
            tbarPriority.Value = (int)player.Priority;
            pbarEnergy.Value   = player.Energy;
            tbarPower.Value    = (int)player.Power;
            chkAlways.Checked  = player.blnAlways;

            selectedPlayer = player;
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void pbx_MouseClick(object sender, MouseEventArgs e)
        {
            PictureBox pbxSender       = sender as PictureBox;
            CPlayer    whoIsThatPlayer = dctPbxVSPlayer[pbxSender];


            // Önce oyunu bi durdur
            tmrGame.Stop();
            tmrBall.Stop();

            // Bilgi ekranýný aç
            F_Info fInfo = new F_Info();

            fInfo.fillPlayerInfo(whoIsThatPlayer);
            fInfo.ShowDialog();

            // Oyunu tekrar aç
            tmrGame.Start();
            tmrBall.Start();
        }
Esempio n. 4
0
        public F_Main()
        {
            InitializeComponent();



            F_Settings fSettings = new F_Settings();

            fSettings.ShowDialog();

            pLeftGK  = fSettings.pLeftGK;
            pLeftLB  = fSettings.pLeftLB;
            pLeftRB  = fSettings.pLeftRB;
            pLeftDMF = fSettings.pLeftDMF;
            pLeftLF  = fSettings.pLeftLF;
            pLeftRF  = fSettings.pLeftRF;


            tmrGame.Interval = 30;
            tmrGame.Tick    += new EventHandler(tmrGame_Tick);
            tmrGame.Start();


            tmrBall.Interval = 30;
            tmrBall.Tick    += new EventHandler(tmrBall_Tick);
            tmrBall.Start();


            tmrGoalScored.Interval = 1000;
            tmrGoalScored.Tick    += new EventHandler(tmrGoalScored_Tick);


            tmrEnergyLoss.Interval = 1000;
            tmrEnergyLoss.Tick    += new EventHandler(tmrEnergyGain_Tick);



            vfnInitializePlayers();



            // P1 oyuncularýný listeye ekle
            lstPlayersLeft.Add(pbxGKLeft);
            lstPlayersLeft.Add(pbxLBLeft);
            lstPlayersLeft.Add(pbxRBLeft);
            lstPlayersLeft.Add(pbxDMFLeft);
            lstPlayersLeft.Add(pbxLFLeft);
            lstPlayersLeft.Add(pbxRFLeft);
            // P1 oyuncularý kütüphanesi
            dctPbxVSPlayer.Add(pbxGKLeft, pLeftGK);
            dctPbxVSPlayer.Add(pbxLBLeft, pLeftLB);
            dctPbxVSPlayer.Add(pbxRBLeft, pLeftRB);
            dctPbxVSPlayer.Add(pbxDMFLeft, pLeftDMF);
            dctPbxVSPlayer.Add(pbxLFLeft, pLeftLF);
            dctPbxVSPlayer.Add(pbxRFLeft, pLeftRF);


            // P2 oyuncularýný listeye ekle
            lstPlayersRight.Add(pbxGKRight);
            lstPlayersRight.Add(pbxLBRight);
            lstPlayersRight.Add(pbxRBRight);
            lstPlayersRight.Add(pbxDMFRight);
            lstPlayersRight.Add(pbxLFRight);
            lstPlayersRight.Add(pbxRFRight);
            // P2 oyuncularý kütüphanesi
            dctPbxVSPlayer.Add(pbxGKRight, pRightGK);
            dctPbxVSPlayer.Add(pbxLBRight, pRightLB);
            dctPbxVSPlayer.Add(pbxRBRight, pRightRB);
            dctPbxVSPlayer.Add(pbxDMFRight, pRightDMF);
            dctPbxVSPlayer.Add(pbxLFRight, pRightLF);
            dctPbxVSPlayer.Add(pbxRFRight, pRightRF);



            foreach (PictureBox var in lstPlayersLeft)
            {
                lstOrgListOfPlayersLeft.Add(var.Location);
            }


            foreach (PictureBox var in lstPlayersRight)
            {
                lstOrgListOfPlayersRight.Add(var.Location);
            }


            // Picturebox eventleri
            foreach (Control cnt in this.Controls)
            {
                if (cnt is PictureBox)
                {
                    PictureBox pbx = cnt as PictureBox;


                    pbx.MouseMove  += new MouseEventHandler(pbx_MouseMove);
                    pbx.MouseLeave += new EventHandler(pbx_MouseLeave);
                    pbx.MouseClick += new MouseEventHandler(pbx_MouseClick);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// OYUN TÝMER FONKSÝYONU
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void tmrGame_Tick(object sender, EventArgs e)
        {
            iValTmrEnergyLoss++;


            Random rnd = new Random();

            // Topa en yakýn oyuncuyu bul ve topa yönlendir
            vfnFindTheClosestPlayer(pbxBall.Location);

            // Tüm oyuncular için default yönelme durumu rastgele olarak ayarlanýyor
            foreach (Control cnt in this.Controls)
            {
                if (cnt is PictureBox)
                {
                    PictureBox pbx = cnt as PictureBox;

                    int off_x = rnd.Next(0, 2);
                    int off_y = rnd.Next(0, 2);

                    // Top haricindeki tüm picturebox bileþenleri futbolcudur
                    if (pbx.Name != pbxBall.Name)
                    {
                        // Topa yönlenme vektörü
                        int devX = pbxBall.Location.X - pbx.Location.X;
                        int devY = pbxBall.Location.Y - pbx.Location.Y;


                        // Kaleciler kaleye yakýn konumlansýn
                        //if (pbx.Name == pbxGKLeft.Name)
                        //{
                        //    devX = (GoalLeft.Bounds.Right) - pbx.Location.X;
                        //    devY = (GoalLeft.Location.Y + GoalLeft.Height / 2) - pbx.Location.Y;

                        //    off_x = 1;
                        //    off_y = 1;

                        //}
                        //// Kaleciler kaleye yakýn konumlansýn
                        //if (pbx.Name == pbxGKRight.Name)
                        //{
                        //    devX = (GoalRight.Bounds.Left - pbx.Width) - pbx.Location.X;
                        //    devY = (GoalRight.Location.Y + GoalRight.Height / 2) - pbx.Location.Y;

                        //    off_x = 1;
                        //    off_y = 1;

                        //}

                        // Topa yakýn olmayan tüm futbolcular topa doðru rand(0,2) kadar yaklaþýyor
                        pbx.Location = new Point(pbx.Location.X + Math.Sign(devX) * off_x, pbx.Location.Y + Math.Sign(devY) * off_y);

                        // Konumlar güncelleniyor
                        vfnUpdateList(pbx);
                    }
                }
            }



            // Hamle için rasgele deðiþken
            Random rndAct  = new Random();
            int    iRndAct = 0;

            // ----------------- PLAYER LEFT ---------------------------------
            //
            #region PLAYER LEFT TIMER EVENTS
            foreach (PictureBox pbx in lstPlayersLeft)
            {
                // Top P1(Left) oyuncularýnda ise
                if (pbx.Bounds.IntersectsWith(pbxBall.Bounds) && blnLeftHasTheBall == false)
                {
                    blnLeftHasTheBall = true;


                    // 0-20 arasýnda rastgele sayý seçiliyor
                    // Öncelik: Shoot ise
                    // 0-10 arasý Shoot
                    // 10-15 arasý Pass
                    // 15-20 arasý Dribbling
                    // always: checked ise 0-20 arasý Shoot

                    bool    rangeShoot = false, rangePass = false, rangeDribbling = false;
                    CPlayer selectedPlayer = dctPbxVSPlayer[pbx];
                    selectedPlayerAtThisMoment = selectedPlayer;
                    iRndAct = rndAct.Next(0, 20);



                    // Eðer kullanýcýnýn oyuncusuna top geldiyse
                    if (pbxUser != null)
                    {
                        if (pbx.Name == pbxUser.Name)
                        {
                            if (blnUserPass)
                            {
                                selectedPlayer.blnAlways = true;
                                selectedPlayer.Priority  = EPriority.Pass;
                            }
                            else if (blnUserShoot)
                            {
                                selectedPlayer.blnAlways = true;
                                selectedPlayer.Priority  = EPriority.Shoot;
                            }
                            else if (blnUserDribble)
                            {
                                selectedPlayer.blnAlways = true;
                                selectedPlayer.Priority  = EPriority.Dribbling;
                            }
                        }
                    }


                    // Önceliðe göre aralýklar belirleniyor
                    switch (selectedPlayer.Priority)
                    {
                    case EPriority.Dribbling:
                        rangeDribbling = (iRndAct < 11);
                        rangePass      = (iRndAct >= 11) && (iRndAct < 16);
                        rangeShoot     = (iRndAct >= 16);

                        if (selectedPlayer.blnAlways)
                        {
                            rangeDribbling = true;
                            rangePass      = rangeShoot = false;
                        }

                        break;

                    case EPriority.Pass:
                        rangePass      = (iRndAct < 11);
                        rangeDribbling = (iRndAct >= 11) && (iRndAct < 16);
                        rangeShoot     = (iRndAct >= 16);

                        if (selectedPlayer.blnAlways)
                        {
                            rangePass      = true;
                            rangeDribbling = rangeShoot = false;
                        }
                        break;

                    case EPriority.Shoot:
                        rangeShoot     = (iRndAct < 11);
                        rangePass      = (iRndAct >= 11) && (iRndAct < 16);
                        rangeDribbling = (iRndAct >= 16);

                        if (selectedPlayer.blnAlways)
                        {
                            rangeShoot     = true;
                            rangeDribbling = rangePass = false;
                        }
                        break;

                    default:
                        break;
                    }



                    // kaleci ile arasýnda rakip yoksa þut çek
                    int nOfRightPlayer = 0, nOfPlayerInTriangle = 0;
                    foreach (PictureBox var in lstPlayersRight)
                    {
                        if (pbx.Bounds.Left > var.Bounds.Left)
                        {
                            nOfRightPlayer++;
                        }

                        if (PointInTriangle(var.Location, pbx.Location, GoalRight.Location, new Point(GoalRight.Location.X, GoalRight.Location.Y + GoalRight.Height)))
                        {
                            nOfPlayerInTriangle++;
                        }
                    }


                    // Geride en az 5 kiþi kalmýþsa VEYA
                    // Kaleyi gördüðü noktada en fazla bir kiþi varsa top sür ya da þut çek
                    if (nOfRightPlayer >= 5 || nOfPlayerInTriangle <= 1)
                    {
                        if (selectedPlayer.Priority != EPriority.Dribbling)
                        {
                            rangeShoot = true;
                        }
                        else
                        {
                            rangeDribbling = true;
                        }
                    }


                    // SHOOT
                    if (rangeShoot)
                    {
                        pbxBall.Location = new Point(pbx.Location.X + pbx.Width, pbx.Location.Y);

                        ballDevX = Math.Sign(GoalRight.Location.X - pbx.Location.X) * 7 * (int)selectedPlayer.Power;
                        ballDevY = Math.Sign((GoalRight.Location.Y + GoalRight.Height / 2) - pbx.Location.Y) * rnd.Next(1, 7) * (int)selectedPlayer.Power;

                        selectedPlayer.nOfShoot++;
                    }
                    // PASS
                    else if (rangePass)
                    {
                        // kendi haricinde rasgele bir takým arkadaþý seçiliyor
                        int rndIdx = rndAct.Next(lstPlayersLeft.Count);
                        if (lstPlayersLeft[rndIdx].Name == pbx.Name)
                        {
                            rndIdx = (rndIdx + 1) % lstPlayersLeft.Count;
                        }

                        int unitVectorX = Math.Sign(lstPlayersLeft[rndIdx].Location.X - pbx.Location.X);
                        int unitVectorY = Math.Sign(lstPlayersLeft[rndIdx].Location.Y - pbx.Location.Y);

                        pbxBall.Location = new Point(pbx.Location.X + pbx.Width * (unitVectorX), pbx.Location.Y + pbx.Height * (unitVectorY));

                        ballDevX = unitVectorX * 4 * (int)selectedPlayer.Power;
                        ballDevY = unitVectorY * 4 * (int)selectedPlayer.Power;

                        selectedPlayer.nOfPass++;
                    }
                    // DRIBBLING
                    else if (rangeDribbling)
                    {
                        int unitVectorX = Math.Sign(GoalRight.Location.X - pbx.Location.X);
                        int unitVectorY = Math.Sign(GoalRight.Location.Y - pbx.Location.Y);

                        pbxBall.Location = new Point(pbx.Location.X + pbx.Width * (unitVectorX), pbx.Location.Y + pbx.Height * (unitVectorY));

                        // Dribbling
                        ballDevX = unitVectorX * rndAct.Next(3, 7);
                        ballDevY = unitVectorY * rndAct.Next(2, 5);

                        selectedPlayer.nOfDribble++;

                        // Belli bir mesafe katedilince þut çek
                        if (pbx.Bounds.Right > this.Width * 4 / 5)
                        {
                            pbxBall.Location = new Point(pbx.Location.X + pbx.Width, pbx.Location.Y);

                            ballDevX = Math.Sign(GoalRight.Location.X - pbx.Location.X) * 7 * (int)selectedPlayer.Power;
                            ballDevY = Math.Sign((GoalRight.Location.Y + GoalRight.Height / 2) - pbx.Location.Y) * rnd.Next(1, 7) * (int)selectedPlayer.Power;

                            selectedPlayer.nOfShoot++;
                        }
                    }
                }
                else
                {
                    blnLeftHasTheBall = false;
                }
            }
            #endregion


            // ----------------- PLAYER RIGHT ---------------------------------
            //


            #region PLAYER RIGHT TIMER EVENTS
            foreach (PictureBox pbx in lstPlayersRight)
            {
                if (pbx.Bounds.IntersectsWith(pbxBall.Bounds) && blnRightHasTheBall == false)
                {
                    blnRightHasTheBall = true;


                    // 0-20 arasýnda rastgele sayý seçiliyor
                    // Öncelik: Shoot ise
                    // 0-10 arasý Shoot
                    // 10-15 arasý Pass
                    // 15-20 arasý Dribbling
                    // always: checked ise 0-20 arasý Shoot

                    bool    rangeShoot = false, rangePass = false, rangeDribbling = false;
                    CPlayer selectedPlayer = dctPbxVSPlayer[pbx];
                    selectedPlayerAtThisMoment = selectedPlayer;
                    iRndAct = rndAct.Next(0, 20);

                    switch (selectedPlayer.Priority)
                    {
                    case EPriority.Dribbling:
                        rangeDribbling = (iRndAct < 11);
                        rangePass      = (iRndAct >= 11) && (iRndAct < 16);
                        rangeShoot     = (iRndAct >= 16);

                        if (selectedPlayer.blnAlways)
                        {
                            rangeDribbling = true;
                            rangePass      = rangeShoot = false;
                        }

                        break;

                    case EPriority.Pass:
                        rangePass      = (iRndAct < 11);
                        rangeDribbling = (iRndAct >= 11) && (iRndAct < 16);
                        rangeShoot     = (iRndAct >= 16);

                        if (selectedPlayer.blnAlways)
                        {
                            rangePass      = true;
                            rangeDribbling = rangeShoot = false;
                        }
                        break;

                    case EPriority.Shoot:
                        rangeShoot     = (iRndAct < 11);
                        rangePass      = (iRndAct >= 11) && (iRndAct < 16);
                        rangeDribbling = (iRndAct >= 16);

                        if (selectedPlayer.blnAlways)
                        {
                            rangeShoot     = true;
                            rangeDribbling = rangePass = false;
                        }
                        break;

                    default:
                        break;
                    }


                    // kaleci ile arasýnda rakip yoksa þut çek
                    int nOfLeftPlayer = 0, nOfPlayerInTriangle = 0;
                    foreach (PictureBox var in lstPlayersLeft)
                    {
                        if (pbx.Bounds.Left < var.Bounds.Left)
                        {
                            nOfLeftPlayer++;
                        }

                        if (PointInTriangle(var.Location, pbx.Location, GoalLeft.Location, new Point(GoalLeft.Location.X, GoalLeft.Location.Y + GoalRight.Height)))
                        {
                            nOfPlayerInTriangle++;
                        }
                    }

                    //Console.WriteLine("nOfLeftPlayer:" + nOfLeftPlayer + "\t PlayerInTriangle: " + nOfPlayerInTriangle);

                    // Geride en az 5 kiþi kalmýþsa þut çek
                    if (nOfLeftPlayer >= 5)
                    {
                        rangeDribbling = true;
                        rangePass      = rangeShoot = false;
                    }

                    // Kaleyi gördüðü noktada en fazla bir kiþi varsa þut çek
                    if (nOfPlayerInTriangle <= 1)
                    {
                        rangeShoot = true;
                    }


                    // SHOOT
                    if (rangeShoot)
                    {
                        pbxBall.Location = new Point(pbx.Location.X - pbx.Width, pbx.Location.Y);

                        ballDevX = Math.Sign(GoalLeft.Location.X - pbx.Location.X) * 7 * (int)selectedPlayer.Power;
                        ballDevY = Math.Sign((GoalLeft.Location.Y + GoalLeft.Height / 2) - pbx.Location.Y) * rnd.Next(1, 7) * (int)selectedPlayer.Power;


                        selectedPlayer.nOfShoot++;
                    }

                    // PASS
                    else if (rangePass)
                    {
                        int rndIdx = rndAct.Next(lstPlayersRight.Count);
                        if (lstPlayersRight[rndIdx].Name == pbx.Name)
                        {
                            rndIdx = (rndIdx + 1) % lstPlayersRight.Count;
                        }

                        int unitVectorX = Math.Sign(lstPlayersRight[rndIdx].Location.X - pbx.Location.X);
                        int unitVectorY = Math.Sign(lstPlayersRight[rndIdx].Location.Y - pbx.Location.Y);

                        pbxBall.Location = new Point(pbx.Location.X + pbx.Width * (unitVectorX), pbx.Location.Y + pbx.Height * (unitVectorY));

                        ballDevX = unitVectorX * 4 * (int)selectedPlayer.Power;
                        ballDevY = unitVectorY * 4 * (int)selectedPlayer.Power;

                        selectedPlayer.nOfPass++;
                    }

                    // DRIBBLING
                    else if (rangeDribbling)
                    {
                        int unitVectorX = Math.Sign(GoalLeft.Location.X - pbx.Location.X);
                        int unitVectorY = Math.Sign(GoalLeft.Location.Y - pbx.Location.Y);

                        pbxBall.Location = new Point(pbx.Location.X + pbx.Width * (unitVectorX), pbx.Location.Y + pbx.Height * (unitVectorY));

                        // Dribbling
                        ballDevX = unitVectorX * rndAct.Next(3, 7);
                        ballDevY = unitVectorY * rndAct.Next(2, 5);

                        selectedPlayer.nOfDribble++;

                        // Belli bir mesafe katedilince þut çek
                        if (pbx.Bounds.Left < this.Width * 1 / 5)
                        {
                            pbxBall.Location = new Point(pbx.Location.X - pbx.Width, pbx.Location.Y);

                            ballDevX = Math.Sign(GoalLeft.Location.X - pbx.Location.X) * 7 * (int)selectedPlayer.Power;
                            ballDevY = Math.Sign((GoalLeft.Location.Y + GoalLeft.Height / 2) - pbx.Location.Y) * rnd.Next(1, 7) * (int)selectedPlayer.Power;

                            selectedPlayer.nOfShoot++;
                        }
                    }
                }
                else
                {
                    blnRightHasTheBall = false;
                }
            }
            #endregion


            // Direkten dönme durumu
            if (pbxBall.Bounds.IntersectsWith(lblLeftPost1.Bounds))
            {
                lblLeftPost1.BackColor = Color.White;
            }
            else
            {
                lblLeftPost1.BackColor = Color.ForestGreen;
            }

            if (pbxBall.Bounds.IntersectsWith(lblLeftPost2.Bounds))
            {
                lblLeftPost2.BackColor = Color.White;
            }
            else
            {
                lblLeftPost2.BackColor = Color.ForestGreen;
            }


            if (pbxBall.Bounds.IntersectsWith(lblRightPost1.Bounds))
            {
                lblRightPost1.BackColor = Color.White;
            }
            else
            {
                lblRightPost1.BackColor = Color.SteelBlue;
            }

            if (pbxBall.Bounds.IntersectsWith(lblRightPost2.Bounds))
            {
                lblRightPost2.BackColor = Color.White;
            }
            else
            {
                lblRightPost2.BackColor = Color.SteelBlue;
            }



            // Gol olma durumu (Right Scored)
            //if (pbxBall.Bounds.IntersectsWith(GoalLeft.Bounds))
            //if (pbxBall.Bounds.Right < GoalLeft.Bounds.Left)
            if (pbxBall.Bounds.Right < lblLeftBound.Bounds.Left)
            {
                blnGoalScored = true;
                FSK           = 2;

                //ballDevX = 0;
                //ballDevY = 0;
                //pbxBall.Location = new Point(GoalLeft.Bounds.Right + 1, pbxBall.Location.Y);
                //pbxBall.Location = new Point(this.Width/2, this.Height/2);

                //GoalLeft.BackColor = Color.Red;

                rightScored++;
                selectedPlayerAtThisMoment.nOfGoal++;

                lblScoreLeft.Text  = leftScored.ToString();
                lblScoreRight.Text = rightScored.ToString();
                lblGoal.ForeColor  = Color.SteelBlue;
                lblGoal.Visible    = true;

                tmrGame.Stop();
                tmrGoalScored.Start();
            }
            else
            {
                GoalLeft.BackColor = Color.Transparent;
            }

            // Gol olma durumu (Left Scored)
            //if (pbxBall.Bounds.IntersectsWith(GoalRight.Bounds))
            //if (pbxBall.Bounds.Left > GoalRight.Bounds.Right)
            if (pbxBall.Bounds.Left > lblRightBound.Bounds.Right)
            {
                blnGoalScored = true;
                FSK           = 2;

                //ballDevX = 0;
                //ballDevY = 0;
                //pbxBall.Location = new Point(GoalRight.Bounds.Left - pbxBall.Width - 1, pbxBall.Location.Y);


                //GoalRight.BackColor = Color.Red;

                leftScored++;
                selectedPlayerAtThisMoment.nOfGoal++;

                lblScoreLeft.Text  = leftScored.ToString();
                lblScoreRight.Text = rightScored.ToString();
                lblGoal.ForeColor  = Color.ForestGreen;
                lblGoal.Visible    = true;

                tmrGame.Stop();
                tmrGoalScored.Start();
            }
            else
            {
                GoalRight.BackColor = Color.Transparent;
            }



            this.Update();
        }
Esempio n. 6
0
 public void setLF(CPlayer p)
 {
     pLeftLF = p;
 }
Esempio n. 7
0
 public void setRF(CPlayer p)
 {
     pLeftRF = p;
 }
Esempio n. 8
0
 public void setDMF(CPlayer p)
 {
     pLeftDMF = p;
 }
Esempio n. 9
0
 public void setRB(CPlayer p)
 {
     pLeftRB = p;
 }
Esempio n. 10
0
 public void setLB(CPlayer p)
 {
     pLeftLB = p;
 }
Esempio n. 11
0
 public void setGK(CPlayer p)
 {
     pLeftGK = p;
 }
Esempio n. 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        private void vfnFindTheClosestPlayer(Point ptBall)
        {
            int minLeft = int.MaxValue, minRight = int.MaxValue, minIdxLeft = 0, minIdxRight = 0;


            // Left
            for (int i = 0; i < lstPlayersLeft.Count; i++)
            {
                int dist = (ptBall.X - lstPlayersLeft[i].Location.X) * (ptBall.X - lstPlayersLeft[i].Location.X) +
                           (ptBall.Y - lstPlayersLeft[i].Location.Y) * (ptBall.Y - lstPlayersLeft[i].Location.Y);

                if (dist < minLeft)
                {
                    minLeft    = dist;
                    minIdxLeft = i;
                }
            }

            // Right
            for (int i = 0; i < lstPlayersLeft.Count; i++)
            {
                int dist = (ptBall.X - lstPlayersRight[i].Location.X) * (ptBall.X - lstPlayersRight[i].Location.X) +
                           (ptBall.Y - lstPlayersRight[i].Location.Y) * (ptBall.Y - lstPlayersRight[i].Location.Y);

                if (dist < minRight)
                {
                    minRight    = dist;
                    minIdxRight = i;
                }
            }


            // Calculate for LEFT
            int devX = ptBall.X - lstPlayersLeft[minIdxLeft].Location.X;
            int devY = ptBall.Y - lstPlayersLeft[minIdxLeft].Location.Y;

            CPlayer selectedPlayer = dctPbxVSPlayer[lstPlayersLeft[minIdxLeft]];
            int     speedVal       = (int)selectedPlayer.Speed + 1;

            lstPlayersLeft[minIdxLeft].Location = new Point(lstPlayersLeft[minIdxLeft].Location.X + Math.Sign(devX) * speedVal, lstPlayersLeft[minIdxLeft].Location.Y + Math.Sign(devY) * speedVal);
            selectedPlayer.TotalDistance       += (ulong)((Math.Abs(devX) + Math.Abs(devY)) / 100);


            // Enerji güncelleniyor
            // Enerji bu durumda hýz oranýnda düþüyor
            int energyLoss = (int)selectedPlayer.TotalDistance / 1000;

            if (selectedPlayer.Energy > energyLoss)
            {
                selectedPlayer.Energy = 100 - energyLoss;
            }

            selectedPlayer.Power = (EPower)(int)(selectedPlayer.Energy / 34 + 1);


            if (selectedPlayer.TotalDistance == ulong.MaxValue)
            {
                selectedPlayer.TotalDistance = 0;
            }


            // Calculate for RIGHT
            devX = ptBall.X - lstPlayersRight[minIdxRight].Location.X;
            devY = ptBall.Y - lstPlayersRight[minIdxRight].Location.Y;

            selectedPlayer = dctPbxVSPlayer[lstPlayersRight[minIdxRight]];
            speedVal       = (int)selectedPlayer.Speed + 1;

            lstPlayersRight[minIdxRight].Location = new Point(lstPlayersRight[minIdxRight].Location.X + Math.Sign(devX) * speedVal, lstPlayersRight[minIdxRight].Location.Y + Math.Sign(devY) * speedVal);
            selectedPlayer.TotalDistance         += (ulong)((Math.Abs(devX) + Math.Abs(devY)) / 100);

            if (selectedPlayer.TotalDistance == ulong.MaxValue)
            {
                selectedPlayer.TotalDistance = 0;
            }
        }