void CollectBerry(GameObject berry) { tpc.berryCount += 1; BerrySpawnManager.PlayBerryNoise(false); if (berry.transform.Find("BlobShadowProjector") != null) { berry.transform.Find("BlobShadowProjector").gameObject.SetActive(false); } StartCoroutine(MoveBerry(berry)); }
IEnumerator BerryReward(int amount) { if (amount >= 5) { tpc.berryCount += 5; } else { tpc.berryCount += amount; } tpc.UpdateBerryHUDRed(); BerrySpawnManager.PlayBerryNoise(false); amount -= 5; yield return(new WaitForSeconds(0.2f)); if (amount > 0) { StartCoroutine(BerryReward(amount)); } }
void OnTriggerEnter(Collider other) { if ((curAnim.inAttack || curAnim.inAttack2 || curAnim.inAttack3)) { if (playerI == 0) { if (((collisionLayers & 1 << other.gameObject.layer) != 0)) { if (other.gameObject.GetComponent <ActivateButton>() == null && (other.gameObject.name != "LeafBox")) { if (Physics.Raycast(this.transform.position, tpc.transform.forward, out checkCol, 3f, collisionLayers) && !checkCol.collider.isTrigger && checkCol.normal.y <= 0.1f) { BounceChara(-checkCol.normal, true); } } } if (other.gameObject.name == "LeafBox") { lbo = other.gameObject.GetComponentInParent <LeafBoxObstacle>(); if (tpc.leafNo >= lbo.boxType) { HDRumbleMain.PlayVibrationPreset(playerI, "D06_Thumpp4", 1f, 0, 0.2f); lbo.DestroyBox(); } else { if (lbo.boxType == 5) { if (PlayerPrefs.GetInt("WrongLeafBlockBlack", 0) == 0) { PlayerPrefs.SetInt("WrongLeafBlockBlack", 1); tpc.ps.gameObject.GetComponentInChildren <TextTriggerMain>().SetText(8); } } else { if (PlayerPrefs.GetInt("WrongLeafBlock", 0) == 0) { PlayerPrefs.SetInt("WrongLeafBlock", 1); tpc.ps.gameObject.GetComponentInChildren <TextTriggerMain>().SetText(7); } } lbo.Wrong(); LeafStarKnockback(other.transform.position); } } if (other.gameObject.GetComponent <NPCCage>()) { LeafStarKnockback(other.transform.position); } } if (other.tag == "LeafHit" || other.tag == "TouchActivate") { if (other.gameObject.GetComponentInChildren <Animator>()) { other.gameObject.GetComponentInChildren <Animator>().SetBool("Activate", true); if (other.tag == "LeafHit") { BerrySpawnManager.SpawnABerry(other.transform.position); } } } } }
IEnumerator Killed() { wasKilled = true; Vector3 curScale = this.transform.localScale; if (icodescript) { curScale = icodescript.gameObject.transform.localScale; } for (float k = 0f; k <= 1f; k += (1f / 60f)) { if (icodescript) { icodescript.gameObject.transform.localScale = Vector3.Lerp(curScale, Vector3.one * 0.001f, k); } else { this.transform.localScale = Vector3.Lerp(curScale, Vector3.one * 0.001f, k); } yield return(null); } if (spawnBigBerries) { int total = Random.Range(2, 4); for (int k = 0; k < total; k++) { BerrySpawnManager.SpawnABigBerry(this.transform.position); } } else { if (berriesToSpawn > 0) { for (int k = 0; k < berriesToSpawn; k++) { BerrySpawnManager.SpawnABerry(this.transform.position); } } } if (sound != null) { sound.enabled = true; sound.clip = berryRelease; sound.loop = false; sound.Stop(); sound.PlayDelayed(0f); } foreach (Renderer r in renderers) { r.enabled = false; } yield return(new WaitForSeconds(1f)); if (parentToDisable == null) { if (this.transform.parent.parent != null && this.transform.parent.parent.GetComponent <IActivablePrefab>()) { Destroy(this.transform.parent.parent.gameObject); } else { Destroy(this.transform.parent.gameObject); } } else { Destroy(parentToDisable.gameObject); // parentToDisable.SetActive(false); } }
/* * 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)); } }