void OnTriggerEnter(Collider c) { BallCollector bc = null; if (c.attachedRigidbody != null) { bc = c.attachedRigidbody.gameObject.GetComponent <BallCollector>(); } if (bc != null) { switch (fishColor) { case FishColor.Red: redFish++; break; case FishColor.Green: greenFish++; break; case FishColor.Blue: blueFish++; break; case FishColor.Orange: orangeFish++; break; } string fishString = string.Format ( " Red: {0}\n Green: {1}\n Blue: {2}\n Orange: {3}", redFish, greenFish, blueFish, orangeFish ); fishScore.text = fishString; if (redFish >= 3 && greenFish >= 3 && blueFish >= 3 && orangeFish >= 3 && flag) { GameObject.Find("Star").transform.Find("Thick Corona").gameObject.SetActive(true); GameObject top_plane = GameObject.Find("GroundingPlane"); fishString = " Congratulations!\n Now look to the skies\n and head towards the\n light"; fishScore.text = fishString; GameObject.Find("Zelda").GetComponent <AudioSource>().Play(); top_plane.SetActive(false); flag = false; } Destroy(this.gameObject); } }
void OnTriggerEnter(Collider c) { if (c.attachedRigidbody != null) { BallCollector bc = c.attachedRigidbody.gameObject.GetComponent <BallCollector>(); if (bc != null) { EventManager.TriggerEvent <BombBounceEvent, Vector3>(c.transform.position); Destroy(this.gameObject); bc.ReceiveBall(); } } }
public BallSystem(BallPrefabs ballPrefabs, StageSystem stageSystem) { stageSystem.AddNoMoreBallsTrigger(this); getBallPrefab = ballPrefabs.GetPrefab; ballCategoriesTotal = ballPrefabs.GetGroupsCount(); getSelectedBallCategory = () => PersistentData.GetIntDecoded(GetType(), 0); getSelectedBallIndex = () => PersistentData.GetIntDecoded(GetType(), 1); setSelectedBallCategory = x => PersistentData.SetIntEncoded(GetType(), 0, x); setSelectedBallIndex = x => PersistentData.SetIntEncoded(GetType(), 1, x); UnlockBall(0, 0); gameZone = Object.FindObjectOfType <GameZone>(); ballCollector = Object.FindObjectOfType <BallCollector>(); }