/// <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"))); }
public bool Collision(RabbitBehavior rabbit) { return(this.collider.Intersects(rabbit.collider)); }