示例#1
0
文件: Gift.cs 项目: Noxalus/Xmas-Hell
        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));
            }
        }
示例#2
0
        public SpriterGuiButton(
            ViewportAdapter viewportAdapter,
            String buttonName,
            String spritePartCompleteFilename,
            CustomSpriterAnimator animator,
            CustomSpriterAnimator referenceAnimator,
            string animationName          = null,
            string clickAnimationName     = null,
            string inputDownSoundName     = null,
            string inputUpSoundName       = null,
            bool stopAnimationWhenClicked = false,
            string timelineName           = null) :
            base(viewportAdapter, buttonName)
        {
            SubstituteEntity    = new SpriterSubstituteEntity(Path.GetFileName(spritePartCompleteFilename), referenceAnimator, animator, timelineName);
            _animationName      = animationName;
            _clickAnimationName = clickAnimationName;

            _inputDownSoundName       = inputDownSoundName;
            _inputUpSoundName         = inputUpSoundName;
            _stopAnimationWhenClicked = stopAnimationWhenClicked;

            if (_animationName != null)
            {
                SubstituteEntity.SubstituteAnimator.Play(_animationName);
            }

            Reset();
        }
示例#3
0
        protected override void LoadSpriterSprite()
        {
            base.LoadSpriterSprite();

            BabyLogAnimator = Animators.First(a => a.Entity != null && a.Entity.Name == "BabyLog");
            HollyAnimator   = Animators.First(a => a.Entity != null && a.Entity.Name == "Holly");
        }
示例#4
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;
        }
示例#5
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());
        }
示例#6
0
        public Player(XmasHell game)
        {
            _game             = game;
            _currentDirection = Vector2.Zero;

            _idleAnimationTimer = new CountdownTimer(5);
            _idleAnimationTimer.Stop();
            _idleAnimationTimer.Completed += (sender, args) =>
            {
                Console.WriteLine("PLAY IDLE");
                CurrentAnimator.Play("Idle");
            };

            var playerHitboxTexture = Assets.GetTexture2D("Graphics/Sprites/Player/hitbox");

            var animatorConfig = new Config
            {
                MetadataEnabled = false,
                EventsEnabled   = false,
                PoolingEnabled  = true,
                TagsEnabled     = false,
                VarsEnabled     = false,
                SoundsEnabled   = false
            };

            var factory = new DefaultProviderFactory <ISprite, SoundEffect>(animatorConfig, true);

            var loader = new SpriterContentLoader(_game.Content, "Graphics/Sprites/Player/player");

            loader.Fill(factory);

            Stack <SpriteDrawInfo> drawInfoPool = new Stack <SpriteDrawInfo>();

            foreach (var entity in loader.Spriter.Entities)
            {
                var animator = new CustomSpriterAnimator(_game, entity, factory, drawInfoPool);
                _animators.Add(animator);
            }

            CurrentAnimator = _animators.First();
            var spriteSize = new Vector2(60, 82);

            CurrentAnimator.Position = new Vector2(spriteSize.X / 2f, spriteSize.Y / 2f);
            CurrentAnimator.Play("Idle");

            CurrentAnimator.AnimationFinished += AnimationFinished;

            _hitboxSprite = new Sprite(playerHitboxTexture)
            {
                //Scale = new Vector2(
                //    (GameConfig.PlayerHitboxRadius * 2f) / playerHitboxTexture.Width,
                //    (GameConfig.PlayerHitboxRadius * 2f) / playerHitboxTexture.Height
                //)
            };
            _hitbox = new CollisionCircle(this, Vector2.Zero, GameConfig.PlayerHitboxRadius);

            // Don't forget to set the player position delegate to the MoverManager
            _game.GameManager.MoverManager.SetPlayerPositionDelegate(Position);
        }
示例#7
0
        protected override void LoadSpriterSprite()
        {
            base.LoadSpriterSprite();

            SnowballAnimator = Animators.First(a => a.Entity != null && a.Entity.Name == "Snowball");
            BigArmsAnimator  = Animators.First(a => a.Entity != null && a.Entity.Name == "BigArms");
            HatAnimator      = Animators.First(a => a.Entity != null && a.Entity.Name == "Hat");
        }
示例#8
0
 public SpriterGuiButton(
     ViewportAdapter viewportAdapter,
     String buttonName,
     String spritePartCompleteFilename,
     CustomSpriterAnimator animator,
     CustomSpriterAnimator referenceAnimator) :
     base(viewportAdapter, buttonName)
 {
     SubstituteEntity = new SpriterSubstituteEntity(Path.GetFileName(spritePartCompleteFilename), referenceAnimator, animator);
 }
示例#9
0
 public SpriterGuiLabel(
     string text,
     BitmapFont font,
     string spritePartCompleteFilename,
     CustomSpriterAnimator referenceAnimator,
     bool center = false) :
     base(text, font, Vector2.Zero, Color.Black, center)
 {
     _replacedPartFilename = spritePartCompleteFilename;
     _referenceAnimator    = referenceAnimator;
     _referenceAnimator.AddHiddenTexture(_replacedPartFilename);
 }
示例#10
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");
        }
示例#11
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();
        }
示例#12
0
文件: Boss.cs 项目: Noxalus/Xmas-Hell
        protected virtual void LoadSpriterSprite()
        {
            if (SpriterFilename == string.Empty)
            {
                throw new Exception("You need to specify a path to the spriter file of this boss");
            }

            var factory = new DefaultProviderFactory <ISprite, SoundEffect>(DefaultAnimatorConfig, true);

            var loader = new SpriterContentLoader(Game.Content, SpriterFilename);

            loader.Fill(factory);

            foreach (var entity in loader.Spriter.Entities)
            {
                var animator = new CustomSpriterAnimator(entity, factory);
                Animators.Add(animator);
            }

            CurrentAnimator = Animators.First();
        }
示例#13
0
        private static Dictionary <string, CustomSpriterAnimator> LoadSpriterFile(ContentManager content, string filename)
        {
            var factory = new DefaultProviderFactory <ISprite, SoundEffect>(DefaultAnimatorConfig, true);

            var loader = new SpriterContentLoader(content, filename);

            loader.Fill(factory);

            var animators = new Dictionary <string, CustomSpriterAnimator>();

            foreach (var entity in loader.Spriter.Entities)
            {
                var animator = new CustomSpriterAnimator(entity, factory);

                // Center the animator
                animator.Position = XmasHell.Instance().ViewportAdapter.Center.ToVector2();

                animators.Add(entity.Name, animator);
            }

            return(animators);
        }
示例#14
0
        protected virtual void LoadSpriterSprite(String spriterFilename)
        {
            if (spriterFilename == string.Empty)
            {
                throw new Exception("You need to specify a path to the spriter file of this boss");
            }

            var factory = new DefaultProviderFactory <ISprite, SoundEffect>(DefaultAnimatorConfig, true);

            var loader = new SpriterContentLoader(Game.Content, spriterFilename);

            loader.Fill(factory);

            foreach (var entity in loader.Spriter.Entities)
            {
                var animator = new CustomSpriterAnimator(Game, entity, factory);
                // Center the animator
                animator.Position = Game.ViewportAdapter.Center.ToVector2();

                Animators.Add(entity.Name, animator);
            }
        }
示例#15
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);
        }
示例#16
0
 public void RemoveSpriterAnimator(CustomSpriterAnimator animator, Layer layer)
 {
     _animatorsToRemove.Add(new Tuple <CustomSpriterAnimator, Layer>(animator, layer));
 }
示例#17
0
 public void AddSpriterAnimator(CustomSpriterAnimator animator, Layer layer)
 {
     _animatorsToAdd.Add(new Tuple <CustomSpriterAnimator, Layer>(animator, layer));
 }
示例#18
0
 public BabyLog(XmasLog boss, CustomSpriterAnimator animator, Vector2 position)
 {
     _boss     = boss;
     _animator = animator.Clone();
     Position(position);
 }