Example #1
0
        public DashCollisionResults OnDashed(Player player, Vector2 direction)
        {
            if (!_activated && (direction == _pressDirection))
            {
                if (_startCutscene)
                {
                    Scene.Add(new CS01_FactoryHelper_BreakFirstFuse(player));
                }
                _activated = true;

                _doorSprite.Active  = true;
                _doorSprite.Visible = true;
                _mainSprite.Play("chaos", true, true);
                (Scene as Level).Displacement.AddBurst(Center, 0.35f, 8f, 32f, 0.25f);
                SetBustedCollider();

                Audio.Play("event:/new_content/game/10_farewell/fusebox_hit_2", Position);
                SetSessionTags();
                SendOutSignals();

                player?.RefillDash();

                Sparkle(20);

                Add(new Coroutine(SparkleSequence()));

                return(DashCollisionResults.Rebound);
            }
            return(DashCollisionResults.NormalCollision);
        }
Example #2
0
 public RustBerry(EntityData data, Vector2 offset, EntityID gid)
 {
     ID            = gid;
     Position      = (_start = data.Position + offset);
     _isGhostBerry = CheckRustBerry();
     Depth         = -100;
     Collider      = new Hitbox(14f, 14f, -7f, -7f);
     Add(new PlayerCollider(OnPlayer));
     Add(new MirrorReflection());
     Add(Follower          = new Follower(ID, null, OnLoseLeader));
     Add(_sprite           = FactoryHelperModule.SpriteBank.Create("rustBerry"));
     _sprite.OnFrameChange = OnAnimate;
     Add(_gearSprite       = FactoryHelperModule.SpriteBank.Create("rustBerryGear"));
     Follower.FollowDelay  = 0.3f;
     if (!_isGhostBerry)
     {
         _sprite.Play("idle");
         _gearSprite.Play("idle");
     }
     else
     {
         _sprite.Play("idleGhost");
         _gearSprite.Play("idleGhost");
     }
 }
        public override void Added(Scene scene)
        {
            base.Added(scene);

            if (inverted != level.Session.GetFlag(flag))
            {
                // start directly finished, since the session flag is already set (or the flag is inverted and unset).
                Activated = true;
                Finished  = true;

                icon.Rate = 0.1f;
                icon.Play("idle");
                icon.Color  = finishColor;
                ease        = 1f;
                bloom.Alpha = 1f;
            }
            else if (level.Session.GetFlag(flag + "_switch" + id))
            {
                // only that switch is activated, not the whole group.
                Activated = true;

                icon.Rate   = 4f;
                icon.Color  = activeColor;
                ease        = 1f;
                bloom.Alpha = 1f;
            }
        }
 public override void Update()
 {
     base.Update();
     if (respawnTimer > 0f)
     {
         respawnTimer -= Engine.DeltaTime;
         if (respawnTimer <= 0f)
         {
             light.Visible = true;
             bloom.Visible = true;
             sprite.Play("on");
             spriteEvil.Play("on");
             if (!fireMode)
             {
                 Audio.Play("event:/game/06_reflection/pinballbumper_reset", Position);
             }
         }
     }
     else if (base.Scene.OnInterval(0.05f))
     {
         float num       = Calc.Random.NextAngle();
         float direction = fireMode ? (-(float)Math.PI / 2f) : num;
         float length    = fireMode ? 12 : 8;
     }
     UpdatePosition();
 }
Example #5
0
 private void SetSprite(bool animate)
 {
     iceMode = (BGMode == false);
     if (animate)
     {
         if (playSounds)
         {
             Audio.Play(iceMode ? "event:/game/09_core/switch_to_cold" : "event:/game/09_core/switch_to_hot", base.Position);
         }
         if (Usable)
         {
             sprite.Play(iceMode ? "ice" : "hot", false, false);
         }
         else
         {
             if (playSounds)
             {
                 Audio.Play("event:/game/09_core/switch_dies", base.Position);
             }
             sprite.Play(iceMode ? "iceOff" : "hotOff", false, false);
         }
     }
     else if (Usable)
     {
         sprite.Play(iceMode ? "iceLoop" : "hotLoop", false, false);
     }
     else
     {
         sprite.Play(iceMode ? "iceOffLoop" : "hotOffLoop", false, false);
     }
     playSounds = false;
 }
        private void SetSprite(bool animate)
        {
            if (animate)
            {
                if (playSounds)
                {
                    Audio.Play(flagActive ? "event:/game/09_core/switch_to_hot" : "event:/game/09_core/switch_to_cold", Position);
                }

                if (Usable)
                {
                    sprite.Play(flagActive ? "activate" : "deactivate");
                }
                else
                {
                    if (playSounds)
                    {
                        Audio.Play("event:/game/09_core/switch_dies", Position);
                    }
                    sprite.Play(flagActive ? "activateOff" : "deactivateOff");
                }
            }
            else if (Usable)
            {
                sprite.Play(flagActive ? "activateLoop" : "deactivateLoop");
            }
            else
            {
                sprite.Play(flagActive ? "activateOffLoop" : "deactivateOffLoop");
            }

            playSounds = false;
        }
Example #7
0
        private IEnumerator CollectRoutine(int collectIndex)
        {
            Level level = SceneAs <Level>();

            Tag   = Tags.TransitionUpdate;
            Depth = -2000010;

            // Use "yellow" text for a new berry, "blue" for an owned berry.
            // Plays the appropriate sounds, too.
            int color = !isOwned ? 0 : 1;

            Audio.Play("event:/game/general/strawberry_get", Position, "colour", (float)color, "count", (float)collectIndex);
            Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium);

            if (!isOwned)
            {
                sprite.Play("collect");
            }
            else
            {
                sprite.Play("collectGhost");
            }

            while (sprite.Animating)
            {
                yield return(null);
            }
            Scene.Add(new StrawberryPoints(Position, isOwned, collectIndex, false));
            RemoveSelf();
            yield break;
        }
Example #8
0
        private IEnumerator destroyThenRespawnRoutine()
        {
            // do like vanilla, but instead of removing the jelly, wait then have it respawn.
            Audio.Play("event:/new_content/game/10_farewell/glider_emancipate", Position);
            sprite.Play("death");

            return(respawnRoutine());
        }
 public void AttachToPlayer(Player player)
 {
     this.player         = player;
     Activated           = false;
     ActiveCompanion     = this;
     reachedLastPosition = false;
     ParentCollection.manager.Interacted();
     wiggler.Start();
     sprite.Play(requiresDash ? "idle" : "noDash", true);
 }
        public MultiplayerControlSwitch(Vector2 position)
            : base(position)
        {
            base.Depth             = 2000;
            base.Add(ControlSwitch = new ControlSwitch(false, 0));

            base.Add(new PlayerCollider(OnPlayer, null, new Hitbox(30f, 30f, -15f, -15f)));
            base.Add(icon);
            base.Add(bloom = new BloomPoint(0f, 16f));
            bloom.Alpha    = 0f;
            icon.Add("idle", "", 0f, default(int));
            icon.Add("spin", "", 0.1f, new Chooser <string>("spin", 1f), 0, 1, 2, 3, 4, 5);
            icon.Play("spin", false, false);
            icon.Color = inactiveColor;
            icon.CenterOrigin();
            base.Collider = new Hitbox(16f, 16f, -8f, -8f);
            base.Add(new TheoCrystalCollider(OnTheoCrystal, new Hitbox(20f, 20f, -10f, -10f)));
            base.Add(new SeekerCollider(OnSeeker, new Hitbox(24f, 24f, -12f, -12f)));

            ControlSwitch.OnActivate = delegate
            {
                wiggler.Start();
                for (int i = 0; i < 32; i++)
                {
                    float num = Calc.Random.NextFloat(6.28318548f);
                    //level.Particles.Emit(P_FireWhite, base.Position + Calc.AngleToVector(num, 6f), num);
                }
                icon.Rate = 4f;
            };

            ControlSwitch.OnDeactivate = delegate
            {
                wiggler.StopAndClear();
                icon.Rate = 0.1f;
                icon.Play("spin", false, false);
            };

            ControlSwitch.OnFinish = delegate
            {
                ease = 0f;
            };
            ControlSwitch.OnStartFinished = delegate
            {
                icon.Rate = 0.1f;
                icon.Play("spin", false, false);
                ease = 1f;
            };

            base.Add(wiggler = Wiggler.Create(0.5f, 4f, delegate(float v)
            {
                pulse = Vector2.One * (1f + v * 0.25f);
            }, false, false));
            base.Add(new VertexLight(Color.White, 0.8f, 16, 32));
            base.Add(touchSfx = new SoundSource());
        }
Example #11
0
 public void OnPlayer(Player player)
 {
     if (Follower.Leader == null && !_collected)
     {
         Audio.Play(_isGhostBerry ? "event:/game/general/strawberry_blue_touch" : "event:/game/general/strawberry_touch", Position);
         player.Leader.GainFollower(Follower);
         _wiggler.Start();
         _sprite.Play("noFlash" + (_isGhostBerry ? "Ghost": ""));
         base.Depth = -1000000;
     }
 }
 private void Open()
 {
     Audio.Play(
         theoGate
             ? "event:/game/05_mirror_temple/gate_theo_open"
             : "event:/game/05_mirror_temple/gate_main_open", Position);
     holdingWaitTimer    = HoldingWaitTime;
     drawHeightMoveSpeed = 200f;
     drawHeight          = Height;
     shaker.ShakeFor(HoldingWaitTime, false);
     SetHeight(OpenHeight);
     sprite.Play("open");
     open = true;
 }
Example #13
0
 private void animate()
 {
     if (active)
     {
         sprite.Play("lever", true);
         sprite.Rate = 1;
     }
     else
     {
         sprite.Play("lever", true);
         sprite.Rate = -1;
         sprite.SetAnimationFrame(sprite.CurrentAnimationTotalFrames - 1);
     }
 }
Example #14
0
        public void Open()
        {
            Audio.Play("event:/game/05_mirror_temple/gate_main_open", Position);
            shaker.ShakeFor(0.2f, removeOnFinish: false);

            sprite.Play("gate", true);
            sprite.Rate = 1f;

            shaker.ShakeFor(0.2f, removeOnFinish: false);

            drawingHeightSpeed = 200f;
            waitFor            = waitDelay;

            open = true;
        }
Example #15
0
        public override void RunGreenSpace(BoardController board, BoardController.BoardSpace space, Action after)
        {
            Sprite       seekerSprite = GFX.SpriteBank.Create("seeker");
            SubHUDSprite seeker       = new SubHUDSprite(seekerSprite);

            seeker.Collider = new Hitbox(50, 50, -25, -25);
            seeker.Depth    = -40000;
            board.Scene.Add(seeker);
            seeker.Position    = space.screenPosition + startOffset;
            seekerSprite.FlipX = true;
            seekerSprite.Play("recover");
            seekerSprite.OnFinish += s => seekerSprite.Play("windUp");
            seekerSprite.Scale     = new Vector2(2, 2);
            board.Add(new Coroutine(SeekerCharge(board, after, seeker, seeker.Position, space.screenPosition - startOffset / 2)));
        }
Example #16
0
 public SeekerBossShot Init(SeekerBoss boss, Player target, float angleOffset = 0.0f)
 {
     this.boss        = boss;
     anchor           = Position = boss.Center;
     this.target      = target;
     this.angleOffset = angleOffset;
     dead             = hasBeenInCamera = false;
     cantKillTimer    = 0.15f;
     appearTimer      = 0.1f;
     sine.Reset();
     sineMult = 0.0f;
     sprite.Play("charge", true);
     InitSpeed();
     return(this);
 }
Example #17
0
 public KevinRefill(Vector2 position)
     : base(position)
 {
     base.Collider = new Hitbox(16f, 16f, -8f, -8f);
     base.Add(new PlayerCollider(OnPlayer, null, null));
     base.Add(outline = new Image(GFX.Game["objects/refill/outline"]));
     outline.CenterOrigin();
     outline.Visible = false;
     base.Add(sprite = new Sprite(GFX.Game, "objects/refill/idle"));
     sprite.AddLoop("idle", "", 0.1f);
     sprite.Play("idle", false, false);
     sprite.CenterOrigin();
     base.Add(flash = new Sprite(GFX.Game, "objects/refill/flash"));
     flash.Add("flash", "", 0.05f);
     flash.OnFinish = delegate
     {
         flash.Visible = false;
     };
     flash.CenterOrigin();
     base.Add(wiggler = Wiggler.Create(1f, 4f, delegate(float v)
     {
         sprite.Scale = (flash.Scale = Vector2.One * (1f + v * 0.2f));
     }, false, false));
     base.Add(new MirrorReflection());
     base.Add(bloom = new BloomPoint(0.8f, 16f));
     base.Add(light = new VertexLight(Color.White, 1f, 16, 48));
     base.Add(sine  = new SineWave(0.6f));
     sine.Randomize();
     UpdateY();
     base.Depth = -100;
 }
Example #18
0
 private DashCollisionResults DashCollide(Player player, Vector2 direction)
 {
     if (_stage == 0)
     {
         _frontSprite.Play("break");
         Audio.Play("event:/new_content/game/10_farewell/fusebox_hit_2", Position);
         Add(_firstHitSfx = new SoundSource("event:/new_content/game/10_farewell/fusebox_hit_1"));
         Celeste.Celeste.Freeze(0.1f);
         _light.Visible = true;
         foreach (RustyLamp rustyLamp in Scene.Tracker.GetEntities <RustyLamp>())
         {
             rustyLamp.Activator.ForceDeactivate();
         }
     }
     else if (_stage == 1)
     {
         if (_firstHitSfx != null)
         {
             _firstHitSfx.Stop();
         }
         _backSprite.Play("break");
         Audio.Play("event:/new_content/game/10_farewell/fusebox_hit_2", Position);
         Add(new Coroutine(CrystalBreakSound()));
         _bloom.Visible = false;
     }
     _stage++;
     return(DashCollisionResults.Rebound);
 }
Example #19
0
        private void InitSprite(int width, int height)
        {
            string sheetpath = null;

            if (Sprite != null && Sprite.SheetPath != null)
            {
                sheetpath = Sprite.SheetPath.Absolute;
            }

            Sprite       = new Sprite(width, height);
            spriteWidth  = width;
            spriteHeight = height;
            if (sheetpath != null)
            {
                Sprite.SheetPath = FilePath.FromAbsolute(sheetpath, project.BaseDir);
            }

            frameTotalLabel.Text = "of " + Sprite.Count.ToString();
            currentFrame.Minimum = 1;
            currentFrame.Maximum = Sprite.Count;
            duration.Value       = 0;

            textWidth.Text  = Sprite.Width.ToString();
            textHeight.Text = Sprite.Height.ToString();

            InitPreview();

            Sprite.Play();

            if (SpriteChange != null)
            {
                SpriteChange();
            }
        }
        public DreamBlockDebris Init(Vector2 pos, DreamBlockDummy block = null)
        {
            orig_Init(pos, '1');

            Block = block ?? new DreamBlockDummy(this);
            Image image = baseData.Get <Image>("image");

            Remove(image);
            Sprite sprite = new Sprite(GFX.Game, "objects/CommunalHelper/dreamMoveBlock/");
            float  speed  = Calc.Random.NextFloat(0.3f) + 0.1f;

            sprite.AddLoop("active", "debris", speed);
            sprite.AddLoop("disabled", "disabledDebris", speed);
            sprite.CenterOrigin();
            sprite.Color    = image.Color;
            sprite.Rotation = image.Rotation;
            sprite.Scale    = image.Scale;
            sprite.FlipX    = image.FlipX;
            sprite.FlipY    = image.FlipY;

            Add(sprite);
            sprite.Play(Block.PlayerHasDreamDash ? "active" : "disabled", randomizeFrame: true);
            baseData["image"] = this.sprite = sprite;

            if (Calc.Random.Next(4) == 0)
            {
                activePointColor   = Calc.Random.Choose(activeParticleColors);
                disabledPointColor = Color.LightGray * (0.5f + Calc.Random.Choose(0, 1, 1, 2, 2, 2) / 2f * 0.5f);
                pointOffset        = new Vector2(Calc.Random.Next(-2, 2), Calc.Random.Next(-2, 2));
            }

            return(this);
        }
Example #21
0
        public override void Added(Scene scene)
        {
            base.Added(scene);

            IsGhost = AltSidesHelperModule.AltSidesSaveData.UnlockedAltSideIDs.Contains(altSideToUnlock);
            string path = IsGhost ? "ghost" : "idle";

            sprite = new Sprite(GFX.Game, spritePath);
            sprite.Add("idle", path, 0.07f, "pulse", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
            sprite.Add("spin", path, 0.07f, "spin", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
            sprite.Add("pulse", path, 0.04f, "idle", new int[] { 13, 14, 15, 16, 17, 18 });
            sprite.CenterOrigin();
            Add(sprite);

            sprite.Play("idle");
            Add(scaleWiggler = Wiggler.Create(0.25f, 4f, delegate(float f) {
                sprite.Scale = Vector2.One * (1f + f * 0.25f);
            }));
            Add(bloom      = new BloomPoint(0.25f, 16f));
            Add(light      = new VertexLight(Color.White, 0.4f, 32, 64));
            Add(hover      = new SineWave(0.5f, 0f));
            hover.OnUpdate = delegate(float f) {
                Sprite      obj         = sprite;
                VertexLight vertexLight = light;
                float       num2        = bloom.Y = f * 2f;
                float       num5        = obj.Y = (vertexLight.Y = num2);
            };
            if (IsGhost)
            {
                sprite.Color = Color.White * 0.8f;
            }
        }
Example #22
0
        public BatteryBox(Vector2 position, string activationIds) : base(position)
        {
            Add(_boxSprite     = FactoryHelperModule.SpriteBank.Create("battery_box"));
            Add(_batterySprite = FactoryHelperModule.SpriteBank.Create("battery"));
            _batterySprite.Play("idle");

            foreach (string activationId in activationIds.Split(','))
            {
                if (activationId != "")
                {
                    _activationIds.Add(activationId);
                }
            }

            Add(_sfx = new SoundSource());

            Add(new PlayerCollider(OnPlayer, new Circle(60f)));

            Add(new LightOcclude(new Rectangle(-15, -15, 30, 30), 0.2f));

            Add(_light     = new VertexLight(Color.LightSeaGreen, 1f, 32, 48));
            _light.Visible = false;

            Depth = 8499;
        }
        public override void RunGreenSpace(BoardController board, BoardController.BoardSpace space, Action after)
        {
            Sprite       tentacleSprite = GFX.SpriteBank.Create("madelinePartyTentacle");
            SubHUDSprite tentacle       = new SubHUDSprite(tentacleSprite);
            Vector2      targetPosition = space.screenPosition - new Vector2(tentacleSprite.Width * scaleFactor / 2, 27 * scaleFactor);

            tentacle.Depth = -40000;
            board.Scene.Add(tentacle);
            tentacle.Position = targetPosition;
            List <Sprite> tentacleExtensions = new List <Sprite>();

            float posOffset = tentacleSprite.Height;

            tentacleSprite.Scale = new Vector2(scaleFactor);
            while (tentacle.Position.Y + posOffset < Engine.ViewHeight)
            {
                Sprite extension = GFX.SpriteBank.Create("madelinePartyTentacle");
                extension.Play("long");
                tentacle.Add(extension);
                extension.Position = new Vector2(0, posOffset * scaleFactor);
                extension.Scale    = new Vector2(scaleFactor);
                posOffset         += extension.Height;
                tentacleExtensions.Add(extension);
            }
            tentacle.Position.Y = Engine.ViewHeight;

            Tween riseTween = Tween.Create(Tween.TweenMode.Oneshot, Ease.CubeIn, 0.25f, true);

            riseTween.OnUpdate   = t => tentacle.Position.Y = Calc.LerpClamp(Engine.ViewHeight, targetPosition.Y, t.Eased);
            riseTween.OnComplete = t => {
                tentacleSprite.Play("tentacle_grab");
                board.Add(new Coroutine(PullDown(board, after, tentacle, space)));
            };
            board.Add(riseTween);
        }
Example #24
0
        private void CreateSecretSprite()
        {
            string id     = "secret_" + Enum.GetNames(typeof(SpriteStyle))[(int)spriteStyle].ToLower();
            Sprite sprite = new Sprite(GFX.Game, "decals/6-reflection/" + id);

            sprite.AddLoop(id, "", 0.1f);
            sprite.Play(id);
            sprite.CenterOrigin();

            Vector2 offset = Vector2.UnitY * -8;

            if (spriteStyle != SpriteStyle.EyeBat)
            {
                offset = Vector2.UnitY * -16;
            }

            sprite.RenderPosition += offset;

            sprite.Scale.X *= -(int)facing;
            if (spriteStyle == SpriteStyle.Towerfall)
            {
                sprite.Scale.X = -sprite.Scale.X;
            }

            Add(sprite);
        }
Example #25
0
 public override void Update()
 {
     bounceSfxDelay -= Engine.DeltaTime;
     timer          += Engine.DeltaTime;
     sprite.Position = Vector2.UnitY * (float)Math.Sin(timer * 2f) * 2f + moveWiggleDir * moveWiggler.Value * -8f;
     if (white != null)
     {
         white.Position = sprite.Position;
         white.Scale    = sprite.Scale;
         if (white.CurrentAnimationID != sprite.CurrentAnimationID)
         {
             white.Play(sprite.CurrentAnimationID);
         }
         white.SetAnimationFrame(sprite.CurrentAnimationFrame);
     }
     if (collected && (base.Scene.Tracker.GetEntity <Player>()?.Dead ?? true))
     {
         EndCutscene();
     }
     base.Update();
     if (!collected && base.Scene.OnInterval(0.1f))
     {
         SceneAs <Level>().Particles.Emit(shineParticle, 1, base.Center, Vector2.One * 8f);
     }
 }
        public ReskinnableStarRotateSpinner(EntityData data, Vector2 offset) : base(data, offset)
        {
            string[] particleColorsAsStrings = data.Attr("particleColors", "EA64B7|3EE852,67DFEA|E85351,EA582C|33BDE8").Split(',');
            trailParticles = new ParticleType[particleColorsAsStrings.Length];
            for (int i = 0; i < particleColorsAsStrings.Length; i++)
            {
                string[] colors = particleColorsAsStrings[i].Split('|');
                trailParticles[i] = new ParticleType(StarTrackSpinner.P_Trail[0])
                {
                    Color  = Calc.HexToColor(colors[0]),
                    Color2 = Calc.HexToColor(colors[1])
                };
            }

            colorID = Calc.Random.Next(0, particleColorsAsStrings.Length);

            Add(sprite = new Sprite(GFX.Game, data.Attr("spriteFolder", "danger/MaxHelpingHand/starSpinner") + "/"));
            for (int i = 0; i < particleColorsAsStrings.Length; i++)
            {
                sprite.AddLoop($"idle{i}", $"idle{i}_", 0.08f);
                sprite.Add($"spin{i}", $"spin{i}_", 0.06f, $"idle{(i + 1) % particleColorsAsStrings.Length}");
            }
            sprite.CenterOrigin();
            sprite.Play($"idle{colorID}");

            Depth = -50;
            Add(new MirrorReflection());
        }
Example #27
0
        public CustomPickup(Vector2 position, Vector2 targetPosition, int playerIndex) : base(position, targetPosition, playerIndex)
        {
            this.playerIndex = playerIndex;
            Tag(GameTags.LightSource);
            images = new Sprite <int> [3];
            for (int i = 0; i < images.Length; i++)
            {
                Sprite <int> image;
                image    = new Sprite <int>(TFGame.Atlas["pickups/bomb"], 12, 12, 0);
                image.X += 14;
                image.X -= 14 * i;
                image.CenterOrigin();
                image.Add(0, 0.05f, new int[]
                {
                    0,
                    0,
                    2,
                    1,
                    1,
                    2
                });

                image.Play(0, false);
                Add(image);
                images[i] = image;
            }
        }
        private void Add(string name, Sprite sprite, string partName = null)
        {
            SpriteGroup group;

            if (_sprites.ContainsKey(name))
            {
                group = _sprites[name];
            }
            else
            {
                group = new SpriteGroup(this);
                _sprites.Add(name, group);

                if (currentSpriteGroup == null)
                {
                    currentSpriteGroup = group;
                }
            }

            group.Add(sprite, partName);

            if (group == currentSpriteGroup)
            {
                sprite.Play();
            }
        }
        public RustyLamp(Vector2 position, Vector2 offset, string activationId, float initialDelay, string strobePattern, bool startActive) : base()
        {
            Depth    = 8500;
            Position = position + offset;

            Collider = new Hitbox(12, 12, 2, 2);

            Add(Activator          = new FactoryActivator());
            Activator.ActivationId = activationId == string.Empty ? null : activationId;
            Activator.StartOn      = startActive;
            Activator.OnTurnOff    = OnTurnOff;
            Activator.OnTurnOn     = OnTurnOn;
            Activator.OnStartOff   = OnStartOff;
            Activator.OnStartOn    = OnStartOn;

            Add(_steamCollider = new SteamCollider(OnSteamWall));

            _initialDelay = initialDelay;
            Add(_sprite   = new Sprite(GFX.Game, "objects/FactoryHelper/rustyLamp/rustyLamp"));
            _sprite.Add("frames", "");
            _sprite.Play("frames");
            _sprite.Active = false;

            _strobePatternString = strobePattern;

            Add(_light      = new VertexLight(Color, 0f, 128, 128));
            Add(_bloom      = new BloomPoint(0.0f, 16f));
            _light.Position = new Vector2(8, 8);
            _bloom.Position = new Vector2(8, 8);
        }
Example #30
0
        public void Move(Vector2 add)
        {
            if (add.X != 0 || add.Y != 0)
            {
                Sprite.Play("move", false);

                // Move maximum in a direction until hitting a wall

                if (CollideCheck(GAccess.WallTag, new Vector2(X + add.X, Y)))
                {
                    while (!CollideCheck(GAccess.WallTag, new Vector2(X + Calc.Sign(add).X, Y)))
                    {
                        X += Calc.Sign(add).X;
                    }
                }
                else
                {
                    X += add.X * 60f * Engine.DeltaTime;
                }

                if (CollideCheck(GAccess.WallTag, new Vector2(X, Y + add.Y)))
                {
                    while (!CollideCheck(GAccess.WallTag, new Vector2(X, Y + Calc.Sign(add).Y)))
                    {
                        Y += Calc.Sign(add).Y;
                    }
                }
                else
                {
                    Y += add.Y * 60f * Engine.DeltaTime;
                }
            }
        }
Example #31
0
 public void CompleteAnimation(Sprite<String> sprite)
 {
     if (sprite.CurrentAnimID=="crouchOut") sprite.Play("idle", true);
 }
Example #32
0
        private void InitSprite(int width, int height)
        {
            string sheetpath = null;
            if (Sprite != null && Sprite.SheetPath != null) sheetpath = Sprite.SheetPath.Absolute;

            Sprite = new Sprite(width, height);
            spriteWidth = width;
            spriteHeight = height;
            if (sheetpath != null) Sprite.SheetPath = FilePath.FromAbsolute(sheetpath, project.BaseDir);

            frameTotalLabel.Text = "of " + Sprite.Count.ToString();
            currentFrame.Minimum = 1;
            currentFrame.Maximum = Sprite.Count;
            duration.Value = 0;

            textWidth.Text = Sprite.Width.ToString();
            textHeight.Text = Sprite.Height.ToString();

            InitPreview();

            Sprite.Play();

            if (SpriteChange != null) SpriteChange();
        }