private void dropCurrentTool() { if (TutorialEventController.Instance.tutorialActive) { TutorialEventController.Instance.OnToolDropped(currentTool.GetToolType(), GetComponent <DoctorInputController>().playerNum); } Rigidbody rb = currentTool.transform.GetComponentInChildren <Rigidbody> (); if (rb != null) { // Remove Constraints rb.constraints = RigidbodyConstraints.None; rb.useGravity = true; rb.isKinematic = false; } // special case for bucket bool full = false; if (currentTool.GetToolType() == Tool.ToolType.BUCKET) { WaterBucket bucket = currentTool.GetComponent <WaterBucket>(); full = bucket.hasWater; } DoctorEvents.Instance.InformToolDropped(currentTool.GetToolType(), full); currentTool.transform.parent = null; currentTool = null; }
static void Main(string[] args) { WaterBucket bucket = new WaterBucket(); bucket.Overflowing += Bucket_Overflowing; bucket.Overflowed += Bucket_Overflowed; bucket.Fill(14); }
void OnTriggerStay(Collider other) { if (other.CompareTag(Tags.Player) && Input.GetButtonDown("Interact")) { PlayerItem playerItem = other.GetComponent <PlayerItem>(); if (playerItem.hasItem) { waterBucket = playerItem.heldItem.GetComponent <WaterBucket>(); if (waterBucket != null && waterBucket.hasWater && isAcornPlanted) { StartCoroutine(CoWaterSoil(playerItem)); } } } }
// When the interaction button is pressed, we must check to see if there // is and interactable nearby. If there is, then we send a message to // the interactable that the doctor is initiating an interaction. The // interactiable accepts the interaction message and acts on it only if // it is valid. public void OnInteractionButtonPressed() { // TODO: Move this if (currentTool && currentTool.GetToolType() == Tool.ToolType.BUCKET) { WaterBucket wb = currentTool as WaterBucket; if (wb.hasWater) { putOutFire(wb); // Return so that it doesn't also fill the water bucket up. return; } } // If near patient, use tool on patient. if (patientInRange() && (currentTool.GetToolType() != Tool.ToolType.CANISTER)) { useCurrentToolOnPatient(); } // Whether you are currently interacting or not, // we'll want the nearest interactable. Interactable nearbyInteractable = getNearestInteractableInRange(interactionRange); // If there is a nearby interactable, then begin interacting! if (nearbyInteractable != null) { // If currently interacting, pressing this button again will cancel the interaction. if (interacting) { nearbyInteractable.DoctorTerminatesInteracting(this); interacting = false; } // If not currently interacting, and ... // If successfully inintiated interacting, set interacting to true, // IF THE ACTION REQUIRES SUSTAINED INTERACTION OVER A TIME PERIOD. // Otherwise, false. interacting = nearbyInteractable.DocterIniatesInteracting(this); } }
public void putOutFire(WaterBucket wb) { // Check for fires in target area. Vector3 sphereOrigin = pos + checkOffset; Collider[] cols = Physics.OverlapSphere(sphereOrigin, wb.splashRadius); Debug.DrawRay(pos, checkOffset, Color.red, 0.2f); // Destroy fires. for (int i = 0; i < cols.Length; i++) { if (cols[i].GetComponentInChildren <Flame>()) { Destroy(cols[i].gameObject); } } // Deplete water level wb.pourWater(transform.forward); // Make hands dirty! Hard coding full dirt levels makeDirty(1f); }
public void OnPickupButtonPressed() { // If we currently have a tool, drop the tool. if (currentTool != null) { dropCurrentTool(); AudioControl.Instance.PlayToolDrop(); } else { // If there is a tool in range, get that tool. // Otherwise, nearestTool == null Tool nearestTool = getNearestToolInRange(interactionRange); // If there is a nearby tool, equip it. if (nearestTool != null) { equipTool(nearestTool); nearestTool.OnDoctorInitatedInteracting(); // special case for the bucket bool full = false; if (nearestTool.GetToolType() == Tool.ToolType.BUCKET) { WaterBucket bucket = nearestTool.GetComponent <WaterBucket>(); full = bucket.hasWater; } DoctorEvents.Instance.InformToolPickedUp(nearestTool.GetToolType(), full); if (TutorialEventController.Instance.tutorialActive) { TutorialEventController.Instance.InformToolPickedUp(nearestTool.GetToolType(), GetComponent <DoctorInputController>().playerNum); } AudioControl.Instance.PlayToolPickup(); } } if (TutorialEventController.Instance.tutorialActive) { TutorialEventController.Instance.InformAButtonPressed(gameObject.GetComponent <DoctorInputController>().playerNum); } }