Beispiel #1
0
        public void UcTopPlayers_Load(object sender, EventArgs e)
        {
            string       lista      = "";
            string       listaScore = "";
            List <Score> miLista    = ScoreController.GetScoreList();

            foreach (var fila in miLista)
            {
                lista      += fila.Name;
                lista      += "\n\n";
                listaScore += fila.Scores;
                listaScore += "\n\n";
            }

            lblUsername.Text = lista;
            lblScore.Text    = listaScore;
        }
        //Rutina de rebote de pelota
        private void BounceBall()
        {
            //Rebote de pelota en la parte superior
            if (ball.Top < scoresPanel.Height)
            {
                GameData.dirY = -GameData.dirY;
                return;
            }

            //Pelota se sale de los bounds
            if (ball.Bottom > Height)
            {
                throw new OutOfBoundsException("");
            }

            //Rebote de pelota en lado derecho o izquierdo de la ventana
            if (ball.Left < 0 || ball.Right > Width)
            {
                GameData.dirX = -GameData.dirX;
                return;
            }

            //Rebote con el jugador
            if (ball.Bounds.IntersectsWith(pbPlayer.Bounds))
            {
                GameData.dirY = -GameData.dirY;
                return;
            }

            //Rutina de colisiones con cpb
            for (int i = 5; i >= 0; i--)
            {
                for (int j = 0; j < 10; j++)
                {
                    if (cpb[i, j] != null && ball.Bounds.IntersectsWith(cpb[i, j].Bounds))
                    {
                        GameData.score += (int)(cpb[i, j].Hits * GameData.ticksCount);
                        cpb[i, j].Hits--;

                        if (cpb[i, j].Hits == 0)
                        {
                            Controls.Remove(cpb[i, j]);
                            cpb[i, j] = null;

                            remainingPB--;
                        }
                        else if (cpb[i, j].Tag.Equals("blinded"))
                        {
                            cpb[i, j].BackgroundImage = Image.FromFile("../../../../Sprites/broken.png");
                        }

                        GameData.dirY = -GameData.dirY;

                        score.Text = GameData.score.ToString();

                        if (remainingPB == 0)
                        {
                            timer1.Stop();
                            ScoreController.CreateScore(Pplayer, GameData.score);
                            MessageBox.Show("Has ganado \n Tu puntaje final fue: " + GameData.score, "ArkaNoid", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Hide();
                            FinishGame?.Invoke();
                        }
                        return;
                    }
                }
            }
        }