void OnTriggerExit(Collider col) { buttonToPress = FindObjectOfType(typeof(ButtonToPress)) as ButtonToPress; if (col.gameObject.tag == "crop") { buttonToPress.hidePanel(); } else if (col.gameObject.tag == "NPC") { buttonToPress.hidePanel(); } }
void OnCollisionExit(Collision col) { buttonToPress = FindObjectOfType(typeof(ButtonToPress)) as ButtonToPress; if (col.gameObject.tag == "shopCounter") { buttonToPress.hidePanel(); } else if (col.gameObject.tag == "ShippingBinObject") { buttonToPress.hidePanel(); } else if (col.gameObject.tag == "Fountain") { buttonToPress.hidePanel(); } else if (col.gameObject.tag == "Farm") { buttonToPress.hidePanel(); } else if (col.gameObject.tag == "MyHouse") { buttonToPress.hidePanel(); } else if (col.gameObject.tag == "Bed") { buttonToPress.hidePanel(); } }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.Escape)) { pauseMenu.gameObject.SetActive(true); Time.timeScale = 0.0f; } if (holdingItem.holdingItem) { if (NPCCollision.collision == true) { if (Input.GetKey(KeyCode.E)) { if (NPCCollision.NPC.GetComponent <NPCBehaviour> ().alreadygifted) { NPCCollision.NPC.GetComponent <NPCBehaviour> ().Talk(holdingItem.itemCode); anim.SetBool("isHolding", false); holdingItem.saveItem(); } else { NPCCollision.NPC.GetComponent <NPCBehaviour> ().Talk(holdingItem.itemCode); anim.SetBool("isHolding", false); holdingItem.Gift(holdingItem.itemCode); } } } if (NPCCollision.collision == true && NPCCollision.NPC.GetComponent <NPCBehaviour> ().talking) { if (Input.GetMouseButtonDown(0)) { anim.SetBool("isHolding", false); NPCCollision.NPC.GetComponent <NPCBehaviour> ().closeDialog(); } } if (Input.GetKey(KeyCode.X)) { buttonToPress.hidePanel(); anim.SetBool("isHolding", false); holdingItem.saveItem(); } } if (!holdingItem.holdingItem) { if (!this.GetComponent <Animator> ().GetBool("isPlowing") && !this.GetComponent <Animator> ().GetBool("isRecollecting") && !this.GetComponent <Animator> ().GetBool("isPlanting") && !this.GetComponent <Animator> ().GetBool("isWatering") && !this.GetComponent <Animator> ().GetBool("isCutting")) { if (Input.GetKey(KeyCode.F)) { Time.timeScale = 0.0f; ToolCanvas.gameObject.SetActive(true); } if (Input.GetKey(KeyCode.I)) { InventoryView.gameObject.SetActive(true); Time.timeScale = 0.0f; } } if (tool.Equals(Tools.NONE)) { if (Input.GetMouseButtonDown(1)) { anim.SetBool("isRecollecting", true); StartCoroutine(waitForEndOfAnimGrab()); } } if (tool.Equals(Tools.HOE)) { if (Input.GetMouseButtonDown(1)) { hoeGO.SetActive(true); hoeGO.GetComponent <Animator> ().SetBool("isPlowing", true); anim.SetBool("isPlowing", true); hoe.plowSoil(); StartCoroutine(waitForEndOfAnimPlow()); } } if (tool.Equals(Tools.SICKLE)) { if (Input.GetMouseButtonDown(1)) { sickleGO.SetActive(true); sickleGO.GetComponent <Animator> ().SetBool("isCutting", true); anim.SetBool("isCutting", true); sickle.cutWeed(); StartCoroutine(waitForEndOfAnimSickle()); } } if (tool.Equals(Tools.SEEDS)) { if (Input.GetMouseButtonDown(1)) { anim.SetBool("isPlanting", true); plant.plantSeeds(); StartCoroutine(waitForEndOfAnimPlant()); } } if (tool.Equals(Tools.WATERINGCAN)) { if (Input.GetMouseButtonDown(1)) { wcanGO.SetActive(true); wcanGO.GetComponent <Animator> ().SetBool("isWatering", true); anim.SetBool("isWatering", true); wateringCan.waterSoil(); StartCoroutine(waitForEndOfAnimWater()); } } if (fountainCollision.collision == true) { if (Input.GetKey(KeyCode.E)) { wcanGO.SetActive(true); wcanGO.GetComponent <Animator> ().SetBool("isWatering", true); anim.SetBool("isWatering", true); StartCoroutine(waitForEndOfAnimChargeWCan()); } } if (NPCCollision.collision == true && !NPCCollision.NPC.GetComponent <NPCBehaviour> ().talking) { if (Input.GetKey(KeyCode.E)) { anim.SetBool("isHolding", false); NPCCollision.NPC.GetComponent <NPCBehaviour> ().Talk(-1); } } if (NPCCollision.collision == true && NPCCollision.NPC.GetComponent <NPCBehaviour> ().talking) { if (Input.GetMouseButtonDown(0)) { anim.SetBool("isHolding", false); NPCCollision.NPC.GetComponent <NPCBehaviour> ().closeDialog(); } } } }
public void recollect() { GameObject cropsHandler = GameObject.FindGameObjectWithTag("CropHandler"); CropBehaviour[] crops = cropsHandler.GetComponentsInChildren <CropBehaviour> (); tree = cropsHandler.GetComponentsInChildren <TreeBehaviour> (); Ray ray = camera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; CreateSoil sl = FindObjectOfType(typeof(CreateSoil)) as CreateSoil; soil = sl.allSquares; MockCropDB cropDB = FindObjectOfType <MockCropDB> (); if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "crop") { for (int i = 0; i < crops.Length; i++) { if (crops [i].GetComponent <CropCollision> () != null) { if (crops [i].GetComponent <CropCollision> ().collision == true && hit.transform.Equals(crops [i].transform)) { foreach (Soil s in soil) { if (s.getSoil().transform.position.x == crops [i].transform.position.x && s.getSoil().transform.position.z == crops [i].transform.position.z) { if (s.getType().Equals(Soil.SoilTypes.PLANTED)) { s.soilType = Soil.SoilTypes.PLOWED; } if (s.getType().Equals(Soil.SoilTypes.WATEREDANDPLATED)) { s.soilType = Soil.SoilTypes.WATERED; } } } buttonToPress.hidePanel(); Destroy(crops [i].transform.gameObject); InventoryItem item = new InventoryItem(crops [i].cropName, crops [i].cropDescription, crops [i].staminaRecovery, crops[i].price, crops[i].code, InventoryItem.inventoryTypes.EDIBLE); inventory.addItem(item, 9); break; } } } } else if (hit.transform.tag == "SpawnItem") { Debug.Log(Vector3.Distance(hit.transform.position, player.transform.position) < 10); string name = hit.transform.name.Replace("(Clone)", ""); if (Vector3.Distance(hit.transform.position, player.transform.position) < 10) { if (hit.transform.name.Contains("Branch")) { InventoryItem item = new InventoryItem(name, "A branch, nothing more, nothing less.", 0, 1, 20, InventoryItem.inventoryTypes.NOTEDIBLE); inventory.addItem(item, 1); Destroy(hit.transform.gameObject); } else if (hit.transform.name.Contains("Apricot")) { InventoryItem item = new InventoryItem(name, "Wild item which you can eat or sell. Only found in spring.", 3, 20, 16, InventoryItem.inventoryTypes.EDIBLE); inventory.addItem(item, 1); Destroy(hit.transform.gameObject); } else if (hit.transform.name.Contains("Plum")) { InventoryItem item = new InventoryItem(name, "Wild item which you can eat or sell. Only found in summer.", 3, 20, 16, InventoryItem.inventoryTypes.EDIBLE); inventory.addItem(item, 1); Destroy(hit.transform.gameObject); } else if (hit.transform.name.Contains("Black")) { InventoryItem item = new InventoryItem(name, "Wild item which you can eat or sell. Only found in fall.", 3, 20, 16, InventoryItem.inventoryTypes.EDIBLE); inventory.addItem(item, 1); Destroy(hit.transform.gameObject); } else if (hit.transform.name.Contains("Goji")) { InventoryItem item = new InventoryItem(name, "Wild item which you can eat or sell. Only found in winter", 3, 20, 16, InventoryItem.inventoryTypes.EDIBLE); inventory.addItem(item, 1); Destroy(hit.transform.gameObject); } } } else if (hit.transform.tag == "tree") { for (int j = 0; j < tree.Length; j++) { if (tree [j].GetComponent <TreeCollision> () != null) { if (tree [j].GetComponent <TreeCollision> ().collision == true && hit.transform.Equals(tree [j].transform)) { tree [j].daysToNextStage = tree [j].dayToHarvest; tree[j].gameObject.GetComponent <Renderer> ().sharedMaterials = tree[j].M_ST2; tree[j].GetComponent <MeshFilter> ().sharedMesh = tree[j].MF_ST2.sharedMesh; InventoryItem fruit = new InventoryItem(tree [j].treeName, tree [j].treeDescription, tree [j].staminaRecovery, tree [j].price, tree [j].code, InventoryItem.inventoryTypes.EDIBLE); inventory.addItem(fruit, 3); break; } } } } } }