Exemplo n.º 1
0
 void OnPlayerDictUpdated(GlyphDictionary dict)
 {
     foreach (var glyph in m_glyphs)
     {
         glyph.UpdateWithDictionary(dict);
     }
 }
    public static GlyphDictionary createRandomDictionary()
    {
        var dict = new GlyphDictionary();

        initSeed();

        // Generate a list of possible ids
        int        id  = 2;
        List <int> tmp = new List <int>();

        for (char c = 'a'; c <= 'z'; ++c)
        {
            tmp.Add(id++);
        }

        for (char c = 'a'; c <= 'z'; ++c)
        {
            int index    = Random.Range(0, tmp.Count);
            int randomId = tmp[index];
            tmp.RemoveAt(index);

            dict.m_translations[c] = new Glyph(c, randomId);
        }

        return(dict);
    }
Exemplo n.º 3
0
 void OnPlayerDictUpdated(GlyphDictionary dict)
 {
     foreach (var lbv in m_letters)
     {
         Glyph g = dict.get(lbv.m_letter[0]);
         lbv.m_glyph.sprite = GlyphVisuals.Instance.GetVisual(g.VisualId);
     }
 }
Exemplo n.º 4
0
    public void Apply()
    {
        if (Atlas == null || FontXML == null)
        {
            BoltLog.Error("Make sure Atlas and FontXML aren't null");
            return;
        }

        XmlDocument xmlData = new XmlDocument();

        xmlData.LoadXml(FontXML.text);

        XmlNode fontNode = xmlData.FirstChild;

        if (fontNode.Name != "font")
        {
            BoltLog.Error("Invalid font xml");
        }

        Glyphs     = new GlyphDictionary();
        BaseSize   = 1f;
        LineHeight = 1f;
        VScale     = 1f;
        HScale     = 1f;

        if (Atlas.width > Atlas.height)
        {
            HScale = Atlas.width / Atlas.height;
        }
        else if (Atlas.width < Atlas.height)
        {
            VScale = Atlas.height / Atlas.width;
        }

        foreach (XmlNode node in fontNode.ChildNodes)
        {
            if (node.Name == "info")
            {
                BaseSize = Convert.ToSingle(attribute(node, "size"));
            }
            else if (node.Name == "common")
            {
                LineHeight = Convert.ToSingle(attribute(node, "lineHeight")) / Atlas.height * VScale;
            }
            else if (node.Name == "chars")
            {
                parseChars(node);
            }
            else if (node.Name == "kernings")
            {
                parseKernings(node);
            }
        }
    }
Exemplo n.º 5
0
 public bool checkFinished(GlyphDictionary dict)
 {
     foreach (var glyph in Glyphs)
     {
         var playerGuess = dict.get(glyph.Letter);
         if (playerGuess.VisualId != glyph.VisualId)
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 6
0
    public void UpdateWithDictionary(GlyphDictionary dict)
    {
        LetterBoxView lbv = GetComponent <LetterBoxView>();

        if (dict.hasGlyph(m_glyph))
        {
            char letter = dict.getLetter(m_glyph);
            lbv.SetLetter(letter);
        }
        else
        {
            lbv.SetLetter(GlyphDictionary.UNKNOWN_GLYPH_CHAR);
        }
    }
Exemplo n.º 7
0
        internal Glyph GetGlyph(char c)
        {
            int glyphIndex;

            return(GlyphDictionary.TryGetValue(c, out glyphIndex) ? Glyphs[glyphIndex] : Glyphs[0]);
        }
Exemplo n.º 8
0
 private Game()
 {
     playerDict = GlyphDictionary.createEmptyDictionary();
     puzzleDict = GlyphDictionary.createRandomDictionary();
 }