public override void DrawArcObject(SceneGame scene, DrawPass pass) { var spriteWraith = SpriteLoader.Instance.AddSprite("content/wraith"); var spriteWraithTrail = SpriteLoader.Instance.AddSprite("content/wraith_trail"); var tile = Curio.GetMainTile(); var startPos = Source; var endPos = tile.VisualTarget; Vector2 curve(float slide) { var a = Vector2.Lerp(startPos, startPos + VelocityStart, (float)LerpHelper.Quadratic(0, 1, slide)); var b = Vector2.Lerp(endPos + VelocityEnd, endPos, (float)LerpHelper.Quadratic(0, 1, slide)); return(Vector2.Lerp(a, b, (float)LerpHelper.Quadratic(0, 1, slide))); } Color colorStart = new Color(215, 63, 36); Color colorEnd = new Color(118, 39, 102); if (pass == DrawPass.Effect) { int segments = 5; for (int i = 0; i < segments; i++) { float trailSlide = (float)i / (segments - 1); float trailPos = (float)LerpHelper.QuadraticOut(Frame.Slide - 0.05f, Frame.Slide, trailSlide); Vector2 pos = curve(trailPos); scene.DrawSpriteExt(spriteWraithTrail, 0, pos - spriteWraithTrail.Middle, spriteWraithTrail.Middle, 0, Vector2.One, SpriteEffects.None, Color.Lerp(colorStart.WithAlpha(0), colorEnd, trailSlide), 0); } } if (pass == DrawPass.EffectAdditive) { scene.DrawSpriteExt(spriteWraith, 0, curve(Frame.Slide) - spriteWraith.Middle, spriteWraith.Middle, 0, Vector2.One, SpriteEffects.None, colorStart, 0); } }
private float DarkRadius(float a, float b, float slide, float split) { float startSlide = Util.ReverseLerp(slide, 0f, split); float endSlide = Util.ReverseLerp(slide, split, 1f); return(slide < 0.2f ? (float)LerpHelper.QuadraticOut(a, b, startSlide) : (float)LerpHelper.QuadraticIn(b, a, endSlide)); }
public override void Draw(Scene scene) { var ui = SpriteLoader.Instance.AddSprite("content/ui_box"); int offset = (scene.Viewport.Width - Width) / 2; int widthInterior = Width - CardWidth; int segmentWidth = widthInterior / (Actions.Length - 1); for (int i = 0; i < Actions.Length; i++) { var action = Actions[i]; if (action == null) { continue; } int height = Height; if (!action.Enabled()) { height = height * 4 / 5; } height += (int)MathHelper.Lerp(0, 30, (float)LerpHelper.QuadraticOut(0, 1, action.HoverFrame.Slide)); int x = offset + i * segmentWidth; int y = scene.Viewport.Height - (int)MathHelper.Lerp(0, height, (float)LerpHelper.ElasticOut(0, 1, action.Frame.Slide)); CardUIs[i].Draw(FontRenderer, x, y, 1); //DrawLabelledUI(scene, ui, ui, new Rectangle(x, y, CardWidth, height + 40), action.Name); //scene.DrawText(action.Description, new Vector2(x, y), Alignment.Center, new TextParameters().SetColor(Color.White, Color.Black).SetConstraints(CardWidth, height)); } }
public void Steppy(float addAngle) { var active = Curio.GetActionHolder(ActionSlot.Active); var passive = Curio.GetActionHolder(ActionSlot.Passive); var orientable = Curio.GetBehavior <BehaviorOrientable>(); var tile = Curio.GetMainTile(); var actions = new List <ActionWrapper>(); if (!tile.IsChasm()) { if (Momentum.Amount >= 16) { var direction = Util.RotateVector(Momentum.Direction, addAngle); var offset = direction.ToTileOffset(); var slide = MathHelper.Clamp(Momentum.Amount / 32f, 0, 1); var speed = (float)LerpHelper.QuadraticOut(0.1f, 0.5f, slide); var time = 1 / speed; var neighbor = tile.GetNeighborOrNull(offset.X, offset.Y); if (neighbor != null && !neighbor.IsSolid()) { actions.Add(new ActionClearStab(Curio).InSlot(ActionSlot.Active)); actions.Add(new ActionChangeMomentum(Curio, -4).InSlot(ActionSlot.Active)); actions.Add(new ActionMoveForward(Curio, direction, 5).InSlot(ActionSlot.Active)); } } } actions.Apply(Curio); }
public void AddDefaultMove(List <ActionWrapper> actions) { var tile = Curio.GetMainTile(); if (tile == null) { return; } if (Momentum.Amount > 0) { var offset = Momentum.Direction.ToTileOffset(); var slide = MathHelper.Clamp(Momentum.Amount / 32f, 0, 1); var speed = (float)LerpHelper.QuadraticOut(0.1f, 0.5f, slide); var time = 1 / speed; var neighbor = tile.GetNeighborOrNull(offset.X, offset.Y); if (neighbor == null || neighbor.IsSolid()) { if (neighbor != null && (Momentum.Amount > 10 || (neighbor.IsSpiky() && Momentum.Amount > 2))) { actions.Add(new ActionCollision(Curio, neighbor, 10).InSlot(ActionSlot.Passive)); } actions.Add(new ActionStop(Curio).InSlot(ActionSlot.Passive)); } else { actions.Add(new ActionMoveForward(Curio, Momentum.Direction, time).InSlot(ActionSlot.Passive)); } } else if (tile.HasBehaviors <BehaviorChasm>()) { actions.Add(new ActionFall(Curio, 30).InSlot(ActionSlot.Passive)); } }
private void DrawMace(ICurio curio, SceneGame scene, DrawPass pass) { var center = curio.GetVisualPosition() + new Vector2(8, 8); var offset = curio.GetOffset(); var angleBody = curio.GetVisualAngle(); var mace = curio.GetBehavior <BehaviorMace>(); if (mace != null && (!mace.Upswing.Done || !mace.MaceReturn.Done)) { var weaponAngle = (float)LerpHelper.QuadraticOut(0, 1, mace.Upswing.Slide); var weaponScale = (float)LerpHelper.QuadraticOut(0.5, 1.0, mace.Upswing.Slide); var weaponStartPos = Util.AngleToVector(angleBody + MathHelper.PiOver4 * 2) * 8; var weaponEndPos = Util.AngleToVector(angleBody + MathHelper.PiOver4 * 3) * 10; var weaponPos = center + offset + Vector2.Lerp(weaponStartPos, weaponEndPos, (float)LerpHelper.QuadraticOut(0, 1, mace.Upswing.Slide)); scene.DrawSpriteExt(SpriteWeapon, 0, weaponPos - SpriteWeapon.Middle, SpriteWeapon.Middle, angleBody + weaponAngle, new Vector2(weaponScale), SpriteEffects.None, Color.White, 0); if (!mace.Upswing.Done) { mace.DrawMace(scene, weaponPos, Util.AngleToVector(mace.UpswingAngle) * (float)LerpHelper.QuadraticOut(0, 12, mace.MaceReturn.Slide), 2); } if (!mace.MaceReturn.Done) { var maceOffset = mace.MacePosition - weaponPos; mace.DrawMace(scene, weaponPos, Vector2.Lerp(maceOffset, Vector2.Zero, (float)LerpHelper.QuadraticOut(0, 1, mace.MaceReturn.Slide)), 8); } } }
private void DrawDagger(ICurio curio, SceneGame scene, DrawPass pass) { var center = curio.GetVisualPosition() + new Vector2(8, 8); var offset = curio.GetOffset(); var angleBody = curio.GetVisualAngle(); var dagger = curio.GetBehavior <BehaviorDagger>(); if (dagger != null && !dagger.Upswing.Done) { var weaponAngle = (float)LerpHelper.QuadraticOut(0, 1, dagger.Upswing.Slide); var weaponScale = (float)LerpHelper.QuadraticOut(0.5, 1.0, dagger.Upswing.Slide); var weaponStartPos = Util.AngleToVector(angleBody + MathHelper.PiOver4 * 2) * 8; var weaponEndPos = Util.AngleToVector(angleBody + MathHelper.PiOver4 * 3) * 10; var weaponPos = center + offset + Vector2.Lerp(weaponStartPos, weaponEndPos, (float)LerpHelper.QuadraticOut(0, 1, dagger.Upswing.Slide)); scene.DrawSpriteExt(SpriteWeapon, 0, weaponPos - SpriteWeapon.Middle, SpriteWeapon.Middle, angleBody + weaponAngle, new Vector2(weaponScale), SpriteEffects.None, Color.White, 0); } }
public void Tick(SceneGame scene) { if (Curio.IsAlive() && !Upswing.Done) { Upswing += scene.TimeModCurrent; var lastAngle = UpswingAngle; UpswingAngle += scene.TimeModCurrent * (float)LerpHelper.QuadraticOut(MathHelper.TwoPi * 0.01, MathHelper.TwoPi * 0.2, Upswing.Slide); var deltaSwing = Math.Abs(Math.Floor(UpswingAngle / MathHelper.Pi) - Math.Floor(lastAngle / MathHelper.Pi)); if (deltaSwing >= 1) { SoundSwish.Play(1, Upswing.Slide - 0.5f, 0); } } //else // Upswing.Time = Upswing.EndTime; if (!MaceReturn.Done) { MaceReturn += scene.TimeModCurrent; } }