コード例 #1
0
ファイル: BL.cs プロジェクト: SlavaSotnikov/LevelUpHW
        public static void Shooting(ref Cartridge shipMag, ref Spacecraft ship)
        {
            Shot left  = CreateLeftShot(ref ship);
            Shot right = CreateRightShot(ref ship);

            AddShotToMag(ref shipMag, left, right);
        }
コード例 #2
0
ファイル: BL.cs プロジェクト: SlavaSotnikov/LevelUpHW
        public static void CheckAllObjects(ref Cartridge source, ref Swarm enemies, ref Display battle, GameField borders)
        {
            CheckShot(ref source, borders);

            CheckFly(ref enemies, ref battle, borders);

            ShotAndFlyProcessing(ref enemies, ref source, ref battle);
        }
コード例 #3
0
ファイル: BL.cs プロジェクト: SlavaSotnikov/LevelUpHW
 public static void CheckShot(ref Cartridge source, GameField borders)
 {
     for (int i = 0; i < source.countOfShots; i++)
     {
         if (source.mag[i].coordinateY <= borders.top)
         {
             source.mag[i].active = false;
         }
     }
 }
コード例 #4
0
ファイル: BL.cs プロジェクト: SlavaSotnikov/LevelUpHW
        public static void AddShotToMag(ref Cartridge source, Shot left, Shot right)
        {
            if (source.countOfShots < source.mag.Length)
            {
                source.mag[source.countOfShots] = left;
                ++source.countOfShots;

                source.mag[source.countOfShots] = right;
                ++source.countOfShots;
            }
        }
コード例 #5
0
ファイル: BL.cs プロジェクト: SlavaSotnikov/LevelUpHW
        public static Cartridge CreateCartridge(int capacity)
        {
            Cartridge clip = new Cartridge
            {
                mag                    = new Shot[capacity],
                countOfShots           = 0,
                methodCounterPrintShot = 0,
            };

            return(clip);
        }
コード例 #6
0
ファイル: UI.cs プロジェクト: SlavaSotnikov/LevelUpHW
        public static void ShowHideShots(ref Shot bullet, ref Cartridge source, int i)
        {
            HideBullet(bullet);

            if (bullet.active)
            {
                BL.ModifyBulletCoordinate(ref bullet);

                PrintBullet(bullet);

                bullet.oldCoordinateX = bullet.coordinateX;
                bullet.oldCoordinateY = bullet.coordinateY;
            }
        }
コード例 #7
0
ファイル: UI.cs プロジェクト: SlavaSotnikov/LevelUpHW
        public static void PrintShots(ref Cartridge source)
        {
            for (int i = 0; i < source.countOfShots; i++)
            {
                ++source.mag[i].counter;

                if (source.mag[i].counter % source.mag[i].speed == 0)
                {
                    source.mag[i].counter = RESET;

                    ShowHideShots(ref source.mag[i], ref source, i);
                }
            }
        }
コード例 #8
0
ファイル: BL.cs プロジェクト: SlavaSotnikov/LevelUpHW
        public static void CleanMag(ref Cartridge source)
        {
            for (int i = 0; i < source.countOfShots; i++)
            {
                if (source.mag[i].counter % source.mag[i].speed == 0)
                {
                    while (!source.mag[i].active && source.countOfShots > 0)
                    {
                        for (int j = i; j < source.countOfShots - 1; j++)
                        {
                            source.mag[j] = source.mag[j + 1];
                        }

                        --source.countOfShots;
                    }
                }
            }
        }
コード例 #9
0
ファイル: BL.cs プロジェクト: SlavaSotnikov/LevelUpHW
        public static void ShotAndFlyProcessing(ref Swarm enemies, ref Cartridge source, ref Display battle)
        {
            for (int i = 0; i < enemies.countOfFly; i++)
            {
                for (int j = 0; j < source.countOfShots; j++)
                {
                    if (IsHit(enemies.enemyFly[i], source.mag[j]))
                    {
                        if (source.mag[j].active)
                        {
                            source.mag[j].active     = false;
                            enemies.enemyFly[i].hit += 1;

                            if (enemies.enemyFly[i].hit >= HITS)
                            {
                                enemies.enemyFly[i].active = false;
                                battle.killed += 1;
                                //battle.enemies -= 1;
                            }
                        }
                    }
                }
            }
        }
コード例 #10
0
ファイル: BL.cs プロジェクト: SlavaSotnikov/LevelUpHW
        public static void CleanDataStructures(ref Swarm enemies, ref Cartridge shipMag)
        {
            CleanSwarm(ref enemies);

            CleanMag(ref shipMag);
        }
コード例 #11
0
ファイル: BL.cs プロジェクト: SlavaSotnikov/LevelUpHW
        /// <summary>
        /// It alters the coordinates X or Y.
        /// </summary>
        /// <param name="borders">Geme field size.</param>
        /// <param name="userAction">User direction enum from console.</param>
        /// <param name="coordinateX">Reference to X coordinate.</param>
        /// <param name="coordinateY">Reference to Y coordinate.</param>
        public static void EventProcessing(ref Spacecraft ship, GameField borders, Actions userAction, ref Cartridge shipMag)
        {
            switch (userAction)
            {
            case Actions.LeftMove:
                --ship.сoordinateX;
                if (ship.сoordinateX <= borders.left)
                {
                    ship.сoordinateX = borders.left;
                }
                break;

            case Actions.RightMove:
                ++ship.сoordinateX;
                if (ship.сoordinateX >= borders.right)
                {
                    ship.сoordinateX = borders.right;
                }
                break;

            case Actions.UpMove:
                --ship.сoordinateY;
                if (ship.сoordinateY <= borders.top)
                {
                    ship.сoordinateY = borders.top;
                }
                break;

            case Actions.DownMove:
                ++ship.сoordinateY;
                if (ship.сoordinateY >= borders.bottom)
                {
                    ship.сoordinateY = borders.bottom;
                }
                break;

            case Actions.Shooting:
                Shooting(ref shipMag, ref ship);
                break;

            default:
                break;
            }
        }