Beispiel #1
0
        public virtual void Reset()
        {
            Clear();

            Game.SpriteBatchManager.Boss = this;
            InitializePhysics();

            foreach (var behaviour in Behaviours)
            {
                behaviour.Reset();
            }

            _randomPosition             = false;
            _randomPositionLongDistance = false;
            RandomMovingArea            = new Rectangle(
                (int)(Width() / 2f), (int)(Height() / 2f),
                GameConfig.VirtualResolution.X - (int)(Width() / 2f),
                500 - (int)(Height() / 2f)
                );

            _bossEntranceAnimation = true;
            _ready           = false;
            _destroyed       = false;
            _targetDirection = Vector2.Zero;
            _targetAngle     = 0f;

            Game.GameManager.MoverManager.Clear();
            Invincible        = true;
            Tinted            = false;
            TargetingPosition = false;
            TargetingAngle    = false;

            CurrentBehaviourIndex  = 0;
            PreviousBehaviourIndex = -1;

            Position(new Vector2(InitialPosition.X, InitialPosition.Y - 500f));
            Rotation(0);
            Scale(Vector2.One);

            Direction = Vector2.Zero;
            Speed     = GameConfig.BossDefaultSpeed;

            CurrentAnimator.Play("Idle");
            CurrentAnimator.Progress = 0;
            CurrentAnimator.Speed    = 1;

            MoveToInitialPosition(GameConfig.BossEntranceAnimationTime, true);
        }
Beispiel #2
0
        public Holly(XmasLog boss, CustomSpriterAnimator animator)
        {
            _boss         = boss;
            _animator     = animator.Clone();
            _angularSpeed = 5f;

            var hollyLeafPosition = SpriterUtils.GetWorldPosition("holly-leaf.png", boss.CurrentAnimator);

            Position(hollyLeafPosition);
            _animator.Play("Growth");

            _animator.AnimationFinished += AnimationFinished;

            // Physics
            _boundingBoxes = new List <CollisionElement>
            {
                new SpriterCollisionCircle(this, "holly-leaf.png", new Vector2(-30, 0), 0.4f, "holly-leaf"),
                new SpriterCollisionCircle(this, "holly-leaf.png", new Vector2(45, 10), 0.3f, "holly-leaf"),
                new SpriterCollisionCircle(this, "holly-leaf.png", new Vector2(-30, 0), 0.4f, "holly-leaf_000"),
                new SpriterCollisionCircle(this, "holly-leaf.png", new Vector2(45, 10), 0.3f, "holly-leaf_000"),
                new SpriterCollisionCircle(this, "holly-leaf.png", new Vector2(-30, 0), 0.4f, "holly-leaf_001"),
                new SpriterCollisionCircle(this, "holly-leaf.png", new Vector2(45, 10), 0.3f, "holly-leaf_001"),
                new SpriterCollisionCircle(this, "holly-balls.png", Vector2.Zero, 0.8f)
            };

            foreach (var boundingBox in _boundingBoxes)
            {
                _boss.AddHitBox(boundingBox);
            }

            MoveTo(_boss.Game.ViewportAdapter.Center.ToVector2());
        }
Beispiel #3
0
        public Snowball(XmasSnowman boss, CustomSpriterAnimator animator, Vector2 position)
        {
            _boss            = boss;
            _animator        = animator.Clone();
            _initialPosition = position;

            Position(_initialPosition);

            _randomScale    = (float)(1f + _boss.Game.GameManager.Random.NextDouble() * 1.75f);
            _animator.Scale = new Vector2(_randomScale);

            // Physics
            _boundingBox = CreateBoundingBox();
            _boss.AddHitBox(_boundingBox);
            _body = CreateBody(_animator.Scale.X);

            _body.IgnoreGravity = true;
            _body.OnCollision  += OnCollision;

            // Animations
            _animator.Play("Spawn");

            // Swap body and ribbon with random textures
            var randomIndex = _boss.Game.GameManager.Random.Next(1, 7);

            if (randomIndex > 1)
            {
                _animator.AddTextureSwap("Graphics/Sprites/Bosses/XmasGift/body", Assets.GetTexture2D("Graphics/Sprites/Bosses/XmasGift/body" + randomIndex));
                _animator.AddTextureSwap("Graphics/Sprites/Bosses/XmasGift/ribbon", Assets.GetTexture2D("Graphics/Sprites/Bosses/XmasGift/ribbon" + randomIndex));
            }

            _animator.AnimationFinished += AnimationFinishedHandler;
        }
Beispiel #4
0
        public Gift(XmasGift boss, CustomSpriterAnimator animator)
        {
            _boss     = boss;
            _animator = animator.Clone();

            var randomScale = (float)(0.42f + _boss.Game.GameManager.Random.NextDouble() * 1.15f);

            _animator.Scale = new Vector2(randomScale);

            // Physics
            _boundingBox = _boss.CreateBoundingBox(this, randomScale);
            _boss.AddHitBox(_boundingBox);

            var randomSpawnBounds = new Rectangle(
                (int)(270 * randomScale), 0,
                (int)(GameConfig.VirtualResolution.X - (270 * randomScale)), 300
                );

            _body = _boss.CreateGiftBody(_boss.Game.GameManager.GetRandomPosition(false, randomSpawnBounds), _animator.Scale.X);

            _animator.Play("NoAnimation");

            // Swap body and ribbon with random textures
            var randomIndex = _boss.Game.GameManager.Random.Next(1, 7);

            if (randomIndex > 1)
            {
                _animator.AddTextureSwap("Graphics/Sprites/Bosses/XmasGift/body", Assets.GetTexture2D("Graphics/Sprites/Bosses/XmasGift/body" + randomIndex));
                _animator.AddTextureSwap("Graphics/Sprites/Bosses/XmasGift/ribbon", Assets.GetTexture2D("Graphics/Sprites/Bosses/XmasGift/ribbon" + randomIndex));
            }
        }
Beispiel #5
0
        private void Expand()
        {
            if (_animator.CurrentAnimation.Name != "Expand")
            {
                _animator.Play("Expand");
            }

            var animationTime = (int)_animator.Length;

            _randomAnimationTime = _boss.Game.GameManager.Random.Next(animationTime / 10, animationTime);

            _animator.Speed = 1;
        }
Beispiel #6
0
        public XmasCandyBar(Boss boss, CustomSpriterAnimator animator)
        {
            _boss     = boss;
            _animator = animator;

            _animator.Progress           = 0;
            _animator.Speed              = 1;
            _animator.AnimationFinished += AnimationFinishedHandler;

            _boundingBox = new SpriterCollisionConvexPolygon(this, "body2.png");
            _boss.AddHitBox(_boundingBox);

            _animator.Play("StretchInBorderMoving");
        }
Beispiel #7
0
        public BigArms(XmasSnowman boss, CustomSpriterAnimator animator, bool rightArm)
        {
            _boss              = boss;
            _animator          = animator.Clone();
            _rightArm          = rightArm;
            _verticalDirection = 1;
            _speed             = 200;

            _initialPosition = new Vector2(GameConfig.VirtualResolution.X / 2f, GameConfig.VirtualResolution.Y / 2f + 300);

            Position(_initialPosition);

            // Physics
            _boundingBoxes = new List <CollisionElement>
            {
                new SpriterCollisionConvexPolygon(this, "big-arm.png", new Vector2(177f, 10f), new Vector2(0.1f, 0.95f)),
                new SpriterCollisionCircle(this, "big-arm.png", new Vector2(-50f, -250f), 0.1f),
                new SpriterCollisionCircle(this, "big-arm.png", new Vector2(-105f, -295f), 0.1f),
                new SpriterCollisionCircle(this, "big-arm.png", new Vector2(-160f, -340f), 0.1f),
                new SpriterCollisionCircle(this, "big-arm.png", new Vector2(50f, -250f), 0.1f),
                new SpriterCollisionCircle(this, "big-arm.png", new Vector2(105f, -295f), 0.1f),
                new SpriterCollisionCircle(this, "big-arm.png", new Vector2(160f, -340f), 0.1f),
            };

            foreach (var boundingBox in _boundingBoxes)
            {
                _boss.AddHitBox(boundingBox);
            }

            // Animations
            _animator.Play("Idle");

            var spriteSize = SpriterUtils.GetSpriterFileSize("big-arm.png", _animator);

            if (rightArm)
            {
                _horizontalDirection = -1;
                _horizontalLimits    = new Point(GameConfig.VirtualResolution.X + 200, GameConfig.VirtualResolution.X + 200 + spriteSize.Y / 2);
                Rotation(MathHelper.Pi);
            }
            else
            {
                _horizontalDirection = 1;
                _horizontalLimits    = new Point(-200 - spriteSize.Y / 2, -200);
            }

            Position(new Vector2(_horizontalLimits.X, 0));
            ChangeHorizontalPosition();
        }
Beispiel #8
0
        public Hat(XmasSnowman boss, CustomSpriterAnimator animator, Vector2 position)
        {
            _boss     = boss;
            _animator = animator.Clone();
            _speed    = 200;

            _initialPosition = position;
            _scaleDownLaser  = true;

            Position(_initialPosition);

            // Physics
            _boundingBox = new SpriterCollisionCircle(this, "hat.png", Vector2.Zero, 0.7f);

            _boss.AddHitBox(_boundingBox);

            // Animations
            _animator.Play("Idle");

            ChangeHorizontalPosition();
            ShootLaser();

            _boss.Game.SpriteBatchManager.AddSpriterAnimator(_animator, Layer.FRONT);
        }
Beispiel #9
0
 private void RestoreDefaultState()
 {
     Direction = Vector2.Zero;
     CurrentAnimator.Play("Idle");
 }
Beispiel #10
0
 private void SpawnAnimationStoped()
 {
     SpawnAnimationFinished?.Invoke(this, EventArgs.Empty);
     _animator.Play("Idle");
 }
Beispiel #11
0
 public void StartStretchInAnimation()
 {
     _animator.Speed = 1;
     _animator.Play("StretchInBorderHeight");
 }