Esempio n. 1
0
    public void SpawnChar(int id)
    {
        Spine.TrackEntry trc        = null;
        string           curAnim    = "idle";
        float            normalTime = 0;
        bool             initiated  = anim != null;

        if (initiated)
        {
            trc        = anim.skeleton.state.GetCurrent(0);
            curAnim    = trc.Animation.name;
            normalTime = trc.TrackTime / trc.Animation.duration;

            Destroy(anim.gameObject);
        }

        curChar = charStorage.GetCharacter(id);
        GameObject go = Instantiate(curChar.prefab, transform.position, curChar.prefab.transform.rotation);

        go.transform.parent = transform;
        Init(go);
        anim.skeleton.state.SetAnimation(0, curAnim, curAnim == "idle");

        if (initiated)
        {
            trc = anim.skeleton.state.GetCurrent(0);


            trc.TrackTime   = normalTime * trc.Animation.duration;
            trc.mixDuration = 0;
        }
        root = anim.skeleton.skeleton.FindBone("body");

        //Recolor!
        RecolorManager rc = RecolorManager.Get();

        if (rc != null)
        {
            rc.Recolor(id);
        }
    }
    public void SpawnCurrent()
    {
        newChar = charStorage.GetCharacter(Persistence.currentChar);
        GameObject go = Instantiate(newChar.prefab, transform.position, Quaternion.identity);

        go.transform.parent     = transform;
        go.transform.localScale = Vector3.one;

        skeletonAnimation = go.GetComponent <SkeletonAnimation>();

        if (isForIapScreen)
        {
            go.GetComponent <MeshRenderer>().sortingLayerName = "InAppPurchase";
        }
        else
        {
            go.GetComponent <MeshRenderer>().sortingLayerName = "SelectionScreen";
        }

        recolor.Recolor(Persistence.currentChar);
    }