-1
私は入力フィールドに単語を入力できるゲームを作ろうとしており、L337トグルがオンになっていると、その単語のL337バージョンがアウトプットテキストから出てきます。他の文字。それは基本的に動作しますが、結果をL337形式に暗号化することはできません。トグルがオンでもオフでも、同じように出てきます。誰かが私を助けてくれますか?ユニティ - 単語をL337形式に変換するにはどうすればよいですか?
public class Encryption : MonoBehaviour
{
InputField input;
public Text output;
string inputText;
public Toggle L337Toggle;
void Start()
{
L337Toggle.isOn = false;
}
private void Update()
{
inputText = input.text;
output.text = inputText;
var textEncryption = new TextEncryption(inputText);
var L337Encryption = new L337Encryption(textEncryption);
if (Input.GetKeyDown("enter"))
{
if (L337Toggle.isOn == true)
{
string result = L337Encryption.Encrypt();
}
}
}
public interface IEncryption
{
string Encrypt();
}
public class TextEncryption : IEncryption
{
private string originalString;
public TextEncryption(string original)
{
originalString = original;
}
public string Encrypt()
{
Debug.Log("Encrypting Text");
return originalString;
}
}
public class L337Encryption : IEncryption
{
private IEncryption _encryption;
public L337Encryption(IEncryption encryption)
{
_encryption = encryption;
}
public string Encrypt()
{
Debug.Log("Encrypting L337 Text");
string result = _encryption.Encrypt();
result = result.Replace('a', '4').Replace('b', '8').Replace('e', '3').Replace('g', '6').Replace('h', '4').Replace('l', '1')
.Replace('0', '0').Replace('q', '9').Replace('s', '5').Replace('t', '7');
return result;
}
}
}
「解決済み」と表示されている質問の隣にあるチェックボックスをクリックすると、 – Mars