/// <summary> /// Initializes a new instance of the <see cref="Rabbit" /> class. /// </summary> /// <param name="position">The position.</param> /// <param name="drawOrder">The draw order.</param> public Rabbit(Vector2 position, float drawOrder) { this.entity = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.One / 2, X = position.X, Y = position.Y, DrawOrder = drawOrder, XScale = 0.8f, YScale = 0.8f, }) .AddComponent(new RectangleCollider()) .AddComponent(new RabbitBehavior()) .AddComponent(new SpriteAtlas(Directories.TexturePath + "game.wpk", "rabbit")) .AddComponent(new SpriteAtlasRenderer(DefaultLayers.GUI)); // Cached this.rabbitBehavior = this.entity.FindComponent <RabbitBehavior>(); this.collider = this.entity.FindComponent <RectangleCollider>(); // Particles this.entity.AddChild(new Entity("rabbitParticles") .AddComponent(new Transform2D()) .AddComponent(ParticleFactory.CreateStarsParticle()) .AddComponent(new Material2D(new BasicMaterial2D(Directories.TexturePath + "starParticle.wpk", DefaultLayers.Additive))) .AddComponent(new ParticleSystemRenderer2D("rabbitParticles"))); }
/// <summary> /// Initializes a new instance of the <see cref="Rabbit" /> class. /// </summary> /// <param name="position">The position.</param> /// <param name="drawOrder">The draw order.</param> /// <param name="assetsContainer">The assets container</param> public Rabbit(Vector2 position, float drawOrder, AssetsContainer assetsContainer) { this.entity = new Entity() .AddComponent(new Transform2D() { Origin = Vector2.Center, X = position.X, Y = position.Y, DrawOrder = drawOrder, XScale = 0.8f, YScale = 0.8f, }) .AddComponent(new RectangleCollider2D()) .AddComponent(new RabbitBehavior()) .AddComponent(new SpriteAtlas(WaveContent.Assets.Textures.game_spritesheet, WaveContent.Assets.Textures.game_spritesheet_TextureName.rabbit)) .AddComponent(new SpriteAtlasRenderer(DefaultLayers.Alpha)); // Cached this.rabbitBehavior = this.entity.FindComponent <RabbitBehavior>(); this.collider = this.entity.FindComponent <RectangleCollider2D>(); var materialModel = assetsContainer.LoadModel <MaterialModel>(WaveContent.Assets.Materials.StarParticleMaterial); // Particles this.entity.AddChild(new Entity("rabbitParticles") .AddComponent(new Transform2D()) .AddComponent(ParticleFactory.CreateStarsParticle()) .AddComponent(new MaterialsMap(materialModel.Material)) .AddComponent(new ParticleSystemRenderer2D("rabbitParticles"))); }