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)); } }
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(); }
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"); }
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; }
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()); }
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); }
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"); }
public SpriterGuiButton( ViewportAdapter viewportAdapter, String buttonName, String spritePartCompleteFilename, CustomSpriterAnimator animator, CustomSpriterAnimator referenceAnimator) : base(viewportAdapter, buttonName) { SubstituteEntity = new SpriterSubstituteEntity(Path.GetFileName(spritePartCompleteFilename), referenceAnimator, animator); }
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); }
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"); }
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(); }
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(); }
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); }
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); } }
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); }
public void RemoveSpriterAnimator(CustomSpriterAnimator animator, Layer layer) { _animatorsToRemove.Add(new Tuple <CustomSpriterAnimator, Layer>(animator, layer)); }
public void AddSpriterAnimator(CustomSpriterAnimator animator, Layer layer) { _animatorsToAdd.Add(new Tuple <CustomSpriterAnimator, Layer>(animator, layer)); }
public BabyLog(XmasLog boss, CustomSpriterAnimator animator, Vector2 position) { _boss = boss; _animator = animator.Clone(); Position(position); }