public override void Added(Scene scene) { base.Added(scene); if (spawnedByOtherBumper) { // this bumper was spawned by another bumper that spawned the platform. so we have nothing to do! return; } // add a multi-node moving platform, pass the bumper settings to it, and attach the bumper to it. StaticMover staticMover = MakeWobbleStaticMover(); Add(staticMover); animatingPlatform = new MultiNodeMovingPlatform(thisEntityData, thisOffset, otherPlatform => { if (otherPlatform != animatingPlatform) { // another multi-node moving platform was spawned (because of the "count" setting), spawn another bumper... MultiNodeBumper otherBumper = new MultiNodeBumper(thisEntityData, thisOffset); otherBumper.spawnedByOtherBumper = true; Scene.Add(otherBumper); // ... and attach it to that new platform. StaticMover otherStaticMover = otherBumper.MakeWobbleStaticMover(); otherBumper.Add(otherStaticMover); otherPlatform.AnimateObject(otherStaticMover); } }); animatingPlatform.AnimateObject(staticMover); scene.Add(animatingPlatform); }
public override void OnStaticMoverTrigger(StaticMover sm) { if (sm.Entity is Spring spring) { switch (spring.Orientation) { case Spring.Orientations.Floor: sinkTimer = 0.5f; return; case Spring.Orientations.WallLeft: dashEase = 1f; dashDirection = -Vector2.UnitX; return; case Spring.Orientations.WallRight: dashEase = 1f; dashDirection = Vector2.UnitX; break; default: return; } } }
/// <summary> /// Makes this platform animate another entity, instead of ... serving as a platform. /// </summary> /// <param name="staticMover">The static mover associated to the entity to animate</param> /// <param name="forcedTrackOffset">Pass a value with the track offset if a track should be rendered</param> internal void AnimateObject(StaticMover staticMover, Vector2?forcedTrackOffset = null) { staticMovers.Add(staticMover); Visible = false; Collider.Width = 8f; Collider.Position -= new Vector2(4f, 2f); this.forcedTrackOffset = forcedTrackOffset; }
public override void OnStaticMoverTrigger(StaticMover sm) { if (MasterOfGroup) { Triggered = true; } else { _master.Triggered = true; } }
public static Entity Load(Level level, LevelData levelData, Vector2 offset, EntityData entityData) { // an attached ice wall is just like a regular "not core mode" wall booster, but with a different static mover hitbox. bool left = entityData.Bool("left"); WallBooster iceWall = new WallBooster(entityData.Position + offset, entityData.Height, left, notCoreMode: true); StaticMover staticMover = iceWall.Get <StaticMover>(); staticMover.SolidChecker = solid => iceWall.CollideCheck(solid, iceWall.Position + (left ? -2 : 2) * Vector2.UnitX); staticMover.OnAttach = platform => iceWall.Depth = platform.Depth + 1; iceWall.Get <CoreModeListener>().RemoveSelf(); return(iceWall); }
public override void Added(Scene scene) { base.Added(scene); // add the hidden solid to the scene as well. scene.Add(playerInteractingSolid); // load the texture. MTexture fullTexture = GFX.Game["objects/woodPlatform/" + texture]; textures = new MTexture[fullTexture.Width / 8]; for (int i = 0; i < textures.Length; i++) { textures[i] = fullTexture.GetSubtexture(i * 8, 0, 8, 8); } if (spawnedByOtherPlatform) { // this platform was spawned by another platform that spawned the moving platform. so don't manage the static mover! return; } // add a multi-node moving platform, pass the platform settings to it, and attach the bumper to it. StaticMover staticMover = new StaticMover() { OnMove = move => SidewaysJumpthruOnMove(this, playerInteractingSolid, left, move) }; Add(staticMover); animatingPlatform = new MultiNodeMovingPlatform(thisEntityData, thisOffset, otherPlatform => { if (otherPlatform != animatingPlatform) { // another multi-node moving platform was spawned (because of the "count" setting), spawn another platform... SidewaysMovingPlatform otherSidewaysPlatform = new SidewaysMovingPlatform(thisEntityData, thisOffset); otherSidewaysPlatform.spawnedByOtherPlatform = true; Scene.Add(otherSidewaysPlatform); // ... and attach it to that new platform. StaticMover otherStaticMover = new StaticMover() { OnMove = move => SidewaysJumpthruOnMove(otherSidewaysPlatform, otherSidewaysPlatform.playerInteractingSolid, otherSidewaysPlatform.left, move) }; otherSidewaysPlatform.Add(otherStaticMover); otherPlatform.AnimateObject(otherStaticMover, forcedTrackOffset: new Vector2(Width + 4f, Height) / 2f); } }); animatingPlatform.AnimateObject(staticMover, forcedTrackOffset: new Vector2(Width + 4f, Height) / 2f); scene.Add(animatingPlatform); }
public AttachedSidewaysJumpThru(EntityData data, Vector2 offset) : base(data, offset) { Left = data.Bool("left"); // this solid will be made solid only when moving the player with the platform, so that the player gets squished and can climb the platform properly. playerInteractingSolid = new Solid(Position, Width, Height, safe: false); playerInteractingSolid.Collidable = false; playerInteractingSolid.Visible = false; if (!Left) { playerInteractingSolid.Position.X += 3f; } // create the StaticMover that will make this jumpthru attached. StaticMover staticMover = new StaticMover() { SolidChecker = solid => solid.CollideRect(new Rectangle((int)X, (int)Y - 1, (int)Width, (int)Height + 2)), OnMove = move => SidewaysMovingPlatform.SidewaysJumpthruOnMove(this, playerInteractingSolid, Left, move), OnShake = shake => SidewaysMovingPlatform.SidewaysJumpthruOnMove(this, playerInteractingSolid, Left, shake) }; Add(staticMover); }
public override void OnStaticMoverTrigger(StaticMover sm) { Triggered = true; }
public TrollSpring(Vector2 position, Orientations orientation, bool playerCanUse) : base(position) { Orientation = orientation; this.playerCanUse = playerCanUse; Add(new PlayerCollider(OnCollide)); Add(new HoldableCollider(OnHoldable)); PufferCollider pufferCollider = new PufferCollider(OnPuffer); Add(pufferCollider); Add(sprite = new Sprite(GFX.Game, "objects/TrollLand/trollSpring/")); sprite.Add("idle", "", 0f, default(int)); sprite.Add("bounce", "", 0.07f, "idle", 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 5); sprite.Add("disabled", "white", 0.07f); sprite.Play("idle"); sprite.Origin.X = sprite.Width / 2f; sprite.Origin.Y = sprite.Height; base.Depth = -8501; staticMover = new StaticMover(); staticMover.OnAttach = delegate(Platform p) { base.Depth = p.Depth + 1; }; switch (orientation) { case Orientations.FloorLeft: case Orientations.FloorRight: staticMover.SolidChecker = ((Solid s) => CollideCheck(s, Position + Vector2.UnitY)); staticMover.JumpThruChecker = ((JumpThru jt) => CollideCheck(jt, Position + Vector2.UnitY)); break; case Orientations.WallLeftUp: case Orientations.WallLeftDown: staticMover.SolidChecker = ((Solid s) => CollideCheck(s, Position - Vector2.UnitX)); staticMover.JumpThruChecker = ((JumpThru jt) => CollideCheck(jt, Position - Vector2.UnitX)); break; case Orientations.WallRightUp: case Orientations.WallRightDown: staticMover.SolidChecker = ((Solid s) => CollideCheck(s, Position + Vector2.UnitX)); staticMover.JumpThruChecker = ((JumpThru jt) => CollideCheck(jt, Position + Vector2.UnitX)); break; } Add(staticMover); Add(wiggler = Wiggler.Create(1f, 4f, delegate(float v) { sprite.Scale.Y = 1f + v * 0.2f; })); switch (orientation) { case Orientations.FloorLeft: case Orientations.FloorRight: base.Collider = new Hitbox(16f, 6f, -8f, -6f); pufferCollider.Collider = new Hitbox(16f, 10f, -8f, -10f); break; case Orientations.WallLeftUp: case Orientations.WallLeftDown: base.Collider = new Hitbox(6f, 16f, 0f, -8f); pufferCollider.Collider = new Hitbox(12f, 16f, 0f, -8f); sprite.Rotation = (float)Math.PI / 2f; break; case Orientations.WallRightUp: case Orientations.WallRightDown: base.Collider = new Hitbox(6f, 16f, -6f, -8f); pufferCollider.Collider = new Hitbox(12f, 16f, -12f, -8f); sprite.Rotation = -(float)Math.PI / 2f; break; default: throw new Exception("Orientation not supported!"); } switch (orientation) { case Orientations.FloorRight: case Orientations.WallLeftDown: case Orientations.WallRightUp: sprite.Scale.X = -1; break; } staticMover.OnEnable = OnEnable; staticMover.OnDisable = OnDisable; }
public override void OnStaticMoverTrigger(StaticMover sm) { sinkTimer = 0.4f; }
public override void OnStaticMoverTrigger(StaticMover sm) { hasStartedFalling = true; }
public override void OnStaticMoverTrigger(StaticMover sm) { base.OnStaticMoverTrigger(sm); triggered = true; }