public void TurnOn() { if (!Activated) { doEffect(() => touchSfx.Play(hitSound)); Activated = true; // animation doEffect(() => { wiggler.Start(); for (int i = 0; i < 32; i++) { float num = Calc.Random.NextFloat((float)Math.PI * 2f); level.Particles.Emit(TouchSwitch.P_FireWhite, Position + Calc.AngleToVector(num, 6f), num); } }); icon.Rate = 4f; HandleCollectedFlagTouchSwitch(flag, inverted, persistent, level, id, allTouchSwitchesInRoom, allMovingFlagTouchSwitchesInRoom, () => doEffect(() => { SoundEmitter.Play(completeSoundFromScene); Add(new SoundSource(completeSoundFromSwitch)); })); } }
public IEnumerator UseRoutine(Vector2 target) { Turning = true; follower.MoveTowardsLeader = false; wiggler.Start(); wobbleActive = false; sprite.Y = 0f; Vector2 from = Position; SimpleCurve curve = new SimpleCurve(from, target, (target + from) / 2f + new Vector2(0f, -48f)); tween = Tween.Create(Tween.TweenMode.Oneshot, Ease.CubeOut, 1f, start: true); tween.OnUpdate = delegate(Tween t) { Position = curve.GetPoint(t.Eased); sprite.Rate = 1f + t.Eased * 2f; }; Add(tween); yield return(tween.Wait()); tween = null; while (sprite.CurrentAnimationFrame != 0) { yield return(null); } shimmerParticles.Active = false; Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium); for (int j = 0; j < 16; j++) { SceneAs <Level>().ParticlesFG.Emit(P_Insert, Center, (float)Math.PI / 8f * (float)j); } sprite.Visible = false; light.Visible = false; Turning = false; }
public override void Update() { base.Update(); // fade the menu in or out openingEase = Calc.Approach(openingEase, opened ? 1f : 0f, Engine.DeltaTime * 4f); if (opened) { if (Input.MenuCancel.Pressed) { // cancelled out opened = false; wiggler.Start(); Audio.Play("event:/ui/main/button_back"); onCancel(); } else if (Input.MenuUp.Pressed && currentlySelectedOption > 0) { // move up to "yes" currentlySelectedOption = 0; wiggler.Start(); Audio.Play("event:/ui/main/rollover_up"); } else if (Input.MenuDown.Pressed && currentlySelectedOption < 1) { // move down to "no" currentlySelectedOption = 1; wiggler.Start(); Audio.Play("event:/ui/main/rollover_down"); } else if (Input.MenuConfirm.Pressed) { if (currentlySelectedOption == 1) { // pressed "no" opened = false; wiggler.Start(); Audio.Play("event:/ui/main/button_back"); onCancel(); } else { // pressed "yes" RemoveSelf(); Audio.Play("event:/ui/main/button_select"); onConfirm(); } } } else if (openingEase <= 0f) { // finished fading out RemoveSelf(); } }
private void turnOn() { if (!activated) { touchSfx.Play("event:/game/general/touchswitch_any"); activated = true; // animation wiggler.Start(); for (int i = 0; i < 32; i++) { float num = Calc.Random.NextFloat((float)Math.PI * 2f); level.Particles.Emit(TouchSwitch.P_FireWhite, Position + Calc.AngleToVector(num, 6f), num); } icon.Rate = 4f; if (persistent) { // this switch is persistent. save its activation in the session. level.Session.SetFlag(flag + "_switch" + id, true); } if ((SpringCollab2020MapDataProcessor.FlagTouchSwitches.Count <= level.Session.Area.ID || SpringCollab2020MapDataProcessor.FlagTouchSwitches[level.Session.Area.ID][(int)level.Session.Area.Mode][flag] .All(touchSwitchID => touchSwitchID.Level == level.Session.Level || level.Session.GetFlag(flag + "_switch" + touchSwitchID.ID))) && allTouchSwitchesInRoom.All(touchSwitch => touchSwitch.activated)) { // all switches in the room are enabled, and all session flags for switches outside the room are enabled. // so, the group is complete. foreach (FlagTouchSwitch touchSwitch in allTouchSwitchesInRoom) { touchSwitch.finish(); } SoundEmitter.Play("event:/game/general/touchswitch_last_oneshot"); Add(new SoundSource("event:/game/general/touchswitch_last_cutoff")); // trigger associated switch gate(s). foreach (FlagSwitchGate switchGate in Scene.Tracker.GetEntities <FlagSwitchGate>().OfType <FlagSwitchGate>()) { if (switchGate.Flag == flag) { switchGate.Trigger(); } } // if all the switches are persistent, the flag it's setting is persistent. if (allTouchSwitchesInRoom.All(touchSwitch => touchSwitch.persistent)) { level.Session.SetFlag(flag, true); } } } }
private void Respawn() { if (!Collidable) { Collidable = true; sprite.Visible = true; outline.Visible = false; Depth = Depths.Pickups; wiggler.Start(); shieldRadiusWiggle.Start(); Audio.Play(twoDashes ? CustomSFX.game_shieldedRefill_pinkdiamond_return : CustomSFX.game_shieldedRefill_diamond_return, Position); level.ParticlesFG.Emit(p_regen, 16, Position, Vector2.One * 2f); } }
public void OnPlayer(Player player) { if (Follower.Leader == null && !collected && !WaitingOnSeeds) { ReturnHomeWhenLost = true; if (Winged) { Level level = SceneAs <Level>(); Winged = false; sprite.Rate = 0f; Alarm.Set(this, Follower.FollowDelay, delegate { sprite.Rate = 1f; sprite.Play("idle"); level.Particles.Emit(Strawberry.P_WingsBurst, 8, Position + new Vector2(8f, 0f), new Vector2(4f, 2f)); level.Particles.Emit(Strawberry.P_WingsBurst, 8, Position - new Vector2(8f, 0f), new Vector2(4f, 2f)); }); } if (Golden) { (Scene as Level).Session.GrabbedGolden = true; } Audio.Play(isGhostBerry ? strawberryBlueTouchSound : strawberryTouchSound, Position); player.Leader.GainFollower(Follower); wiggler.Start(); Depth = -1000000; } }
public void EndTimer() { if (!timerEnded) { timerEnded = true; fadeTime = 5f; endChapterTimer = SceneAs <Level>().Session.Time; wiggler.Start(); // save the PB if this was beaten. long time = endChapterTimer - startChapterTimer; bool newPB = true; if (CollabModule.Instance.SaveData.SpeedBerryPBs.TryGetValue(SceneAs <Level>().Session.Area.GetSID(), out long pb)) { if (time > pb) { newPB = false; } } if (newPB) { CollabModule.Instance.SaveData.SpeedBerryPBs[SceneAs <Level>().Session.Area.GetSID()] = time; } if (CollabModule.Instance.Settings.HideSpeedBerryTimerDuringGameplay) { // display speed berry timer. createTween(0.6f, t => { Position = Vector2.Lerp(offscreenPosition, onscreenPosition, t.Eased); }); } } }
public void OnPlayer(Player player) { Level level = Scene as Level; if (!Collected && !level.Frozen) { if (player.DashAttacking) { Collect(player, level); return; } if (bounceSfxDelay <= 0f) { if (Heart.IsFake) { Audio.Play(SFX.game_10_fakeheart_bounce, Position); } else { Audio.Play(SFX.game_gen_crystalheart_bounce, Position); } bounceSfxDelay = 0.1f; } player.PointBounce(Center, 110f); scaleWiggler.Start(); moveWiggler.Start(); moveWiggleDir = (Center - player.Center).SafeNormalize(Vector2.UnitY); Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium); } }
private void BounceAnimate() { Audio.Play("event:/game/general/spring", base.BottomCenter); staticMover.TriggerPlatform(); sprite.Play("bounce", restart: true); wiggler.Start(); }
private IEnumerator FlyAwayRoutine() { rotateWiggler.Start(); flapSpeed = -200f; Tween tween = Tween.Create(Tween.TweenMode.Oneshot, Ease.CubeOut, 0.25f, start: true); tween.OnUpdate = delegate(Tween t) { flapSpeed = MathHelper.Lerp(-200f, 0f, t.Eased); }; Add(tween); yield return(0.1f); Audio.Play("event:/game/general/strawberry_laugh", Position); yield return(0.2f); if (!Follower.HasLeader) { Audio.Play("event:/game/general/strawberry_flyaway", Position); } tween = Tween.Create(Tween.TweenMode.Oneshot, null, 0.5f, start: true); tween.OnUpdate = delegate(Tween t) { flapSpeed = MathHelper.Lerp(0f, -200f, t.Eased); }; Add(tween); }
private void onPlayer(Player player) { Level level = Scene as Level; if (player.DashAttacking || !requireDashToBreak) { // player broke the heart heartBroken(player, null, level); } else { // player bounces on the heart int dashCount = player.Dashes; player.PointBounce(Center); if (!refillDash) { player.Dashes = dashCount; } moveWiggler.Start(); scaleWiggler.Start(); moveWiggleDir = (Center - player.Center).SafeNormalize(Vector2.UnitY); Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium); if (bounceSfxDelay <= 0f) { Audio.Play("event:/game/general/crystalheart_bounce", Position); bounceSfxDelay = 0.1f; } } }
private IEnumerator Respawn() { while (true) { Collidable = true; if (!CollideCheck <Player>()) { break; } else { Collidable = false; yield return(null); } } if (_broken) { _gemSprite.Visible = _shineSprite.Visible = _dangerSprite.Visible = true; _outline.Visible = false; Depth = -100; _wiggler.Start(); Audio.Play("event:/game/general/diamond_return", Position); _level.ParticlesFG.Emit(P_Regen, 16, Position, Vector2.One * 4f); _broken = false; } }
public override IEnumerator Enter(Oui from) { audioPrevMusic = Audio.GetEventName(Audio.CurrentMusicEventInstance); Audio.SetMusic(null); audioPrevAmbience = Audio.GetEventName(Audio.CurrentAmbienceEventInstance); Audio.SetAmbience(null); Visible = true; musicParamMenu = new TextMenu(); musicParamMenu.Focused = false; musicParamMenu.MinWidth = 500f; for (int i = 0; i < digits.Length; i++) { digits[i] = 0; } selectedDigit = digits.Length - 1; UpdateSelectedPath(); Vector2 posFrom = Position; Vector2 posTo = Vector2.Zero; for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f) { ease = Ease.CubeIn(t); Position = posFrom + (posTo - posFrom) * Ease.CubeInOut(t); yield return(null); } ease = 1f; posFrom = Vector2.Zero; posTo = Vector2.Zero; yield return(0.2f); Focused = true; yield return(0.2f); for (int i = 0; i < digits.Length; i++) { wigglerDigits[i].Start(); } wigglerPath.Start(); wigglerBankPath.Start(); }
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); }
private void KillPlayer(Player player) { Vector2 direction = (player.Center - base.Center).SafeNormalize(); if (player.Die(direction) != null) { _hitDir = direction; _hitWiggler.Start(); } }
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()); }
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; } }
public override void Update() { if (minigame.completed) { if (CompleteTimer == 0f) { wiggler.Start(); } CompleteTimer += Engine.DeltaTime; } DrawLerp = Calc.Approach(DrawLerp, 1, Engine.DeltaTime * 4f); base.Update(); }
private void Respawn() { if (!base.Collidable) { base.Collidable = true; sprite.Visible = true; outline.Visible = false; base.Depth = -100; wiggler.Start(); Audio.Play("event:/game/general/diamond_return", base.Position); //level.ParticlesFG.Emit(P_Regen, 16, base.Position, Vector2.One * 2f); } }
// We added a PlayerCollider handler in the constructor. This routine is called when it is triggered. public void OnPlayer(Player player) { // Bail if we're not ready to be picked up, or are already picked up. if (Follower.Leader != null || collected || WaitingOnSeeds || wasBroken) { return; } // Let's play a pickup sound and trigger the Wiggler to make the strawberry temporarily change size when we touch it. Audio.Play(isOwned ? "event:/game/general/strawberry_blue_touch" : "event:/game/general/strawberry_touch", Position); player.Leader.GainFollower(Follower); wiggler.Start(); Depth = -1000000; }
private void OnPlayer(Player player) { player.PointBounce(Center); if (Input.MoveX.Value == Math.Sign(player.Speed.X)) { player.Speed.X *= 1.2f; } moveWiggle.Start(); shieldRadiusWiggle.Start(); moveWiggleDir = (Center - player.Center).SafeNormalize(Vector2.UnitY); Audio.Play("event:/game/06_reflection/feather_bubble_bounce", Position); Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium); level.DirectionalShake((player.Center - Center).SafeNormalize(), 0.15f); }
public void Respawn() { if (!Collidable) { Collidable = true; sprite.Visible = true; outline.Visible = false; base.Depth = -100; wiggler.Start(); Audio.Play("event:/game/general/diamond_return", Position); } }
public DashCollisionResults Dashed(Player player, Vector2 dir) { if (!SaveData.Instance.Assists.Invincible) { if (dir == Vector2.UnitX && spikesLeft) { return(DashCollisionResults.NormalCollision); } if (dir == -Vector2.UnitX && spikesRight) { return(DashCollisionResults.NormalCollision); } if (dir == Vector2.UnitY && spikesUp) { return(DashCollisionResults.NormalCollision); } if (dir == -Vector2.UnitY && spikesDown) { return(DashCollisionResults.NormalCollision); } } if (canSwitch) { Sfx.Play(CustomSFX.game_trackSwitchBox_smash, "global_switch", global ? 1f : 0f); (Scene as Level).DirectionalShake(dir); sprite.Scale = new Vector2(1f + Math.Abs(dir.Y) * 0.4f - Math.Abs(dir.X) * 0.4f, 1f + Math.Abs(dir.X) * 0.4f - Math.Abs(dir.Y) * 0.4f); shakeCounter = 0.2f; shaker.On = true; bounceDir = dir; bounce.Start(); smashParticles = true; Pulse(); Add(new Coroutine(SwitchSequence())); Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium); canSwitch = false; Switch(Scene, LocalTrackSwitchState.Invert(), global); return(DashCollisionResults.Rebound); } return(DashCollisionResults.NormalCollision); }
public void OnPlayer(Player player) { if (collected || (base.Scene as Level).Frozen) { return; } if (player.DashAttacking) { Collect(player); return; } if (bounceSfxDelay <= 0f) { Audio.Play("event:/game/general/crystalheart_bounce", Position); bounceSfxDelay = 0.1f; } player.PointBounce(base.Center); moveWiggler.Start(); ScaleWiggler.Start(); moveWiggleDir = (base.Center - player.Center).SafeNormalize(Vector2.UnitY); Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium); }
public void OnPlayer(Player player) { if (Follower.Leader == null && !collected) { ReturnHomeWhenLost = true; if (Winged) { Level level = SceneAs <Level>(); Winged = false; sprite.Rate = 0f; Alarm.Set(this, Follower.FollowDelay, delegate { sprite.Rate = 1f; sprite.Play("idle", false, false); level.Particles.Emit(Strawberry.P_WingsBurst, 8, Position + new Vector2(8f, 0f), new Vector2(4f, 2f)); level.Particles.Emit(Strawberry.P_WingsBurst, 8, Position - new Vector2(8f, 0f), new Vector2(4f, 2f)); }, Alarm.AlarmMode.Oneshot); } Audio.Play("event:/game/general/strawberry_touch", Position); player.Leader.GainFollower(Follower); wiggler.Start(); Depth = -1000000; } }
private IEnumerator CommunalHelperSequence(Vector2 node) { this.node = node; Vector2 start = Position; while (!Switch.Check(Scene)) { yield return(null); } if (permanent) { Switch.SetLevelFlag(SceneAs <Level>()); } yield return(0.1f); openSfx.Play(SFX.game_gen_touchswitch_gate_open); StartShaking(0.5f); while (icon.Rate < 1f) { icon.Color = Color.Lerp(inactiveColor, activeColor, icon.Rate); icon.Rate += Engine.DeltaTime * 2f; yield return(null); } yield return(0.1f); int particleAt = 0; Tween tween = Tween.Create(Tween.TweenMode.Oneshot, Ease.CubeOut, 2f, start: true); tween.OnUpdate = t => { MoveTo(Vector2.Lerp(start, node, t.Eased)); if (Scene.OnInterval(0.1f)) { particleAt++; particleAt %= 2; for (int n = 0; n < Width / 8f; n++) { for (int num2 = 0; num2 < Height / 8f; num2++) { if ((n + num2) % 2 == particleAt) { ParticleType pType = Calc.Random.Choose(P_BehindDreamParticles); SceneAs <Level>().ParticlesBG.Emit(pType, Position + new Vector2(n * 8, num2 * 8) + Calc.Random.Range(Vector2.One * 2f, Vector2.One * 6f)); } } } } }; Add(tween); yield return(1.8f); bool collidable = Collidable; Collidable = false; if (node.X <= start.X) { Vector2 value = new Vector2(0f, 2f); for (int i = 0; i < Height / 8f; i++) { Vector2 vector = new Vector2(Left - 1f, Top + 4f + i * 8); Vector2 point = vector + Vector2.UnitX; if (Scene.CollideCheck <Solid>(vector) && !Scene.CollideCheck <Solid>(point)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, vector + value, (float)Math.PI); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, vector - value, (float)Math.PI); } } } if (node.X >= start.X) { Vector2 value = new Vector2(0f, 2f); for (int j = 0; j < Height / 8f; j++) { Vector2 vector = new Vector2(Right + 1f, Top + 4f + j * 8); Vector2 point = vector - Vector2.UnitX * 2f; if (Scene.CollideCheck <Solid>(vector) && !Scene.CollideCheck <Solid>(point)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, vector + value, 0f); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, vector - value, 0f); } } } if (node.Y <= start.Y) { Vector2 value = new Vector2(2f, 0f); for (int k = 0; k < Width / 8f; k++) { Vector2 vectpr = new Vector2(Left + 4f + k * 8, Top - 1f); Vector2 point = vectpr + Vector2.UnitY; if (Scene.CollideCheck <Solid>(vectpr) && !Scene.CollideCheck <Solid>(point)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, vectpr + value, -(float)Math.PI / 2f); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, vectpr - value, -(float)Math.PI / 2f); } } } if (node.Y >= start.Y) { Vector2 value = new Vector2(2f, 0f); for (int l = 0; l < Width / 8f; l++) { Vector2 vector = new Vector2(Left + 4f + l * 8, Bottom + 1f); Vector2 point = vector - Vector2.UnitY * 2f; if (Scene.CollideCheck <Solid>(vector) && !Scene.CollideCheck <Solid>(point)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, vector + value, (float)Math.PI / 2f); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, vector - value, (float)Math.PI / 2f); } } } Collidable = collidable; Audio.Play(SFX.game_gen_touchswitch_gate_finish, Position); StartShaking(0.2f); while (icon.Rate > 0f) { icon.Color = Color.Lerp(activeColor, finishColor, 1f - icon.Rate); icon.Rate -= Engine.DeltaTime * 4f; yield return(null); } icon.Rate = 0f; icon.SetAnimationFrame(0); wiggler.Start(); bool collidable2 = Collidable; Collidable = false; if (!Scene.CollideCheck <Solid>(Center)) { for (int m = 0; m < 32; m++) { float num = Calc.Random.NextFloat((float)Math.PI * 2f); SceneAs <Level>().ParticlesFG.Emit(TouchSwitch.P_Fire, Center + Calc.AngleToVector(num, 4f), num); } } Collidable = collidable2; }
public override IEnumerator Enter(Oui from) { TextInput.OnInput += OnKeyboardInput; Overworld.ShowInputUI = false; selectingOptions = false; optionsIndex = 0; index = 0; line = 0; // Create the keyboard, and take the measurements for it. string letterChars = "7 8 9\n4 5 6\n1 2 3\n- 0 ."; letters = letterChars.Split('\n'); foreach (char c in letterChars) { float width = ActiveFont.Measure(c).X; if (width > widestLetter) { widestLetter = width; } } widestLineCount = 0; foreach (string letter in letters) { if (letter.Length > widestLineCount) { widestLineCount = letter.Length; } } widestLine = widestLineCount * widestLetter; letterChars = null; boxPadding = widestLetter; keyboardWidth = widestLine + boxPadding * 2f; lineHeight = ActiveFont.LineHeight; lineSpacing = ActiveFont.LineHeight * 0.1f; // take the measurements for options. optionsScale = 0.75f; cancel = Dialog.Clean("name_back"); backspace = Dialog.Clean("name_backspace"); accept = Dialog.Clean("name_accept"); cancelWidth = ActiveFont.Measure(cancel).X *optionsScale; backspaceWidth = ActiveFont.Measure(backspace).X *optionsScale; acceptWidth = ActiveFont.Measure(accept).X *optionsScale; optionsWidth = cancelWidth + backspaceWidth + acceptWidth + widestLetter * 3f; boxWidth = Math.Max(widestLine, optionsWidth) + boxPadding * 2f; boxHeight = (letters.Length + 1f) * lineHeight + letters.Length * lineSpacing + boxPadding * 3f; Visible = true; // Ease the keyboard in. Vector2 posFrom = Position; Vector2 posTo = Vector2.Zero; for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f) { ease = Ease.CubeIn(t); Position = posFrom + (posTo - posFrom) * Ease.CubeInOut(t); yield return(null); } ease = 1f; posFrom = Vector2.Zero; posTo = Vector2.Zero; yield return(0.2f); Focused = true; yield return(0.2f); wiggler.Start(); }
private IEnumerator moveSequence(Vector2 node, bool goingBack) { Vector2 start = Position; Color fromColor, toColor; if (!goingBack) { fromColor = inactiveColor; toColor = finishColor; while ((!Triggered || allowReturn) && !SceneAs <Level>().Session.GetFlag(Flag)) { yield return(null); } } else { fromColor = finishColor; toColor = inactiveColor; while (SceneAs <Level>().Session.GetFlag(Flag)) { yield return(null); } } yield return(0.1f); if (shouldCancelMove(goingBack)) { yield break; } // animate the icon openSfx.Play(moveSound); if (shakeTime > 0f) { StartShaking(shakeTime); while (icon.Rate < 1f) { icon.Color = Color.Lerp(fromColor, activeColor, icon.Rate); icon.Rate += Engine.DeltaTime / shakeTime; yield return(null); if (shouldCancelMove(goingBack)) { yield break; } } } else { icon.Rate = 1f; } yield return(0.1f); if (shouldCancelMove(goingBack)) { yield break; } // move the switch gate, emitting particles along the way int particleAt = 0; Tween tween = Tween.Create(Tween.TweenMode.Oneshot, moveEased ? Ease.CubeOut : null, moveTime + (moveEased ? 0.2f : 0f), start: true); tween.OnUpdate = tweenArg => { MoveTo(Vector2.Lerp(start, node, tweenArg.Eased)); if (Scene.OnInterval(0.1f)) { particleAt++; particleAt %= 2; for (int tileX = 0; tileX < Width / 8f; tileX++) { for (int tileY = 0; tileY < Height / 8f; tileY++) { if ((tileX + tileY) % 2 == particleAt) { SceneAs <Level>().ParticlesBG.Emit(SwitchGate.P_Behind, Position + new Vector2(tileX * 8, tileY * 8) + Calc.Random.Range(Vector2.One * 2f, Vector2.One * 6f)); } } } } }; Add(tween); float moveTimeLeft = moveTime; while (moveTimeLeft > 0f) { yield return(null); moveTimeLeft -= Engine.DeltaTime; if (shouldCancelMove(goingBack, tween)) { yield break; } } bool collidableBackup = Collidable; Collidable = false; // collide dust particles on the left if (node.X <= start.X) { Vector2 add = new Vector2(0f, 2f); for (int tileY = 0; tileY < Height / 8f; tileY++) { Vector2 collideAt = new Vector2(Left - 1f, Top + 4f + (tileY * 8)); Vector2 noCollideAt = collideAt + Vector2.UnitX; if (Scene.CollideCheck <Solid>(collideAt) && !Scene.CollideCheck <Solid>(noCollideAt)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt + add, (float)Math.PI); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt - add, (float)Math.PI); } } } // collide dust particles on the rigth if (node.X >= start.X) { Vector2 add = new Vector2(0f, 2f); for (int tileY = 0; tileY < Height / 8f; tileY++) { Vector2 collideAt = new Vector2(Right + 1f, Top + 4f + (tileY * 8)); Vector2 noCollideAt = collideAt - Vector2.UnitX * 2f; if (Scene.CollideCheck <Solid>(collideAt) && !Scene.CollideCheck <Solid>(noCollideAt)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt + add, 0f); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt - add, 0f); } } } // collide dust particles on the top if (node.Y <= start.Y) { Vector2 add = new Vector2(2f, 0f); for (int tileX = 0; tileX < Width / 8f; tileX++) { Vector2 collideAt = new Vector2(Left + 4f + (tileX * 8), Top - 1f); Vector2 noCollideAt = collideAt + Vector2.UnitY; if (Scene.CollideCheck <Solid>(collideAt) && !Scene.CollideCheck <Solid>(noCollideAt)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt + add, -(float)Math.PI / 2f); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt - add, -(float)Math.PI / 2f); } } } // collide dust particles on the bottom if (node.Y >= start.Y) { Vector2 add = new Vector2(2f, 0f); for (int tileX = 0; tileX < Width / 8f; tileX++) { Vector2 collideAt = new Vector2(Left + 4f + (tileX * 8), Bottom + 1f); Vector2 noCollideAt = collideAt - Vector2.UnitY * 2f; if (Scene.CollideCheck <Solid>(collideAt) && !Scene.CollideCheck <Solid>(noCollideAt)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt + add, (float)Math.PI / 2f); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt - add, (float)Math.PI / 2f); } } } Collidable = collidableBackup; // moving is over Audio.Play(finishedSound, Position); StartShaking(0.2f); while (icon.Rate > 0f) { icon.Color = Color.Lerp(activeColor, toColor, 1f - icon.Rate); icon.Rate -= Engine.DeltaTime * 4f; yield return(null); if (shouldCancelMove(goingBack)) { yield break; } } icon.Rate = 0f; icon.SetAnimationFrame(0); wiggler.Start(); // emit fire particles if the block is not behind a solid. collidableBackup = Collidable; Collidable = false; if (!Scene.CollideCheck <Solid>(Center)) { for (int i = 0; i < 32; i++) { float angle = Calc.Random.NextFloat((float)Math.PI * 2f); SceneAs <Level>().ParticlesFG.Emit(goingBack ? P_RecoloredFireBack : P_RecoloredFire, Position + iconOffset + Calc.AngleToVector(angle, 4f), angle); } } Collidable = collidableBackup; }
private void OnGainLeader() { wiggler.Start(); canLoseTimer = LoseDelay; loseTimer = LoseGraceTime; }
public override void Awake(Scene scene) { base.Awake(scene); Level level = base.Scene as Level; if (level.Session.HeartGem) { RemoveSelf(); return; } AreaKey area = level.Session.Area; IsGhost = (SaveData.Instance.Areas_Safe[area.ID].Modes[(int)area.Mode].HeartGem); if (path == string.Empty) { Add(sprite = GFX.SpriteBank.Create("heartgem3")); } else { Add(sprite = GFX.SpriteBank.Create(path)); } sprite.Play("spin"); sprite.OnLoop = delegate(string anim) { if (Visible && anim == "spin" && autoPulse) { Audio.Play("event:/game/general/crystalheart_pulse", Position); ScaleWiggler.Start(); (base.Scene as Level).Displacement.AddBurst(Position, 0.35f, 8f, 48f, 0.25f); } }; if (IsGhost) { if (path == string.Empty) { sprite.Color = Color.Lerp(color, Color.White, 0.8f) * 0.8f; } else { sprite.Color = Color.White * 0.8f; } } else if (path == string.Empty) { sprite.Color = color; } switch (path) { case "heartgem0": color = Color.Aqua; P_Shine = HeartGem.P_BlueShine; break; case "heartgem1": color = Color.Red; P_Shine = HeartGem.P_RedShine; break; case "heartgem2": color = Color.Gold; P_Shine = HeartGem.P_GoldShine; break; case "heartgem3": color = Calc.HexToColor("dad8cc"); P_Shine = HeartGem.P_FakeShine; break; } Collider = new Hitbox(16f, 16f, -8f, -8f); Add(new PlayerCollider(OnPlayer)); Add(ScaleWiggler = Wiggler.Create(0.5f, 4f, delegate(float f) { sprite.Scale = Vector2.One * (1f + f * 0.25f); })); Add(bloom = new BloomPoint(0.75f, 16f)); Color value; shineParticle = P_Shine; value = Color.Lerp(color, Color.White, 0.5f); Add(light = new VertexLight(value, 1f, 32, 64)); if (path == "heartgem3") { bloom.Alpha = 0f; light.Alpha = 0f; } moveWiggler = Wiggler.Create(0.8f, 2f); moveWiggler.StartZero = true; Add(moveWiggler); }