Exemple #1
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;
        }
Exemple #2
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));
            }
        }