예제 #1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        HeroRabbit rabit = collider.GetComponent <HeroRabbit>();

        if (rabit != null)
        {
            GameObject parent = UICamera.first.transform.parent.gameObject;

            GameObject obj = NGUITools.AddChild(parent, winScreenPrefab);

            WinScreenPopUp popup = obj.GetComponent <WinScreenPopUp>();



            CrystalBar cb = (CrystalBar)LevelController.current.cb;
            if (SceneManager.GetActiveScene().name == "Level2")
            {
                popup.setCoins(PlayerStats.stat.getCoins2());
                PlayerStats.stat.endLevel2(true);
                PlayerStats.stat.allCrystalsSet(1, cb.collectedCrystals() == 3);
                popup.setFruits(PlayerStats.stat.collectedFruits(), PlayerStats.stat.getMaxFruits());
            }
            else
            {
                popup.setCoins(PlayerStats.stat.getCoins());
                PlayerStats.stat.endLevel1(true);
                PlayerStats.stat.allCrystalsSet(0, cb.collectedCrystals() == 3);
                popup.setFruits(PlayerStats.stat.collectedFruits(), PlayerStats.stat.getMaxFruits());
            }
            PlayerStats.stat.saveStatistics();
        }
    }
예제 #2
0
    void Start()
    {
        closing.signalOnClick.AddListener(this.onClose);
        blackBackground.signalOnClick.AddListener(this.onClose);
        coinsLabel  = this.transform.GetChild(1).gameObject.transform.GetChild(0).gameObject.GetComponent <UILabel>();
        fruitsLabel = this.transform.GetChild(1).gameObject.transform.GetChild(1).gameObject.GetComponent <UILabel>();
        cb          = this.transform.GetChild(1).gameObject.transform.GetChild(2).gameObject.GetComponent <CrystalBar>();
        cb1         = (CrystalBar)LevelController.current.cb;
        cb.loadSprites(cb1.red, cb1.green, cb1.blue);

        for (int i = 0; i < 3; i++)
        {
            if (cb1.colir[i] != -1)
            {
                cb.add(cb1.colir[i]);
            }
        }


        coinsLabel.text  = coins + "";
        fruitsLabel.text = fruits + "/" + full;
    }