Пример #1
0
    IEnumerator MorphStored(GlyphMatch match)
    {
        Clear(castedGlyphGraphic);
        Stroke[] strokes = null;

        /*
         * for (float t=0;t<1;t+=0.05f){
         *      match.SetLerpStrokes(t, ref strokes);
         *      Set(targetGlyphGraphic,strokes);
         *      yield return new WaitForSeconds(step);
         * }
         */
        float t = 0f;

        while (t < 0.99f && !stopStoredMorph)
        {
            match.SetLerpStrokes(t, ref strokes);
            Set(storedGlyphGraphic, strokes);
            storedGlyph = strokes;
            t          += (1 - t) * 0.1f;
            yield return(new WaitForSeconds(step));
        }
        if (!stopStoredMorph)
        {
            Set(storedGlyphGraphic, match.target);
        }
        stopStoredMorph = false;
    }
Пример #2
0
    IEnumerator Morph(GlyphMatch match)
    {
        //targetGlyphGraphic.color = new Color(1f, 1f, 1f, 1f);

        Clear(castedGlyphGraphic);
        Stroke[] strokes = null;

        /*
         * for (float t=0;t<1;t+=0.05f){
         *      match.SetLerpStrokes(t, ref strokes);
         *      Set(targetGlyphGraphic,strokes);
         *      yield return new WaitForSeconds(step);
         * }
         */

        float t = 0f;

        while (t < 0.99f)
        {
            match.SetLerpStrokes(t, ref strokes);
            Set(targetGlyphGraphic, strokes);
            //targetGlyphGraphic.material.color = Color.Lerp(glyphColours["default"], color, t);
            t += (1 - t) * 0.1f;
            yield return(new WaitForSeconds(step));
        }

        Set(targetGlyphGraphic, match.target);
        if (IsClear(currentStrokeGraphic) && IsClear(currentGlyphGraphic))
        {
            Set(castedGlyphGraphic, match.source);
        }
    }
Пример #3
0
    void OnGlyphCast(int index, GlyphMatch match)
    {
        lastCast = match;

        // Reset casted glyph transparency
        targetGlyphGraphic.color = new Color(1f, 1f, 1f, 1f);

        Clear(currentGlyphGraphic);
        if (match == null || match.Cost > costThreshold)
        {
            Clear(targetGlyphGraphic);
            Clear(castedGlyphGraphic);
            if (match != null)
            {
                print("Error cost of " + match.Cost + " too high for match: " + match.target.ToString());
            }
            return;
        }

        Debug.Log("Match found:  " + match.target.ToString() + "   Cost: " + match.Cost);
        // Debug.Log("Player:   "+player.name);
        // Make sure glyph recognition finishes and clears the stroke list
        // through any possible errors.
        try {
            StartCoroutine(Morph(match));
            // glyphColours[match.target.ToString()])
            // TODO: ADD COMPONENT TO PLAYER
            AuricaCaster.LocalCaster.AddComponent(match.target.name);
        }
        catch (System.Exception e) {
            Debug.LogError("Glyph recognition " + e + " occured. Clearing strokes.");
        }
        ClearAll();
    }
Пример #4
0
    IEnumerator Morph(GlyphMatch match)
    {
        Clear(castedGlyphGraphic);
        Stroke[] strokes = null;

        /*
         * for (float t=0;t<1;t+=0.05f){
         *      match.SetLerpStrokes(t, ref strokes);
         *      Set(targetGlyphGraphic,strokes);
         *      yield return new WaitForSeconds(step);
         * }
         */
        float t = 0f;

        while (t < 0.99f)
        {
            match.SetLerpStrokes(t, ref strokes);
            Set(targetGlyphGraphic, strokes);
            t += (1 - t) * 0.1f;
            yield return(new WaitForSeconds(step));
        }

        Set(targetGlyphGraphic, match.target);
        if (IsClear(currentStrokeGraphic) && IsClear(currentGlyphGraphic))
        {
            Set(castedGlyphGraphic, match.source);
        }
    }
Пример #5
0
 public void OnGlyphCast(int index, GlyphMatch match)
 {
     if (match != null && match.Cost < match.Threshold)
     {
         StartCoroutine(Morph(match));
         Clear(currentGlyphGraphic);
     }
     else
     {
         Clear(targetGlyphGraphic);
         StartCoroutine(FadeOut(currentGlyphGraphic, Color.red));
     }
 }
Пример #6
0
 void OnGlyphCast(int index, GlyphMatch match)
 {
     if (match != null)
     {
         StartCoroutine(Morph(match));
     }
     else
     {
         Clear(targetGlyphGraphic);
         Clear(castedGlyphGraphic);
     }
     Clear(currentGlyphGraphic);
 }
Пример #7
0
 IEnumerator Morph(GlyphMatch match)
 {
     Stroke[] strokes = null;
     for (float time = 0; time < morphDuration; time += step)
     {
         float progress = time / morphDuration;
         float t        = morph.Evaluate(progress);
         match.SetLerpStrokes(t, ref strokes);
         foreach (Stroke s in strokes)
         {
             float size = Mathf.Lerp(Mathf.Max(drawingBounds.height, drawingBounds.width), 1f, t);
             s.Scale(new Vector2(size, size));
             s.Translate(Vector2.Lerp(drawingBounds.center, Vector2.zero, t));
         }
         Set(targetGlyphGraphic, strokes);
         yield return(new WaitForSeconds(step));
     }
     Set(targetGlyphGraphic, match.target);
     StartCoroutine(FadeOut(targetGlyphGraphic, Color.white));
 }
Пример #8
0
    void OnStrokeDraw(Stroke[] strokes)
    {
        Clear(currentStrokeGraphic);
        if (strokes == null)
        {
            Debug.Log("Null Stroke");
            return;
        }
        Stroke[]  latestStroke  = new Stroke[1];
        Stroke[]  previousGlyph = new List <Stroke>(strokes).GetRange(0, strokes.Length - 1).ToArray();
        Vector2[] points;
        latestStroke[0] = Clone(strokes[strokes.Length - 1], out points);
        Vector2    vectorStroke = points[points.Length - 1] - points[0];
        GlyphMatch castGlyph    = Match(latestStroke);

        //Debug.Log(castGlyph.target.ToString());
        //Debug.Log(castGlyph.Cost);
        //Debug.Log("Stroke Drawn");
        Set(currentGlyphGraphic, strokes);
    }
Пример #9
0
    void OnGlyphCast(int index, GlyphMatch match)
    {
        lastCast = match;

        // Reset casted glyph transparency
        targetGlyphGraphic.color = new Color(1f, 1f, 1f, 1f);

        Clear(currentGlyphGraphic);
        if (match == null || match.Cost > costThreshold)
        {
            Clear(targetGlyphGraphic);
            Clear(castedGlyphGraphic);
            if (match != null)
            {
                print("Error cost of " + match.Cost + " too high for match: " + match.target.ToString());
            }
            player.CastFizzle(hand);
            return;
        }

        Debug.Log("Match found:  " + match.target.ToString() + "   Cost: " + match.Cost);
        // Debug.Log("Player:   "+player.name);
        // Make sure glyph recognition finishes and clears the stroke list
        // through any possible errors.
        try {
            StartCoroutine(Morph(match));
            // glyphColours[match.target.ToString()])
            if (!groundCast)
            {
                player.PrepareSpell(match.target.ToString(), hand, 1f - match.Cost / costThreshold);
            }
            else
            {
                groundPlane.CastSpell(match.target.ToString(), 1f - match.Cost / costThreshold);
            }
        }
        catch (System.Exception e) {
            Debug.LogError("Glyph recognition " + e + " occured. Clearing strokes.");
        }
        ClearAll();
    }