33 lines
825 B
C#
33 lines
825 B
C#
using Godot;
|
|
using System;
|
|
|
|
namespace lettergodot
|
|
{
|
|
|
|
|
|
public class Letterbox : Node2D
|
|
{
|
|
// Called when the node enters the scene tree for the first time.
|
|
public override void _Ready()
|
|
{
|
|
// assign random letters to all the child nodes of type Letter
|
|
foreach (var letter in GetChildren())
|
|
{
|
|
if (letter is Letter)
|
|
{
|
|
((Letter)letter).Value = RandomLetterAsAString();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// method that returns a string with a random capital letter inside
|
|
private string RandomLetterAsAString()
|
|
{
|
|
var random = new Random();
|
|
var randomLetter = (char)random.Next('A', 'Z' + 1);
|
|
return randomLetter.ToString();
|
|
}
|
|
|
|
}
|
|
} |