Ejemplo n.º 1
0
        // aktualizace výstřely
        void UpdateShots(List <Shot> shots)
        {
            for (int k = shots.Count - 1; k >= 0; k--)
            {
                Shot shot = shots[k];

                for (int j = 0; j < shot.cells.GetLength(1); j++)
                {
                    for (int i = 0; i < shot.cells.GetLength(0) - 1; i++)
                    {
                        shot.cells[i, j] = shot.cells[i + 1, j];
                    }
                }

                for (int j = 0; j < shot.cells.GetLength(1); j++)
                {
                    shot.cells[shot.cells.GetLength(0) - 1, j] = shot.cells[0, shot.cells.GetLength(1) - 1 - j];
                }

                if (shot.status > 0)
                {
                    shot.status--;

                    if (shot.status == 0)
                    {
                        shots.RemoveAt(k);
                    }
                    else
                    {
                        shots[k] = shot;
                    }

                    return;
                }

                // pokud výstřel dosáhl konce
                if (shot.y < 1)
                {
                    shot.status = 5;
                    shot.cells  = shotEndCells;
                    shot.color  = shotEndColor;
                    shot.x     -= shotEndCells.GetLength(1) / 2;

                    shots[k] = shot;
                }
                else if (shot.y >= gameHeight - alienShotCells.GetLength(0))   // pokud výstřel vetřelcu dosáhl konce
                {
                    shot.status = 10;
                    shot.cells  = alienShotEndCells;
                    shot.color  = alienShotEndColor;
                    shot.x     -= alienShotEndCells.GetLength(1) / 2;

                    shots[k] = shot;
                }
                else
                {
                    shot.y += shot.dy;

                    shots[k] = shot;
                }
            }
        }