void OnTriggerEnter(Collider col) { if ("Player" == col.gameObject.tag) { if (4 == Inventory.charge) { transform.FindChild("door").SendMessage("DoorCheck"); if (GameObject.Find("PowerGUI")) { Destroy(GameObject.Find("PowerGUI")); doorLoght.color = Color.green; } } else if (Inventory.charge > 0 && Inventory.charge < 4) { textHints.SendMessage("ShowHint", "This door won't budge... guess it needs more charging - maybe more power cells will help..."); if (null != lockedSound) { transform.FindChild("door").audio.PlayOneShot(lockedSound); } } else { if (null != lockedSound) { transform.FindChild("door").audio.PlayOneShot(lockedSound); } col.gameObject.SendMessage("HUDon"); textHints.SendMessage("ShowHint", "This door seems to be locked... maybe that generator needs power..."); } } }
//Player has entered a farm collider void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player") { if (!villageVisited) { switch (villageNumber) { case 2: Inventory.visitedVillageTwo = true; villageVisited = true; textHints.SendMessage("ShowHint", "Discovered " + Inventory.villageTwo); GameSettings.percentCompleted += GameSettings.percentVillage; break; case 1: textHints.SendMessage("ShowHint", "Discovered " + Inventory.villageOne); Inventory.visitedVillageOne = true; villageVisited = true; GameSettings.percentCompleted += GameSettings.percentVillage; break; } } } }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player") { if (Inventory.charge == 4) { transform.FindChild("door").SendMessage("DoorCheck"); if (GameObject.Find("PowerGUI")) { Destroy(GameObject.Find("PowerGUI")); doorLight.color = Color.green; } } else if (Inventory.charge > 0 && Inventory.charge < 4) { textHints.SendMessage("ShowHint", "The door still won't budge...\nThe generator isn't fully charged yet."); transform.FindChild("door").audio.PlayOneShot(lockedSound); } else { transform.FindChild("door").audio.PlayOneShot(lockedSound); col.gameObject.SendMessage("HUDon"); textHints.SendMessage("ShowHint", "This door hasn't the energy to open.\nFinding some power cells should do the trick."); } } }
void OnTriggerEnter(Collider col) { if (col.gameObject.name == "First Person Controller") { if (Inventory.charge == 4) { transform.FindChild("door").SendMessage("DoorCheck"); if (GameObject.Find("PowerGUI")) { Destroy(GameObject.Find("PowerGUI")); doorLight.color = Color.green; } } else if (Inventory.charge > 0 && Inventory.charge < 4) { textHints.SendMessage("ShowHint", "This door won't budge... guess it needs fully charging - maybe more power cells will help..."); //This door won't budge... guess it needs fully charging - maybe more power cells will help... //Drzwi sa nadal zamkniete... generator ma za malo mocy - moze wiecej ogniw pomoze... transform.FindChild("door").audio.PlayOneShot(lockedSound); } else { transform.FindChild("door").audio.PlayOneShot(lockedSound); col.gameObject.SendMessage("HUDon"); textHints.SendMessage("ShowHint", "This door seems locked... maybe that generator needs power..."); //This door seems locked... maybe that generator needs power... //Te drzwi wygladaja na zamkniete... \n byc moze generator wymaga odpowiedniego zasilania... } } }
void OnTriggerEnter(Collider col) { Debug.Log("Trigger entered"); //note you could do the below via name //if(col.gameObject.name =="First Person Controller"); if (col.gameObject.tag == "Player") { if (Inventory.charge == 4) { GameObject.Find("door").SendMessage("DoorCheck"); if (GameObject.Find("PowerGUI")) { Destroy(GameObject.Find("PowerGUI")); doorLight.color = Color.green; } } else if (Inventory.charge < 4) { textHints.SendMessage("ShowHint", "you need 4 cells"); //GameObject.Find("door").audio.PlayOneShot(lockedSound); Debug.Log("Im getting to the else statemet"); } //findChild > find here b/c it only seraches children not whole game } }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player") { CoconutThrower.canThrow = true; crosshair.enabled = true; if (!CoconutWin.haveWon) { textHints.SendMessage("ShowHint", "\n\n\n\n\n There's power cell attached to this game, \n maybe I'll win if I can knock down all the targets..."); // \n\n\n\n\n There's power cell attached to this game, \n maybe I'll win if I can knock down all the targets... //\n\n\n\n\n Po prawej stronie znajduje sie pojemnik z ogniwem, \n moze jesli wygram skrzynka z zawartoscia sie otworzy } } }
void OnControllerColliderHit(ControllerColliderHit col) { if (col.gameObject.name == "campfire") { if (!haveMatches && !fireIsLit) { textHints.SendMessage("ShowHint", "I could use this campfire to signal for help\nif I can find something to light it."); } else if (!fireIsLit) { LightFire(col.gameObject); } } }
void OnTriggerEnter(Collider other) { if (!other.CompareTag("Player")) { return; } //Debug.Log ("BOUM!"); other.SendMessage("AddCoin"); Texto.SendMessage("Add"); Destroy(this.gameObject); }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player") { CoconutThrower.canThrow = true; crosshair.enabled = true; if (!CoconutWin.haveWon) { textHints.SendMessage("ShowHint", "\n\n\n\n There is a power cell attached to this game,\nmaybe I'll win it if I knock down the targets."); } } }
// handles door behavoir when player enters trigger area void OnTriggerEnter(Collider col) { // checks to ensure collision is with player before carrying out routine if (col.gameObject.tag == "Player") { // checks to ensure all powercells have been collected before carrying out routine if (Inventory.charge == 4) { // sends message to DoorCheck function attached to Door game object transform.FindChild("door").SendMessage("DoorCheck"); // checks to see if charge GUI is still active before running routine. if (GameObject.Find("PowerGUI")) { // removes charge GUI from game Destroy(GameObject.Find("PowerGUI")); // changes color of light over cabin door doorLight.color = Color.green; } } else if (Inventory.charge > 0 && Inventory.charge < 4) { // sends call to ShowHint function to turn on text hint GUI and dsiplay a message textHints.SendMessage("ShowHint", "This door won't budge.. guess it needs to be fully charged- maybe more power cells will help..."); // plays locked sound from door transform.FindChild("door").audio.PlayOneShot(lockedSound); } else { // plays locked sound from door transform.FindChild("door").audio.PlayOneShot(lockedSound); // sends call to HUDon function to turn on charge GUI col.gameObject.SendMessage("HUDon"); // sends call to ShowHint function to turn on text hint GUI and dsiplay a message textHints.SendMessage("ShowHint", "This door seems locked.. maybe that generator needs power..."); } } }
// Use this for initialization void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player") { CoconutThrower.canThrow = true; //note CoconutThrower is static hence why we can get it so //easily crosshair.enabled = true; if (!CoconutWin.haveWon) { textHints.SendMessage("ShowHint", "\n\n\n\n There's a power cell attached to this game,\n maybe I'll win it if I can knock down all the targets..."); } } }
void OnControllerColliderHit(ControllerColliderHit col) { if (col.gameObject.name == "campfire") { if (haveMatches && !fireIsLit) { LightFire(col.gameObject); } else if (!haveMatches && !fireIsLit) { textHints.SendMessage("ShowHint", "I could use this campfire to signal for help... if only I could light it..."); //I could use this campfire to signal for help... if only I could light it... //Powiniennem uzyc ogniska do wezwania pomocy... gdybym tylko znalazl zapalki... } } }
// handles the enabling of cocunt throwing for the player character void OnTriggerEnter(Collider col) { // check for collisions with the player character before carrying out routine if (col.gameObject.tag == "Player") { // passes a vaule to canThrow boolean within the CoconutThower class CoconutThrower.canThrow = true; // enables the crosshair GUI texture crosshair.enabled = true; // checks to see if player has already won game previously before carrying out routine if (!CoconutWin.haveWon) { // sends a message to the ShowHint function to display a text hint textHints.SendMessage("ShowHint", "\n\n\n\n\n There's a power cell attahced to this game, \n maybe I'll win it if I can nock down all the targets..."); } } }
void OnControllerColliderHit(ControllerColliderHit col) { if ("campfire" == col.gameObject.name) { if (haveMatches && !fireIsLit) { LightFire(col.gameObject); Destroy(matchGUIInstance); haveMatches = false; fireIsLit = true; winObject.SendMessage("GameOver"); } else if (!haveMatches && !fireIsLit) { textHints.SendMessage("ShowHint", "I could use this campfire to signal for help...\nIf only I could light it..."); } } }
// handles players collision with campfire object void OnControllerColliderHit(ControllerColliderHit col) { // check to see if object player has collided with is the campfire if (col.gameObject.name == "campfire") { // conditional checks of players invenotry and state of campfire if (haveMatches && !fireIsLit) { // calls LightFire function LightFire(col.gameObject); } else if (!haveMatches && !fireIsLit) { // dispalys message to player via textHint GUI Text textHints.SendMessage("ShowHint", "I could use this campfire to sgnal for help..if only I could light it.."); } } }
public void OnControllerColliderHit(ControllerColliderHit col) { if (col.gameObject.name == "campfire" && haveMatches) { LightFire(col.gameObject); } else if (!haveMatches && !fireIsLit && col.gameObject.name == "campfire") { textHints.SendMessage("ShowHint", "you need to get\n the matches\n in the cabin."); } if (col.gameObject.tag == "berry") { berries++; Debug.Log("berry hit " + berries); Destroy(col.gameObject); BerryPickup(); } }
public int farmOrder; //To track the database //Player has entered a farm collider void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player") { if (!farmVisited) { if (addFarm == null) { Debug.Log("Can't find the Inventory GameObject."); } //they found a farm, so add it to the inventory and update a GUI addFarm.AddFarm(farmOrder); Inventory.farmsVisited += 1; textHints.SendMessage("ShowHint", "Discovered " + addFarm.GetFarmName(farmOrder) + " Farm"); farmVisited = true; } } }