Class Card3D
Represents a card in 3D space with enhanced 2.5D rendering. Supports nine-slice textures, animations, and interactive elements.
Inherited Members
Namespace: PopcorningGuineaPig.Engine.UI
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public class Card3D
Constructors
| Edit this page View SourceCard3D(Texture2D, Texture2D, Vector3, Vector2, float)
Creates a new card with the specified textures and size.
Declaration
public Card3D(Texture2D frontTexture, Texture2D backTexture, Vector3 position, Vector2 size, float thickness = 0.1)
Parameters
| Type | Name | Description |
|---|---|---|
| Texture2D | frontTexture | The texture for the front of the card |
| Texture2D | backTexture | The texture for the back of the card |
| Vector3 | position | The initial position of the card in 3D space |
| Vector2 | size | The size of the card (width, height) |
| float | thickness | The visual thickness of the card |
Methods
| Edit this page View SourceAddSection(string, Rectangle)
Adds an interactive section to the card.
Declaration
public void AddSection(string name, Rectangle rect)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the section |
| Rectangle | rect | The rectangle defining the section (normalized 0-1 coordinates) |
Draw(Camera3D)
Draws the card.
Declaration
public void Draw(Camera3D camera)
Parameters
| Type | Name | Description |
|---|---|---|
| Camera3D | camera | The camera to use for rendering |
DrawHighlight(Matrix4x4)
Draws a highlight effect around the card.
Declaration
protected virtual void DrawHighlight(Matrix4x4 transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4x4 | transform | The transformation matrix |
Flip(float)
Flips the card.
Declaration
public void Flip(float duration = 0.5)
Parameters
| Type | Name | Description |
|---|---|---|
| float | duration | The duration of the flip animation in seconds |
GetPosition()
Gets the position of the card.
Declaration
public Vector3 GetPosition()
Returns
| Type | Description |
|---|---|
| Vector3 | The position of the card |
GetRotation()
Gets the rotation of the card.
Declaration
public Vector3 GetRotation()
Returns
| Type | Description |
|---|---|
| Vector3 | The rotation of the card |
GetSection(string)
Gets a section by name.
Declaration
public Rectangle GetSection(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the section |
Returns
| Type | Description |
|---|---|
| Rectangle | The rectangle defining the section, or an empty rectangle if not found |
GetSize()
Gets the size of the card.
Declaration
public Vector2 GetSize()
Returns
| Type | Description |
|---|---|
| Vector2 | The size of the card |
IsAnimating()
Gets whether the card is currently animating.
Declaration
public bool IsAnimating()
Returns
| Type | Description |
|---|---|
| bool | True if the card is animating, false otherwise |
IsFaceUp()
Gets whether the card is face up.
Declaration
public bool IsFaceUp()
Returns
| Type | Description |
|---|---|
| bool | True if the card is face up, false otherwise |
IsPointOver(Vector2, Camera3D, out string)
Checks if a point in screen space is over the card.
Declaration
public bool IsPointOver(Vector2 screenPoint, Camera3D camera, out string sectionName)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | screenPoint | The point in screen space |
| Camera3D | camera | The camera used for rendering |
| string | sectionName | The name of the section that was hit, if any |
Returns
| Type | Description |
|---|---|
| bool | True if the point is over the card, false otherwise |
MoveTo(Vector3, float)
Moves the card to a new position.
Declaration
public void MoveTo(Vector3 target, float duration = 0.5)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | target | The target position |
| float | duration | The duration of the movement animation in seconds |
RotateTo(Vector3, float)
Rotates the card to a new orientation.
Declaration
public void RotateTo(Vector3 targetRot, float duration = 0.5)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | targetRot | The target rotation |
| float | duration | The duration of the rotation animation in seconds |
SetBackNineSlice(int)
Sets the nine-slice information for the back texture.
Declaration
public void SetBackNineSlice(int cornerSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cornerSize | The size of the corners in pixels |
SetEdgeTexture(Texture2D)
Sets the edge texture for the card.
Declaration
public void SetEdgeTexture(Texture2D texture)
Parameters
| Type | Name | Description |
|---|---|---|
| Texture2D | texture | The texture to use for the card edges |
SetFaceUp(bool)
Sets whether the card is face up.
Declaration
public void SetFaceUp(bool faceUp)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | faceUp | Whether the card should be face up |
SetFrontNineSlice(int)
Sets the nine-slice information for the front texture.
Declaration
public void SetFrontNineSlice(int cornerSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cornerSize | The size of the corners in pixels |
SetHighlight(bool, Color, float)
Sets the highlight state of the card.
Declaration
public void SetHighlight(bool highlighted, Color color, float intensity = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | highlighted | Whether the card should be highlighted |
| Color | color | The color of the highlight |
| float | intensity | The intensity of the highlight |
SetPosition(Vector3)
Sets the position of the card.
Declaration
public void SetPosition(Vector3 position)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | position | The new position |
SetRotation(Vector3)
Sets the rotation of the card.
Declaration
public void SetRotation(Vector3 rotation)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | rotation | The new rotation |
SetSize(Vector2)
Sets the size of the card.
Declaration
public void SetSize(Vector2 size)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | size | The new size |
Unload()
Easing function for smooth animations.
Declaration
public void Unload()
Update(float)
Updates the card's state.
Declaration
public void Update(float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | deltaTime | The time elapsed since the last update |
Events
| Edit this page View SourceOnClick
Declaration
public event Action<Card3D>? OnClick
Event Type
| Type | Description |
|---|---|
| Action<Card3D> |
OnDragEnd
Declaration
public event Action<Card3D, Vector3>? OnDragEnd
Event Type
| Type | Description |
|---|---|
| Action<Card3D, Vector3> |
OnDragStart
Declaration
public event Action<Card3D>? OnDragStart
Event Type
| Type | Description |
|---|---|
| Action<Card3D> |
OnSectionHover
Declaration
public event Action<Card3D, string>? OnSectionHover
Event Type
| Type | Description |
|---|---|
| Action<Card3D, string> |