public override void Update(GameTime dt) { base.Update(dt); if (score == null) { for (int i = 0; i < scene.Nodes.Count; i++) { if (scene.Nodes[i] is DonutScore) { score = scene.Nodes[i] as DonutScore; } } } box.Position = Position; if (!Chosen) { if (InFan) { Timer += gttf(dt) * 2.0f; PosY += JabMath.Sin(Timer) * WindWeakness; if (Timer > 2 * JabMath.PI) { ; } Timer -= 2 * JabMath.PI; } else { Timer += gttf(dt) * 4.0f; PosY += JabMath.Sin(Timer) * 0.25f; } } else { Position = JabMath.LinearMoveTowards(Position, score.ScaledPos, gttf(dt) * 1000.0f / Camera.Get.UniformWorldScale); UniformScale = JabMath.LinearMoveTowards(UniformScale, score.ScaledScale, gttf(dt) / Camera.Get.UniformWorldScale); if (Position == score.ScaledPos && !CheckFlag(Flags.DELETE)) { RaiseFlag(Flags.DELETE); score.IncrementScore(); } } InFan = false; }
public override void Update(GameTime dt) { base.Update(dt); if (lastPos != targetPos && !LevelSelect) { float totalLength = (lastPos - targetPos).Length(); float curLength = (Position - targetPos).Length(); float prop = 1.0f - curLength / totalLength; float interp = JabMath.Sin(curLength * JabMath.PI / totalLength); if (curLength == 0 && UniformWorldScale != minScale) { if (lastcurLength != 0) { lastcurLength = 0; UniformWorldScale = minScale; } else { UniformWorldScale = JabMath.MoveTowards(UniformWorldScale, minScale, gttf(dt) * 5.0f, 0.001f); } } else if (curLength != 0) { lastcurLength = curLength; if (totalLength < 300) { UniformWorldScale = JabMath.LinearInterpolate(minScale, 1.5f, interp); } else { UniformWorldScale = JabMath.LinearInterpolate(minScale, 0.8f, interp); } } } else if (LevelSelect) { UniformWorldScale = JabMath.MoveTowards(UniformWorldScale, targetScale, gttf(dt) * 5.0f, 0.001f); } else { UniformWorldScale = JabMath.MoveTowards(UniformWorldScale, minScale, gttf(dt) * 5.0f, 0.001f); } Position = JabMath.MoveTowards(Position, targetPos, gttf(dt) * 5.0f, 5.0f); }
public override void Update(GameTime gameTime) { base.Update(gameTime); Body.UserData = this; if (health <= 0) { health = 0; if (!SplintersCreated) { CreateSplinters(); SplintersCreated = true; } RaiseFlag(Jabber.Flags.DELETE); Body.CollisionGroup = BodyNoneCollisionGroup; Body.IgnoreRayCast = true; } if (InFan) { Body.LinearVelocity = new Vector2(Body.LinearVelocity.X, 0); if (!InBentFan) { Body.LinearDamping = 150.0f; } if (fanTimer == 0) { fanTimer = RandomFloat * 2.0f * JabMath.PI; } fanTimer += gttf(gameTime) * 2.0f; Body.PosY += JabMath.Sin(fanTimer) / 3.0f; } else { Body.BodyState = JabActor.BodyType.DYNAMIC; //Body.AngularDamping = Body.LinearDamping = 0.5f; Body.LinearDamping = Body.AngularDamping = JabMath.MoveTowards(Body.LinearDamping, 0.75f, gttf(gameTime) * 3.0f); } if (InFan || InBentFan) { Body.AngularDamping = 20.0f; } InFan = false; InBentFan = false; }
public override void Update(GameTime gameTime) { base.Update(gameTime); // Rot = 0;// -0.25f * JabMath.PI;// 1.0f * JabMath.PI;// gttf(gameTime); /* * Vector2 toCamera = (Position - Camera.Get.Position); * float dist = toCamera.Length(); * dist /= 2000.0f; * if (dist > 1.0f || !Camera.Get.IsVisible(this)) * { * dist = 1.0f; * } * dist = 1.0f - dist;*/ float closestChicken = float.MaxValue; for (int i = 0; i < world.Actors.Count; i++) { if (world.Actors[i].UserData is Chicken) { if ((Position - world.Actors[i].Position).Length() < closestChicken && world.Actors[i].LinearVelocity.Length() > 5.0f) { closestChicken = (Position - world.Actors[i].Position).Length(); } } } if (closestChicken < 500 && closestChicken > 0) { FanSound.Volume = (500 - closestChicken) / 500.0f; } else { FanSound.Volume = 0.0f; } placeholder.Position = Position; placeholder.Rot = Rot; box.Rot = placeholder.Rot; Vector2 airDir = new Vector2(JabMath.Sin(Rot), JabMath.Cos(Rot)); box.Position = (placeholder.Position + airDir * box.Height / 2.0f) - (100 * airDir); for (int i = 0; i < world.Actors.Count; i++) { } }