Page History
...
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
public async ValueTask Render(SceneContext game, Canvas2DContext context)
{
string NameText = Name;
if (!string.IsNullOrEmpty(ChatMessage))
{
NameText = NameText + "-" + ChatMessage;
ChatViewTime--;
}
if (ChatViewTime < 0)
{
ChatMessage = string.Empty;
}
await context.SaveAsync();
// 닉네임
await context.SetFontAsync("14px 바탕체");
await context.SetFillStyleAsync("Blue");
await context.FillTextAsync(Name, _transform.Local.Position.X + 10, _transform.Local.Position.Y + 75);
if (!string.IsNullOrEmpty(ChatMessage))
{
// 채팅 Box
int padding = 10;
int dynamicWidth = 50 + ((ChatMessage.Length - 3) * 15);
int dynamicHeight = 50;
float boxX = _transform.Local.Position.X + 20;
float boxY = _transform.Local.Position.Y - 40;
float tailWidth = 10;
float tailHeight = 10;
// 말풍선 배경
await context.BeginPathAsync();
await context.MoveToAsync(boxX, boxY);
await context.LineToAsync(boxX + dynamicWidth, boxY);
await context.LineToAsync(boxX + dynamicWidth, boxY + dynamicHeight);
await context.LineToAsync(boxX + dynamicWidth / 2 + tailWidth, boxY + dynamicHeight);
await context.LineToAsync(boxX + dynamicWidth / 2, boxY + dynamicHeight + tailHeight);
await context.LineToAsync(boxX + dynamicWidth / 2 - tailWidth, boxY + dynamicHeight);
await context.LineToAsync(boxX, boxY + dynamicHeight);
await context.ClosePathAsync();
await context.SetFillStyleAsync("White");
await context.FillAsync();
// 말풍선 테두리
await context.SetStrokeStyleAsync("Black");
await context.StrokeAsync();
// 채팅 메시지
await context.SetFillStyleAsync("Black");
await context.FillTextAsync(ChatMessage, boxX + padding, boxY + padding + 20);
}
if (_isMine)
{
// 추가적인 렌더링 로직이 필요하다면 여기에 작성
}
await context.RestoreAsync();
}
| ||||||
| Info | ||||||
| Code Block | ||||||
| ||||||
| Info | ||||||
| Code Block | ||||||
| ||||||
| Info | ||||||
| Code Block | ||||||
| ||||||
| Info | ||||||
| Code Block | ||||||
| ||||||
| Info | ||||||
| Code Block | ||||||
| ||||||
| Info | ||||||
| Code Block | ||||||
| ||||||
| Info | ||||||
| Code Block | ||||||
| ||||||
| Info | ||||||
| Code Block | ||||||
|