/// <summary> /// Initializes a new instance of the <see cref="Squid" /> class. /// </summary> /// <param name="positionY">The position Y.</param> public Squid(float positionY) { this.initialPosY = positionY; this.gamePlayPosY = WaveServices.ViewportManager.BottomEdge + 50; this.entity = new Entity("SquidEntity") .AddComponent(new Transform2D() { Origin = new Vector2(0.5f, 0f), X = WaveServices.ViewportManager.VirtualWidth / 2, Y = this.gamePlayPosY, DrawOrder = 0.3f, }) .AddComponent(new AnimationUI()) .AddComponent(new SquidBehavior()) .AddComponent(new Sprite(Directories.TexturePath + "squidSpriteSheet.wpk")) .AddComponent(Animation2D.Create <TexturePackerGenericXml>(Directories.TexturePath + "squidSpriteSheet.xml") .Add("swim", new SpriteSheetAnimationSequence() { First = 1, Length = 30, FramesPerSecond = 30 })) .AddComponent(new PerPixelCollider(Directories.TexturePath + "squidCollider.wpk", 0.5f)) .AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Alpha)); // Cached this.transform = this.entity.FindComponent <Transform2D>(); this.animation2D = this.entity.FindComponent <Animation2D>(); this.direction = -Vector2.UnitY; this.animation = this.entity.FindComponent <AnimationUI>(); // Bubble this.entity.AddChild(new Entity("bubblesParticle") .AddComponent(new Transform2D() { LocalY = 210, }) .AddComponent(ParticleFactory.CreateBubbleParticles()) .AddComponent( new Material2D(new BasicMaterial2D(Directories.TexturePath + "waterParticle.wpk", DefaultLayers.Additive))) .AddComponent(new ParticleSystemRenderer2D("bubblesParticle"))); // Cached this.particleSystem = this.entity.FindChild("bubblesParticle").FindComponent <ParticleSystem2D>(); // Animations this.appearAnim = new SingleAnimation(gamePlayPosY, this.initialPosY, TimeSpan.FromSeconds(1.5f), EasingFunctions.Cubic); }