Esempio n. 1
0
    void SpawnItem(int id)
    {
        CharacterProfile newChar = storage.GetCharacter(id);

        if (newChar != null)
        {
            GameObject go = Instantiate(shopItem, contentRoot.transform);

            ShopItem item = go.GetComponent <ShopItem> ();
            item.SetProfile(newChar);
            UnityEngine.UI.Image coinImg = item.coinRoot.GetComponentInChildren <UnityEngine.UI.Image> ();
            if (coinImg != null && newChar.rewardBonus <= coinIcons.Length)
            {
                coinImg.sprite = coinIcons [newChar.rewardBonus];
            }
            else
            {
                Debug.LogError("Failed to set coin icons");
            }
            items.Add(item);
            go.transform.SetSiblingIndex(items.Count - 1);
        }
        else
        {
            Debug.LogWarning("Could not spawn char, skipping");
        }
    }
    public void Recolor(int id)
    {
        CharacterProfile chara = charStore.GetCharacter(id);

        Recolor(chara.primary, chara.secondary, chara.textcol, chara.buttonColor);
        curScheme = id;
    }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        panel.SetActive(true);
        //shopAnim = panel.GetComponent<Animator>();
        storage = FindObjectOfType <CharacterStorage> ();
        main    = FindObjectOfType <GameController> ();
        items   = new List <ShopItem> ();
        bool[] purchases  = Persistence.GetPurchased();
        bool   isUnlocked = true;

        if (FMC_GameDataController.instance != null)
        {
            isUnlocked = FMC_GameDataController.instance.subscriptionIsActive();
        }
        for (int i = 0; i < storage.characters.Length; i++)
        {
            storage.GetCharacter(i).isLocked = !isUnlocked;

            if (purchases.Length > 0)
            {
                storage.GetCharacter(i).isPurchased = purchases [i];
            }
            else if (i > 0)
            {
                storage.GetCharacter(i).isPurchased = false;
            }
            SpawnItem(i);
        }
        if (purchases.Length == 0)
        {
            Save();
        }
        shopAnim.SetBool("IsOpen", true);
        curtainAnim.SetBool("IsOpen", true);
        panel.SetActive(false);
        curtainAnim.gameObject.SetActive(false);
    }
    //public static void StorePurchases(CharacterProfile[] chars){
    public static void StorePurchases(CharacterStorage storage)
    {
        string result = string.Empty;

        for (int i = 0; i < storage.characters.Length; i++)
        {
            if (storage.GetCharacter(i).isPurchased)
            {
                result += 1;
            }
            else
            {
                result += 0;
            }
        }
        PlayerPrefs.SetString("Chars" + curPlayer, result);
    }
    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);
    }
Esempio n. 6
0
    void HandleCustomEvent(Spine.TrackEntry trc, Spine.Event e)
    {
        if (e.Data.Name == "start" || e.Data.Name == "jump_start")
        {
            move = true;
            if (height > 0)
            {
                timer = jumpFlightTime;
                if (curChar.jumpVoice != null && canTalk)
                {
                    charVoice = LeanAudio.play(curChar.jumpVoice, 1f);
                }
            }
            else
            {
                timer = fallFlightTime;
                if (curChar.fallVoice != null && canTalk)
                {
                    charVoice = LeanAudio.play(curChar.fallVoice, 1f);
                }
            }


            if (curChar.jumpSound != null)
            {
                charVoice = LeanAudio.play(curChar.jumpSound, 1f);
            }
        }
        if (e.Data.Name == "jump_end")
        {
            move = false;
            if (!hasPicked)
            {
                if (dropMgr.enabled)
                {
                    //Debug.Log ("Character Shifts index");
                    dropMgr.ShiftIndex(-(int)Mathf.Sign(height));
                }

                //Debug.Log ("Jump End " + Time.time);
                hasPicked = true;
                if (curChar.landSound != null)
                {
                    charVoice = LeanAudio.play(charStorage.GetCharacter(Persistence.currentChar).landSound);
                }
            }
        }
        if (e.Data.Name == "particle" || e.Data.Name == "particles")
        {
            Debug.Log("CALL FOR PARTICLES!");
            if (curChar.particle != null)
            {
                GameObject p = Instantiate(curChar.particle, transform.position + Vector3.up, curChar.particle.transform.rotation);
                p.transform.parent = FindObjectOfType <DropManager> ().topItemTransform;
                ParticleSystem sys = p.GetComponent <ParticleSystem> ();
                //sys.main.loop = false;
                sys.Play();
                Destroy(p, sys.main.duration);
            }
        }
        if (e.Data.Name == "sound" || e.Data.Name == "sfx")
        {
        }
    }