/// <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"))); }
/// <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"))); }
/// <summary> /// Unload this material. /// </summary> /// <param name="assets">The assets.</param> public void Unload(AssetsContainer assets) { if (this.EnvironmentMap != null && !string.IsNullOrEmpty(this.EnvironmentMap.AssetPath)) { assets.UnloadAsset(this.EnvironmentMap.AssetPath); this.EnvironmentMap = null; } }
/// <summary> /// Initializes the specified assets. /// </summary> /// <param name="assets">The assets.</param> public override void Initialize(AssetsContainer assets) { base.Initialize(assets); if (this.EnvironmentMap == null && !string.IsNullOrEmpty(this.environmentMapPath)) { this.EnvironmentMap = assets.LoadAsset <TextureCube>(this.environmentMapPath); } }
public override void Initialize(AssetsContainer assets) { try { this.DiffuseMap = assets.LoadAsset <Texture2D>(this.diffuseMapPath); } catch (Exception e) { throw new InvalidOperationException("MyMaterial needs a valid texture."); } }
public override void Initialize(AssetsContainer assets) { try { this.DiffuseMap = assets.LoadAsset<Texture2D>(this.diffuseMapPath); } catch (Exception e) { throw new InvalidOperationException("MyMaterial needs a valid texture."); } }
/// <summary> /// Initializes the specified assets. /// </summary> /// <param name="assets">The assets.</param> /// <exception cref="System.InvalidOperationException">Disappear Material needs a valid texture.</exception> public override void Initialize(AssetsContainer assets) { try { this.DiffuseMap = assets.LoadAsset <Texture2D>(this.diffuseMapPath); this.OpacityMap = assets.LoadAsset <Texture2D>(this.opacityMapPath); this.BurnMap = assets.LoadAsset <Texture2D>(this.burnMapPath); } catch (Exception) { throw new InvalidOperationException("DisappearMaterial needs a valid texture."); } }
/// <summary> /// Initializes a new instance of the <see cref="WaveTextureLoader" /> class. /// </summary> /// <param name="assets">The assets.</param> public WaveTextureLoader(AssetsContainer assets) { this.assets = assets; }
/// <summary> /// Initializes the specified assets. /// </summary> /// <param name="assets">The assets.</param> /// <exception cref="System.InvalidOperationException">Disappear Material needs a valid texture.</exception> public override void Initialize(AssetsContainer assets) { try { this.DiffuseMap = assets.LoadAsset<Texture2D>(this.diffuseMapPath); this.OpacityMap = assets.LoadAsset<Texture2D>(this.opacityMapPath); this.BurnMap = assets.LoadAsset<Texture2D>(this.burnMapPath); } catch (Exception) { throw new InvalidOperationException("DisappearMaterial needs a valid texture."); } }
/// <summary> /// Initializes the specified assets. /// </summary> /// <param name="assets">The assets.</param> public override void Initialize(AssetsContainer assets) { base.Initialize(assets); if (this.EnvironmentMap == null && !string.IsNullOrEmpty(this.environmentMapPath)) { this.EnvironmentMap = assets.LoadAsset<TextureCube>(this.environmentMapPath); } }
private void OnEnable() => _provider = Resources.Load <AssetsContainer>("ToolBoxAssetsContainer");