示例#1
0
        public void BulletsMove(List <BulletEngine> bullets, MapBase map)
        {
            for (var i = 0; i < bullets.Count; i++)
            {
                if (BulletNearWall(bullets[i], map.GameMap))

                #region BulletNearWall

                {
                    switch (bullets[i].Direction)
                    {
                    case MoveDirection.Up:
                        map.MapPointDelete(bullets[i].Y - 1, bullets[i].X - 1);
                        map.MapPointDelete(bullets[i].Y - 1, bullets[i].X);
                        map.MapPointDelete(bullets[i].Y - 1, bullets[i].X + 1);
                        break;

                    case MoveDirection.Down:
                        map.MapPointDelete(bullets[i].Y + 1, bullets[i].X - 1);
                        map.MapPointDelete(bullets[i].Y + 1, bullets[i].X);
                        map.MapPointDelete(bullets[i].Y + 1, bullets[i].X + 1);
                        break;

                    case MoveDirection.Left:
                        map.MapPointDelete(bullets[i].Y - 1, bullets[i].X - 1);
                        map.MapPointDelete(bullets[i].Y, bullets[i].X - 1);
                        map.MapPointDelete(bullets[i].Y + 1, bullets[i].X - 1);
                        break;

                    case MoveDirection.Right:
                        map.MapPointDelete(bullets[i].Y - 1, bullets[i].X + 1);
                        map.MapPointDelete(bullets[i].Y, bullets[i].X + 1);
                        map.MapPointDelete(bullets[i].Y + 1, bullets[i].X + 1);
                        break;
                    }
                    OnBulletErase(bullets[i]);
                    BulletDeleteFromMap(bullets[i], map);
                    bullets.Remove(bullets[i]);
                    break;
                }

                #endregion

                if (!BulletNearBorder(bullets[i], map.Borders))

                #region BulletNearBorder

                {
                    OnBulletErase(bullets[i]);
                    BulletDeleteFromMap(bullets[i], map);
                    switch (bullets[i].Direction)
                    {
                    case MoveDirection.Up:
                        BulletMoveUp(bullets[i]);
                        break;

                    case MoveDirection.Down:
                        BulletMoveDown(bullets[i]);
                        break;

                    case MoveDirection.Left:
                        BulletMoveLeft(bullets[i]);
                        break;

                    case MoveDirection.Right:
                        BulletMoveRight(bullets[i]);
                        break;
                    }
                    OnBulletDraw(bullets[i]);
                    BulletCreateOnMap(bullets[i], map);
                }
                else
                {
                    OnBulletErase(bullets[i]);
                    BulletDeleteFromMap(bullets[i], map);
                    bullets.Remove(bullets[i]);
                }

                #endregion
            }
        }