public RespawningJellyfish(EntityData data, Vector2 offset) : base(data, offset) { if (P_NotGlow == null) { // P_NotGlow is a transparent particle. P_NotGlow = new ParticleType(P_Glow) { Color = Color.Transparent, Color2 = Color.Transparent }; } respawnTime = data.Float("respawnTime"); bubble = data.Bool("bubble"); initialPosition = Position; respawning = false; // get the sprite, and replace it depending on the path in entity properties. self = new DynData <Glider>(this); sprite = self.Get <Sprite>("sprite"); new DynData <Sprite>(sprite)["atlas"] = GFX.Game; sprite.Path = data.Attr("spriteDirectory", defaultValue: "objects/MaxHelpingHand/glider") + "/"; sprite.Stop(); sprite.ClearAnimations(); sprite.AddLoop("idle", "idle", 0.1f); sprite.AddLoop("held", "held", 0.1f); sprite.Add("fall", "fall", 0.06f, "fallLoop"); sprite.AddLoop("fallLoop", "fallLoop", 0.06f); sprite.Add("death", "death", 0.06f); sprite.Add("respawn", "respawn", 0.03f, "idle"); sprite.Play("idle"); // make the jelly go invisible when the death animation is done. sprite.OnFinish += anim => { if (anim == "death") { Visible = false; } }; // listen for transitions: if the jelly is carried to another screen, it should not respawn anymore. Add(new TransitionListener() { OnOutBegin = () => shouldRespawn = false }); }
public RespawningJellyfish(EntityData data, Vector2 offset) : base(data, offset) { respawnTime = data.Float("respawnTime"); bubble = data.Bool("bubble"); initialPosition = Position; respawning = false; // get the sprite, and give it a respawn animation. self = new DynData <Glider>(this); sprite = self.Get <Sprite>("sprite"); new DynData <Sprite>(sprite)["atlas"] = GFX.Game; sprite.Add("respawn", "objects/MaxHelpingHand/glider/respawn", 0.03f, "idle"); // listen for transitions: if the jelly is carried to another screen, it should not respawn anymore. Add(new TransitionListener() { OnOutBegin = () => shouldRespawn = false }); }