public override void Update() { grace = Math.Max(0, grace - Engine.DeltaTime); springGrace = Math.Max(0, springGrace - Engine.DeltaTime); timeAcc += Engine.DeltaTime; updateColors(); updateDiscoShell(); bool useMovingVisuals = Speed.X != 0 || Get <MarioClearPipeInteraction>()?.CurrentClearPipe != null; decorationMoving.Visible = shellMoving.Visible = useMovingVisuals; decorationIdle.Visible = shellIdle.Visible = !useMovingVisuals; if (!Hold.IsHeld) { Speed.Y = OnGround() && Speed.Y >= 0 ? 0f : Calc.Approach(Speed.Y, 200f, 400f * Engine.DeltaTime); MoveH(Speed.X * Engine.DeltaTime, onCollideH, null); MoveV(Speed.Y * Engine.DeltaTime, onCollideV, null); if (OnGround() && LiftSpeed == Vector2.Zero && prevLiftspeed != Vector2.Zero) { Speed = prevLiftspeed; Speed.X = Math.Sign(Speed.X) * baseSpeed; prevLiftspeed = Vector2.Zero; } prevLiftspeed = LiftSpeed; } else { prevLiftspeed = Vector2.Zero; } if (!Hold.IsHeld && Collider == shellHeldCollider && grace == 0) { Collider = shellNotHeldCollider; if (CollideCheck <Solid>()) { Collider = shellHeldCollider; } } Hold.CheckAgainstColliders(); Hold.PickupCollider = grabbable && Math.Abs(Speed.X) <= 10e-6 ? pickupIdleCollider : pickupMovingCollider; base.Update(); }
public override void Update() { base.Update(); if (_soundTimerX > 0f) { _soundTimerX -= Engine.DeltaTime; } if (_soundTimerY > 0f) { _soundTimerY -= Engine.DeltaTime; } if (Hold.IsHeld) { _prevLiftSpeed = Vector2.Zero; } else if (!ConveyorMover.IsOnConveyor) { if (OnGround()) { float target = (!OnGround(Position + Vector2.UnitX * 3f)) ? 20f : (OnGround(Position - Vector2.UnitX * 3f) ? 0f : (-20f)); Speed.X = Calc.Approach(Speed.X, target, 800f * Engine.DeltaTime); Vector2 liftSpeed = base.LiftSpeed; if (liftSpeed == Vector2.Zero && _prevLiftSpeed != Vector2.Zero) { Speed = _prevLiftSpeed; _prevLiftSpeed = Vector2.Zero; Speed.Y = Math.Min(Speed.Y * 0.6f, 0f); if (Speed.X != 0f && Speed.Y == 0f) { Speed.Y = -60f; } if (Speed.Y < 0f) { _noGravityTimer = 0.15f; } } else { _prevLiftSpeed = liftSpeed; if (liftSpeed.Y < 0f && Speed.Y < 0f) { Speed.Y = 0f; } } } else if (Hold.ShouldHaveGravity) { float accY = 800f; if (Math.Abs(Speed.Y) <= 30f) { accY *= 0.5f; } float accX = 350f; if (Speed.Y < 0f) { accX *= 0.5f; } Speed.X = Calc.Approach(Speed.X, 0f, accX * Engine.DeltaTime); if (_noGravityTimer > 0f) { _noGravityTimer -= Engine.DeltaTime; } else { Speed.Y = Calc.Approach(Speed.Y, 300f, accY * Engine.DeltaTime); } } MoveH(Speed.X * Engine.DeltaTime, OnCollideH); MoveV(Speed.Y * Engine.DeltaTime, OnCollideV); if (IsSpecial) { if (Left < _level.Bounds.Left) { Left = _level.Bounds.Left; Speed.X *= -0.4f; } else if (Right > _level.Bounds.Right) { Right = _level.Bounds.Right; Speed.X *= -0.4f; } else if (Top < _level.Bounds.Top - 4) { Top = _level.Bounds.Top - 4; Speed.Y = 0; } else if (Bottom > _level.Bounds.Bottom + 4) { Shatter(); } } if (_isCrucial && Bottom > _level.Bounds.Bottom + 4) { Shatter(); } if (Left > _level.Bounds.Right + 8 || Right < _level.Bounds.Left - 8 || Top > _level.Bounds.Bottom + 8 || Bottom < _level.Bounds.Top - 8) { RemoveSelf(); } } if (Collidable) { Hold.CheckAgainstColliders(); } if (_tutorial && OnGround(4) && !ConveyorMover.IsOnConveyor && _tutorialCarry == null) { _tutorialCarry = new BirdTutorialGui(this, new Vector2(0f, -24f), Dialog.Clean("tutorial_carry"), Dialog.Clean("tutorial_hold"), Input.Grab); _tutorialCarry.Open = true; Scene.Add(_tutorialCarry); } }
public override void Update() { if (boostDuration > 0) { boostDuration -= Engine.DeltaTime; } if (hardVerticalHitSoundCooldown > 0) { hardVerticalHitSoundCooldown -= Engine.DeltaTime; } Hold.CheckAgainstColliders(); updateVisuals(); makeSparks(); if (Hold.IsHeld && Hold.Holder.OnGround() || !Hold.IsHeld && OnGround()) { landed(); } if (Hold.IsHeld) { prevLiftSpeed = Vector2.Zero; interactibleHoldable?.OnHoldUpdate?.Invoke(Hold); } else { if (OnGround()) { float target = (!OnGround(Position + Vector2.UnitX * 3f)) ? 20f : (OnGround(Position - Vector2.UnitX * 3f) ? 0f : (-20f)); Speed.X = Calc.Approach(Speed.X, target, 800f * Engine.DeltaTime); Vector2 liftSpeed = base.LiftSpeed; if (liftSpeed == Vector2.Zero && prevLiftSpeed != Vector2.Zero) { Speed = prevLiftSpeed; prevLiftSpeed = Vector2.Zero; Speed.Y = Math.Min(Speed.Y * 0.6f, 0f); if (Speed.X != 0f && Speed.Y == 0f) { Speed.Y = -60f; } if (Speed.Y < 0f) { noGravityTimer = 0.15f; } } else { prevLiftSpeed = liftSpeed; if (liftSpeed.Y < 0f && Speed.Y < 0f) { Speed.Y = 0f; } } } else if (Hold.ShouldHaveGravity) { float speedXMaxMove = 350f; float speedYMaxMove = 800f; if (Math.Abs(Speed.Y) <= 30f) { speedYMaxMove *= 0.5f; } if (Speed.Y < 0f) { speedXMaxMove *= 0.5f; } Speed.X = Calc.Approach(Speed.X, 0f, speedXMaxMove * Engine.DeltaTime); if (noGravityTimer > 0f) { noGravityTimer -= Engine.DeltaTime; } else { if (level.Wind.Y < 0f) { Speed.Y = Calc.Approach(Speed.Y, 0f, speedYMaxMove * Engine.DeltaTime); } else { Speed.Y = Calc.Approach(Speed.Y, 30f, speedYMaxMove * Engine.DeltaTime); } } } previousPosition = base.ExactPosition; MoveH(Speed.X * Engine.DeltaTime, onCollideH); MoveV(Speed.Y * Engine.DeltaTime, onCollideV); } base.Update(); }
public override void Update() { base.Update(); if (Charge > 0 && base.Scene.OnInterval(fresh ? 0.5f : 0.1f)) { bool collided = false; foreach (FakeWall wall in Scene.Tracker.GetEntities <FakeWall>()) { if (wall.Collider.Collide(this)) { collided = true; } } if (!collided) { Level.ParticlesFG.Emit(particle, Hold.IsHeld ? 2 : 1, Position + particleOffset, Vector2.One * 5f); } } if (dead) { return; } if (swatTimer > 0f) { swatTimer -= Engine.DeltaTime; } hardVerticalHitSoundCooldown -= Engine.DeltaTime; base.Depth = 100; if (base.Scene.OnInterval(0.5f) && Running && Charge > 0) { Charge -= DischargeRate / 2; } string newSprite; ParticleType newParticle = P_Low; if (DischargeRate == 0) { newSprite = "infinite"; newParticle = P_Infinite; } else if (fresh && Charge == MaxCharge) { newSprite = "fresh"; newParticle = P_Full; } else if (Charge > MaxCharge / 2) { newSprite = "full"; newParticle = P_Full; } else if (Charge > MaxCharge / 5) { newSprite = "half"; newParticle = P_Half; } else if (Charge > 0) { newSprite = "low"; newParticle = P_Low; } else { newSprite = "empty"; } if (sprite.CurrentAnimationID != newSprite) { sprite.Play(newSprite); particle = newParticle; if (newSprite == "empty") { Audio.Play("event:/classic/sfx0", Position); Level.ParticlesFG.Emit(particle, 30, Position + particleOffset, Vector2.One * 10f); } else if (newSprite != "infinite" && newSprite != "full" && newSprite != "fresh") { Audio.Play("event:/classic/sfx1", Position); } } if (Hold.IsHeld) { if (!Running) { Running = true; fresh = false; } prevLiftSpeed = Vector2.Zero; LastHeld = this; } else { if (OnGround()) { float target = (!OnGround(Position + Vector2.UnitX * 3f)) ? 20f : (OnGround(Position - Vector2.UnitX * 3f) ? 0f : (-20f)); Speed.X = Calc.Approach(Speed.X, target, 800f * Engine.DeltaTime); Vector2 liftSpeed = base.LiftSpeed; if (liftSpeed == Vector2.Zero && prevLiftSpeed != Vector2.Zero) { Speed = prevLiftSpeed; prevLiftSpeed = Vector2.Zero; Speed.Y = Math.Min(Speed.Y * 0.6f, 0f); if (Speed.X != 0f && Speed.Y == 0f) { Speed.Y = -60f; } if (Speed.Y < 0f) { noGravityTimer = 0.15f; } } else { prevLiftSpeed = liftSpeed; if (liftSpeed.Y < 0f && Speed.Y < 0f) { Speed.Y = 0f; } } } else if (Hold.ShouldHaveGravity) { float num = 800f; if (Math.Abs(Speed.Y) <= 30f) { num *= 0.5f; } float num2 = 350f; if (Speed.Y < 0f) { num2 *= 0.5f; } Speed.X = Calc.Approach(Speed.X, 0f, num2 * Engine.DeltaTime); if (noGravityTimer > 0f) { noGravityTimer -= Engine.DeltaTime; } else { Speed.Y = Calc.Approach(Speed.Y, 200f, num * Engine.DeltaTime); } } previousPosition = base.ExactPosition; MoveH(Speed.X * Engine.DeltaTime, onCollideH); MoveV(Speed.Y * Engine.DeltaTime, onCollideV); if (base.Right > (float)Level.Bounds.Right) { base.Right = Level.Bounds.Right; CollisionData data = new CollisionData { Direction = Vector2.UnitX }; OnCollideH(data); } else if (base.Left < (float)Level.Bounds.Left) { base.Left = Level.Bounds.Left; CollisionData data = new CollisionData { Direction = -Vector2.UnitX }; OnCollideH(data); } else if (base.Bottom > (float)Level.Bounds.Bottom && SaveData.Instance.Assists.Invincible) { base.Bottom = Level.Bounds.Bottom; Speed.Y = -300f; Audio.Play("event:/game/general/assist_screenbottom", Position); } else if (base.Top > (float)Level.Bounds.Bottom) { RemoveSelf(); } Player entity = base.Scene.Tracker.GetEntity <Player>(); BatteryGate templeGate = CollideFirst <BatteryGate>(); if (templeGate != null && entity != null) { templeGate.Collidable = false; MoveH((float)(Math.Sign(entity.X - base.X) * 32) * Engine.DeltaTime); templeGate.Collidable = true; } } if (!dead) { foreach (BatteryCollider batteryCollider in base.Scene.Tracker.GetComponents <BatteryCollider>()) { batteryCollider.Check(this); } Hold.CheckAgainstColliders(); if (!ignoreBarriers) { foreach (SeekerBarrier entity in base.Scene.Tracker.GetEntities <SeekerBarrier>()) { entity.Collidable = true; bool flag = CollideCheck(entity); entity.Collidable = false; if (flag) { entity.OnReflectSeeker(); Die(); } } } } if (hitSeeker != null && swatTimer <= 0f && !hitSeeker.Check(Hold)) { hitSeeker = null; } }