/** * Draws the point, text and borders of this cell. */ internal void Paint( Page page, float x, float y, float w, float h) { if (background != -1) { DrawBackground(page, x, y, w, h); } if (image != null) { if (GetTextAlignment() == Align.LEFT) { image.SetLocation(x + leftPadding, y + topPadding); image.DrawOn(page); } else if (GetTextAlignment() == Align.CENTER) { image.SetLocation((x + w / 2f) - image.GetWidth() / 2f, y + topPadding); image.DrawOn(page); } else if (GetTextAlignment() == Align.RIGHT) { image.SetLocation((x + w) - (image.GetWidth() + leftPadding), y + topPadding); image.DrawOn(page); } } if (barCode != null) { try { if (GetTextAlignment() == Align.LEFT) { barCode.DrawOnPageAtLocation(page, x + leftPadding, y + topPadding); } else if (GetTextAlignment() == Align.CENTER) { float barcodeWidth = barCode.DrawOn(null)[0]; barCode.DrawOnPageAtLocation(page, (x + w / 2f) - barcodeWidth / 2f, y + topPadding); } else if (GetTextAlignment() == Align.RIGHT) { float barcodeWidth = barCode.DrawOn(null)[0]; barCode.DrawOnPageAtLocation(page, (x + w) - (barcodeWidth + leftPadding), y + topPadding); } } catch (Exception e) { Console.WriteLine(e.ToString()); } } if (textBlock != null) { textBlock.SetLocation(x + leftPadding, y + topPadding); textBlock.DrawOn(page); } DrawBorders(page, x, y, w, h); if (text != null && !text.Equals("")) { DrawText(page, x, y, w, h); } if (point != null) { if (point.align == Align.LEFT) { point.x = x + 2 * point.r; } else if (point.align == Align.RIGHT) { point.x = (x + w) - this.rightPadding / 2; } point.y = y + h / 2; page.SetBrushColor(point.GetColor()); if (point.GetURIAction() != null) { page.AddAnnotation(new Annotation( point.GetURIAction(), null, point.x - point.r, point.y - point.r, point.x + point.r, point.y + point.r, null, null, null)); } page.DrawPoint(point); } if (drawable != null) { drawable.SetPosition(x + leftPadding, y + topPadding); drawable.DrawOn(page); } }
protected override void OnUpdate(float deltaTime) { Position = body.Position; Rotation = body.Rotation; body.ApplyTorque(-body.Rotation * BodyRotationForce); if (!InputEnabled) { return; } GamePadState state = GamePad.GetState(PlayerId); if (state.IsButtonDown(Mappings.Forfeit)) { timeSinceForfeit += deltaTime; if (timeSinceForfeit >= TimeToForfeit) { Forfeited = true; } } else { timeSinceForfeit = 0f; } timeUntilJump = Math.Max(timeUntilJump - deltaTime, 0f); AttackStrength = Math.Max(AttackStrength - deltaTime * AttackDecayRate, 0f); if (Math.Abs(state.ThumbSticks.Left.X) >= Deadzone) { if (currentDrawable == null) { if (state.ThumbSticks.Left.X > 0) { direction = -1; } else if (state.ThumbSticks.Left.X < 0) { direction = 1; } } body.ApplyForce(new Vector2(state.ThumbSticks.Left.X * bodyMovementForce, 0f)); } if (AttackStrength > 0) { leftShoulder.ReferenceAngle = PunchingArmAngle * direction; rightShoulder.ReferenceAngle = PunchingArmAngle * direction; } else { leftShoulder.ReferenceAngle = RestingArmAngle; rightShoulder.ReferenceAngle = -RestingArmAngle; } if (state.Triggers.Right > 0.5f) { cursorPosition += new Vector2(state.ThumbSticks.Right.X, -state.ThumbSticks.Right.Y) * DrawSpeed * deltaTime; if (cursorPosition.Length() > MaxDrawDistance) { cursorPosition.Normalize(); cursorPosition *= MaxDrawDistance; } if (currentDrawable == null) { currentDrawable = new Terrain(AbsoluteCursorPosition); } currentDrawable?.SetPosition(AbsoluteCursorPosition); } else { cursorPosition = new Vector2(state.ThumbSticks.Right.X, -state.ThumbSticks.Right.Y) * MaxDrawDistance; if (currentDrawable != null) { currentDrawable.StopDrawing(); currentDrawable = null; } } }