- Home /
In Unity3d we can develop Scrabble 2d game?
I mean i am trying to develop one scrabble game. In Scrabble we need dictionary.But i have one doubt is there any dictionary functionality in unity3d.Anybody knows share with me friends. Thank you friends........
Answer by lbalasubbaiahapps · Jan 23, 2012 at 09:26 AM
I find the solution.i stored all words in A.txt , b.txt like this.These all A-Z txt files stored in assets folder.then call that words using TestAssets.That Scripts also shown below.
using UnityEngine; using System.Collections; using System.Text.RegularExpressions; using System.Collections.Generic;
[ExecuteInEditMode] public class example : MonoBehaviour {
public TextAsset A;
public TextAsset B;
public TextAsset C;
public TextAsset D;
public TextAsset E;
public TextAsset F;
public TextAsset G;
public TextAsset H;
public TextAsset I;
public TextAsset J;
public TextAsset K;
public TextAsset L;
public TextAsset M;
public TextAsset N;
public TextAsset O;
public TextAsset P;
public TextAsset Q;
public TextAsset R;
public TextAsset S;
public TextAsset T;
public TextAsset U;
public TextAsset V;
public TextAsset W;
public TextAsset X;
public TextAsset Y;
public TextAsset Z;
public GUIText mytext;
public string tfield="";
private string myString;
private string[] myWords;
private string[] myWordDir;
void Start()
{
mytext.gameObject.active = false;
}
void OnGUI()
{
if(GUI.Button(new Rect(100,100,100,50),"Compare"))
{
if(tfield[0] == 'A' || tfield[0] == 'a')
{
myString = A.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
Debug.Log("A");
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'B' || tfield[0] == 'b')
{
myString = B.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'C' || tfield[0] == 'c')
{
myString = C.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'D' || tfield[0] == 'd')
{
myString = D.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'E' || tfield[0] == 'e')
{
myString = E.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'F' || tfield[0] == 'f')
{
myString = F.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'G' || tfield[0] == 'g')
{
myString = G.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'H' || tfield[0] == 'h')
{
myString = H.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'I' || tfield[0] == 'i')
{
myString = I.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'J' || tfield[0] == 'j')
{
myString = J.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'K' || tfield[0] == 'k')
{
myString = K.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'L' || tfield[0] == 'l')
{
myString = L.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'M' || tfield[0] == 'm')
{
myString = M.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'N' || tfield[0] == 'n')
{
myString = N.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'O' || tfield[0] == 'o')
{
myString = O.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'P' || tfield[0] == 'p')
{
myString = P.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'Q' || tfield[0] == 'q')
{
myString = Q.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'R' || tfield[0] == 'r')
{
myString = R.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'S' || tfield[0] == 's')
{
myString = S.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'T' || tfield[0] == 't')
{
myString = T.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'U' || tfield[0] == 'u')
{
myString = U.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'V' || tfield[0] == 'v')
{
myString = V.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'W' || tfield[0] == 'w')
{
myString = W.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'X' || tfield[0] == 'x')
{
myString = X.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'Y' || tfield[0] == 'y')
{
myString = Y.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
else if(tfield[0] == 'Z' || tfield[0] == 'z')
{
myString = Z.ToString();
myWords = myString.Split(new char[]{'\n'});
for(int i = 0; i < myWords.Length ; i++)
{
if(string.Compare(tfield , myWords[i]) == 0)
{
Debug.Log("Ok");
mytext.gameObject.active = true;
break;
}
else
{
Debug.Log("Wrong");
}
}
}
}
tfield = GUI.TextField(new Rect(70,200,200,50),tfield,100);
tfield = Regex.Replace(tfield, @"[^a-zA-Z]", "");
}
void Update()
{
}
}
Answer by DaveA · Jan 18, 2012 at 10:21 AM
You can certainly do this, but you'll be coding it yourself, or finding things in the Asset Store. Dictionary? I've not seen this, but it may be there, or may exist in some C# project on Git or SourceForge.
i search in Asset Store also i am getting any dictionary information also.if you see send it to me please.
Answer by Smike · Mar 31, 2013 at 11:32 PM
For your dictionnary, you can always find a .txt file with a list of all english words and read it with StreamReader.
Your answer
Follow this Question
Related Questions
Cloud recognition in Vuforia 0 Answers
What designing software needed to create a 2D image for Unity 3D? 3 Answers
Box boundary 2D Unity3D 4.3 2 Answers