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 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); }