public void populateAnimations()
    {
        TIME.Figurine fig = ScreenManager.getInstance().currentFigurine;

        foreach (Transform child in animationGroup.transform)
        {
            Destroy(child.gameObject);
        }

        for (int i = 0; i < fig.animations.Count; i++)
        {
            GameObject preview = Instantiate <GameObject>(previewPrefab);
            preview.transform.SetParent(animationGroup.transform, false);
            RectTransform rt = preview.GetComponent <RectTransform>();
            rt.anchoredPosition = new Vector2((120 * (i % 6) + 100), -150 - (120 * (i / 6)));

            RawImageAnimator riAnim = preview.GetComponent <RawImageAnimator>();
            riAnim.anim = fig.animations[i];
        }
    }
    public IEnumerator getAnimations(TIME.Figurine figurine)
    {
        string url = "http://" + databaseAddress + "/playtime/getAnimations.php";

        WWWForm form = new WWWForm();

        form.AddField("rfidKey", figurine.key);

        WWW www = new WWW(url, form);

        yield return(www);

        string[] delimiters = { "<br>" };
        string[] results    = www.text.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
        if (results.Length == 0)
        {
            // Figurine does not exist or has no animations in the database.
        }
        else
        {
            // for each animation associated to this figurine
            for (int i = 0; i < results.Length; i++)
            {
                print(results[i]);

                int animID;
                if (int.TryParse(results[i], out animID))
                {
                    TIME.Animation anim = new TIME.Animation();
                    anim.id = animID;

                    yield return(StartCoroutine(getFrames(anim)));

                    figurine.animations.Add(anim);
                }
            }
        }

        doneFetchingAnimations = true;
    }
Esempio n. 3
0
 void Update()
 {
     if (placeRfidScreenTop.activeSelf)
     {
         DatabaseManager dbMgr = DatabaseManager.getInstance();
         if (waitingForAnimations)
         {
             if (dbMgr.doneFetchingAnimations)
             {
                 waitingForAnimations         = false;
                 dbMgr.doneFetchingAnimations = false;
                 goToAnimationListScreen();
             }
         }
         else if (Input.GetKeyDown(KeyCode.Space))
         {
             currentFigurine = new TIME.Figurine("680088977f");
             StartCoroutine(dbMgr.getAnimations(currentFigurine));
             waitingForAnimations = true;
         }
     }
 }