Пример #1
0
        private SpaceCraft AddEnemy()
        {
            bool isExist;
            //int rndX = 0;
            uint speed    = BL_Random.GetFlySpeed();
            byte rndYShot = BL_Random.GetRndY();
            HashSet <Coordinate> position;

            do
            {
                //rndX = BL_Random.GetX();

                position = InitNewEnemy(BL_Random.GetX());

                isExist = false;

                for (int i = 0; i < _amountOfObjects; i++)
                {
                    if (_gameObjects[i] is EnemyShip enemy)
                    {
                        if (position.Overlaps(enemy.Position) /*!((rndX > enemy.X + enemy.Width) || (rndX + enemy.Width < enemy.X))*/)
                        {
                            isExist = true;
                            break;
                        }
                    }
                }
            } while (isExist);

            return(new EnemyShip(this, position, 0 /*rndX*/, CONST_Y, _active, speed, 1, rndYShot));
        }
Пример #2
0
 public void AddStars()
 {
     for (int i = 0; i < 10; i++)
     {
         _gameObjects[i] = new Star(BL_Random.GetX(), BL_Random.GetY(), 1, 2000);
         ++_amountOfObjects;
     }
 }
Пример #3
0
        private void ResetEnemy(EnemyShip source)
        {
            bool isExist;
            //int rndX = 0;
            uint speed    = BL_Random.GetFlySpeed();
            byte rndYShot = BL_Random.GetRndY();
            HashSet <Coordinate> newPosition;

            do
            {
                //rndX = BL_Random.GetX();

                newPosition = InitNewEnemy(BL_Random.GetX());

                isExist = false;

                for (int i = 0; i < _amountOfObjects; i++)
                {
                    if (_gameObjects[i] is EnemyShip enemy)
                    {
                        if (newPosition.Overlaps(enemy.Position) /*!((rndX > enemy.X + enemy.Width) || (rndX + enemy.Width < enemy.X))*/)
                        {
                            isExist = true;
                            break;
                        }
                    }
                }
            } while (isExist);

            source.Active  = true;
            source.Counter = 0;
            source.HP      = 6;
            source.Position.Clear();
            foreach (var item in newPosition)
            {
                source.Position.Add(new Coordinate(item));
            }
        }