Beispiel #1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player" && other.gameObject.name == "Woodle Character" && !activated)
        {
            if (main == null)
            {
                main = GameObject.FindWithTag("Pause").transform.Find("Event Text").gameObject.GetComponent <TextTriggerMain>();
            }

            if (main != null)
            {
                activated = true;
                main.SetText(textID);
            }
        }
    }
    /*
     * private void OnEnable()
     * {
     *  StartCoroutine("CheckDistance");
     * }
     */

    public void CollectBerry(GameObject berry, BerryType berryType, int amount, bool playFX, int initAmount)
    {
        if (amount <= 0)
        {
            amount     = 1;
            initAmount = 1;
        }
        if (berryType == BerryType.red || berryType == BerryType.redCircle)
        {
            if (playFX)
            {
                if (PlayerPrefs.GetInt("FirstRedBerry", 0) == 0)
                {
                    PlayerPrefs.SetInt("FirstRedBerry", 1);
                    textMain.SetText(0);
                }
                tpc.berryPFX.PlayEffect(0, berry.transform.position, null, Vector3.zero, false);

                if (amount == 1)
                {
                    BerrySpawnManager.PlayBerryNoise(false);
                }
                else
                {
                    BerrySpawnManager.PlayBerryNoise(true);
                }
            }
            tpc.berryCount++;
            if (PlayerPrefs.GetInt("AllFlowers", 0) == 1)
            {
                tpc.berryCount++;
                CheckPSTrophies(2);
            }
            else
            {
                CheckPSTrophies(1);
            }


            tpc.UpdateBerryHUDRed();
        }
        if (berryType == BerryType.blue)
        {
            if (playFX)
            {
                if (PlayerPrefs.GetInt("FirstBlueBerry") == 0)
                {
                    PlayerPrefs.SetInt("FirstBlueBerry", 1);
                    textMain.SetText(1);
                }
                tpc.berryPFX.PlayEffect(1, berry.transform.position, null, Vector3.zero, false);
            }

            tpc.blueberryCount += amount;
            tpc.UpdateBerryHUDBlue();

            //     tpc.ps.CheckBlues();
            PlayerPrefs.SetInt("BlueBerryTotal", PlayerPrefs.GetInt("BlueBerryTotal") + 1);

#if UNITY_PS4
            // check trophy
            if (PlayerPrefs.GetInt("BlueBerryTotal") >= 100)
            {
                PS4Manager.ps4TrophyManager.UnlockTrophy((int)PS4_TROPHIES.COLLECT_100_BLUE_BERRIES);
            }
            //
            if (PlayerPrefs.GetInt("BlueBerryTotal") >= 930)
            {
                PS4Manager.ps4TrophyManager.UnlockTrophy((int)PS4_TROPHIES.COLLECT_ALL_BLUE_BERRIES);
            }
#endif

#if UNITY_XBOXONE
            // check trophy
            if (PlayerPrefs.GetInt("BlueBerryTotal") >= 100)
            {
                // check friend trophy
                XONEAchievements.SubmitAchievement((int)XONEACHIEVS.BLUE_BERRIES_LOVER);
            }
            //
            if (PlayerPrefs.GetInt("BlueBerryTotal") >= 930)
            {
                // check friend trophy
                XONEAchievements.SubmitAchievement((int)XONEACHIEVS.BLUE_BERRIES_CHAMPION);
            }
#endif

            if (PlayerPrefs.GetInt("BlueBerryTotal") == 930)
            {
                PlayerPrefs.SetInt("AllBlueBerries", 1);
                textMain.SetText(13);
                BerrySpawnManager.PlayBerryNoise(true);

                tpc.berryCount += 1000;
                CheckPSTrophies(1000);
                tpc.UpdateBerryHUDRed();
            }
            else
            {
                BerrySpawnManager.PlayBlueBerryNoise(0);
            }
        }
        if (playFX)
        {
            berry.GetComponentInChildren <SphereCollider>().enabled = false;
            StartCoroutine(MoveBerry(berry, berryType, initAmount));
        }
    }