Inheritance: System.Entity, ICloneable
示例#1
0
        private void Reset()
        {
            MoverManager.movers.Clear();

            _mainPartIsDead = false;
            _ready          = true;
            _timer          = Config.BossInitialTimer;

            if (_previousBossPart == null)
            {
                _mainPart = new BossPart(
                    _gameRef, this, _players, MoverManager, _completeBulletPatterns, new Color(0f, 0.75f, 0f, 0.65f),
                    4242f, _iteration, _step, null, null, true
                    );

                _mainPart.Initialize();
            }
            else
            {
                _mainPart = _previousBossPart;
                _mainPart.IterateStructure(_iteration);
            }

            _previousBossPart = (BossPart)_mainPart.Clone();

            _parts.Add(_mainPart);

            int targetPlayerId = _gameRef.Rand.Next(0, _players.Count);

            _core = new BossCore(_gameRef, _mainPart, _players[targetPlayerId].GetPosition, MoverManager, _completeBulletPatterns);
            _core.Initialize();
        }
示例#2
0
        public Boss(DnK gameRef, List<Player> players, int iteration = 50, float step = 25)
        {
            _gameRef = gameRef;
            _defeatCounter = 0;
            MoverManager = new MoverManager(gameRef);
            GameManager.GameDifficulty = Config.GameDifficultyDelegate;
            _players = players;
            _iteration = iteration;
            _step = step;
            _previousBossPart = null;

            _parts = new List<BossPart>();
            _currentPartIndex = 0;

            int targetPlayerId = _gameRef.Rand.Next(0, _players.Count);
            MoverManager.Initialize(_players[targetPlayerId].GetPosition);
        }
示例#3
0
        public Boss(DnK gameRef, List <Player> players, int iteration = 50, float step = 25)
        {
            _gameRef                   = gameRef;
            _defeatCounter             = 0;
            MoverManager               = new MoverManager(gameRef);
            GameManager.GameDifficulty = Config.GameDifficultyDelegate;
            _players                   = players;
            _iteration                 = iteration;
            _step             = step;
            _previousBossPart = null;

            _parts            = new List <BossPart>();
            _currentPartIndex = 0;

            int targetPlayerId = _gameRef.Rand.Next(0, _players.Count);

            MoverManager.Initialize(_players[targetPlayerId].GetPosition);
        }
示例#4
0
        private void Reset()
        {
            MoverManager.movers.Clear();

            _mainPartIsDead = false;
            _ready = true;
            _timer = Config.BossInitialTimer;

            if (_previousBossPart == null)
            {
                _mainPart = new BossPart(
                    _gameRef, this, _players, MoverManager, _completeBulletPatterns, new Color(0f, 0.75f, 0f, 0.65f),
                    4242f, _iteration, _step, null, null, true
                );

                _mainPart.Initialize();
            }
            else
            {
                _mainPart = _previousBossPart;
                _mainPart.IterateStructure(_iteration);
            }

            _previousBossPart = (BossPart)_mainPart.Clone();

            _parts.Add(_mainPart);

            int targetPlayerId = _gameRef.Rand.Next(0, _players.Count);
            _core = new BossCore(_gameRef, _mainPart, _players[targetPlayerId].GetPosition, MoverManager, _completeBulletPatterns);
            _core.Initialize();
        }
示例#5
0
        private void Split(CollisionConvexPolygon box)
        {
            var newPolygonShape = _structure.Split(box);
            var center = box.GetCenterInWorldSpace();

            // TODO: Part is dead?
            // A boss part is dead when its center is dead?
            // or when the number of sub-parts is less than a number?
            if (center.X > (Size.X / 2f - 2 * _step) + Position.X - Origin.X &&
                center.X < (Size.X / 2f + 2 * _step) + Position.X - Origin.X)
            {
                TakeDamage(99999);
            }
            else
            {
                var boxLocalPosition = box.GetLocalPosition();

                // Left (1) or right (-1) part?
                var factor = (boxLocalPosition.X > Origin.X) ? 1 : -1;

                // If the break out part is not large enough => we don't create another part
                if (newPolygonShape.Vertices != null && newPolygonShape.GetArea() > Config.MinBossPartArea)
                {
                    var bossPart = new BossPart(
                        GameRef, _bossRef, _players, _moverManager, null, _color,
                        _health, 0, 25f, null, newPolygonShape
                    );

                    bossPart.Initialize();

                    var bossPartSize = newPolygonShape.GetSize();
                    var boxWorldPosition = box.GetWorldPosition();

                    // Compute new boss part's world position
                    var worldPosition = Vector2.Zero;
                    worldPosition.Y = boxWorldPosition.Y - boxLocalPosition.Y;

                    // Left part
                    if (factor == 1)
                        worldPosition.X = boxWorldPosition.X - bossPartSize.X;
                    // Right part
                    else if (factor == -1)
                        worldPosition.X = boxWorldPosition.X + _step;

                    // Update world position according to parent rotation
                    bossPart.Scale = Scale;
                    bossPart.Rotation = Rotation;

                    var newLocalPosition = Vector2.Zero;
                    newLocalPosition.X = (Position.X - Origin.X) + (boxLocalPosition.X);
                    newLocalPosition.Y = (Position.Y - Origin.Y);

                    if (factor == -1)
                        newLocalPosition.X -= bossPartSize.X;
                    else
                        newLocalPosition.X += _step;

                    var newOrigin = newPolygonShape.GetCenter();
                    newLocalPosition += newOrigin;

                    var rotationOrigin = Position;
                    newLocalPosition = Vector2.Transform(newLocalPosition - rotationOrigin, Matrix.CreateRotationZ(Rotation)) + rotationOrigin;

                    bossPart.Origin = newOrigin;
                    bossPart.Position = newLocalPosition;
                    _bossRef.Parts.Add(bossPart);

                    // Give to this new BossPart an impulsion to (pseudo) random direction due to explosion
                    var random = (float)(GameRef.Rand.NextDouble() * (1f - 0.75f)) + 0.75f;
                    bossPart.ApplyImpulse(new Vector2(factor, random * factor), new Vector2(random / 5f));
                    ApplyImpulse(new Vector2(-factor, random * -factor), new Vector2(random / 5f));
                }

                // Remove destroyed bounding boxes
                if (factor == -1)
                    CollisionBoxes.RemoveAll(bb => bb.GetCenter().X < boxLocalPosition.X);
                else
                    CollisionBoxes.RemoveAll(bb => bb.GetCenter().X > boxLocalPosition.X);

                // This is the bounding that the player has destroyed, so we remove it from the list
                CollisionBoxes.Remove(box);
            }
        }
示例#6
0
        private void Split(CollisionConvexPolygon box)
        {
            var newPolygonShape = _structure.Split(box);
            var center          = box.GetCenterInWorldSpace();

            // TODO: Part is dead?
            // A boss part is dead when its center is dead?
            // or when the number of sub-parts is less than a number?
            if (center.X > (Size.X / 2f - 2 * _step) + Position.X - Origin.X &&
                center.X < (Size.X / 2f + 2 * _step) + Position.X - Origin.X)
            {
                TakeDamage(99999);
            }
            else
            {
                var boxLocalPosition = box.GetLocalPosition();

                // Left (1) or right (-1) part?
                var factor = (boxLocalPosition.X > Origin.X) ? 1 : -1;

                // If the break out part is not large enough => we don't create another part
                if (newPolygonShape.Vertices != null && newPolygonShape.GetArea() > Config.MinBossPartArea)
                {
                    var bossPart = new BossPart(
                        GameRef, _bossRef, _players, _moverManager, null, _color,
                        _health, 0, 25f, null, newPolygonShape
                        );

                    bossPart.Initialize();

                    var bossPartSize     = newPolygonShape.GetSize();
                    var boxWorldPosition = box.GetWorldPosition();

                    // Compute new boss part's world position
                    var worldPosition = Vector2.Zero;
                    worldPosition.Y = boxWorldPosition.Y - boxLocalPosition.Y;

                    // Left part
                    if (factor == 1)
                    {
                        worldPosition.X = boxWorldPosition.X - bossPartSize.X;
                    }
                    // Right part
                    else if (factor == -1)
                    {
                        worldPosition.X = boxWorldPosition.X + _step;
                    }

                    // Update world position according to parent rotation
                    bossPart.Scale    = Scale;
                    bossPart.Rotation = Rotation;

                    var newLocalPosition = Vector2.Zero;
                    newLocalPosition.X = (Position.X - Origin.X) + (boxLocalPosition.X);
                    newLocalPosition.Y = (Position.Y - Origin.Y);

                    if (factor == -1)
                    {
                        newLocalPosition.X -= bossPartSize.X;
                    }
                    else
                    {
                        newLocalPosition.X += _step;
                    }

                    var newOrigin = newPolygonShape.GetCenter();
                    newLocalPosition += newOrigin;

                    var rotationOrigin = Position;
                    newLocalPosition = Vector2.Transform(newLocalPosition - rotationOrigin, Matrix.CreateRotationZ(Rotation)) + rotationOrigin;

                    bossPart.Origin   = newOrigin;
                    bossPart.Position = newLocalPosition;
                    _bossRef.Parts.Add(bossPart);

                    // Give to this new BossPart an impulsion to (pseudo) random direction due to explosion
                    var random = (float)(GameRef.Rand.NextDouble() * (1f - 0.75f)) + 0.75f;
                    bossPart.ApplyImpulse(new Vector2(factor, random * factor), new Vector2(random / 5f));
                    ApplyImpulse(new Vector2(-factor, random * -factor), new Vector2(random / 5f));
                }

                // Remove destroyed bounding boxes
                if (factor == -1)
                {
                    CollisionBoxes.RemoveAll(bb => bb.GetCenter().X < boxLocalPosition.X);
                }
                else
                {
                    CollisionBoxes.RemoveAll(bb => bb.GetCenter().X > boxLocalPosition.X);
                }

                // This is the bounding that the player has destroyed, so we remove it from the list
                CollisionBoxes.Remove(box);
            }
        }