void OnParticleCollision(GameObject other) { GameObject obj = other.gameObject; bool isFire = obj.CompareTag("Fire"); if (!isFire && obj.transform.parent != null) { isFire = obj.transform.parent.gameObject.CompareTag("Fire"); } if (isFire) { DateTime now = DateTime.Now; AudioSource fireAudioSource = GetComponent <AudioSource>(); if ((now - lastFire).Seconds >= 1) { if (!fireAudioSource.isPlaying) { fireAudioSource.Play(); } } lastFire = now; MasterController.ShowMessage(""); HealthController.AddHealth(-0.4f); fireCounter += 1; } }
void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { healthController.AddHealth(healthPoints); Destroy(gameObject); } }
//Main function void Update() { // if(Input.GetKeyDown("f") && enter){ if (isOn && inArea && MainControls.Check(MainControls.Key.OpenDoor)) { myLight.enabled = !myLight.enabled; renderer.material.mainTexture = theTVOff; HealthController.AddHealth(20); AudioSource.PlayClipAtPoint(successAudio, transform.position); isOn = false; } }
bool HealPlayer(int health) { if (healthController.health >= healthController.maxHealth) { return(false); } infoSection.SetMessage("Picked up a health bonus."); colorOverlay.SetColor(pickupScreenColor, .25f, .25f, .25f, 1); healthController.AddHealth(health); return(true); }
void OnTriggerEnter(Collider other) { GameObject obj = other.gameObject; if (obj.name == "Cross") { AudioSource.PlayClipAtPoint(successAudio, transform.position); Destroy(obj); AudioSource.PlayClipAtPoint(picked_up_a_first_aid_kit, transform.position, 1.0f); MasterController.ShowMessage(""); HealthController.AddHealth(15); } }
void OnTriggerEnter(Collider coll) { GameObject object_collided_with = coll.gameObject; if (object_collided_with.tag == "rupee") { if (inventory != null) { inventory.AddRupees(1); } Destroy(object_collided_with); // add sound effect AudioSource.PlayClipAtPoint(rupee_collection_sound_clip, Camera.main.transform.position); } else if (object_collided_with.tag == "key") { if (inventory != null) { inventory.AddKeys(1); } Destroy(object_collided_with); AudioSource.PlayClipAtPoint(key_collection_sound_clip, Camera.main.transform.position); } else if (object_collided_with.tag == "bomb") { if (inventory != null) { inventory.AddBomb(1); } Destroy(object_collided_with); AudioSource.PlayClipAtPoint(bomb_collection_sound_clip, Camera.main.transform.position); } else if (object_collided_with.tag == "heart") { if (healthController != null) { healthController.AddHealth(1f); } Destroy(object_collided_with); AudioSource.PlayClipAtPoint(health_collection_sound_clip, Camera.main.transform.position); } }
void UsePotion() { //insert potion and actionButton here if (Input.GetButton("Potion")) { if (!globalCoolDown) { bool healthfilled = false; healthfilled = healthController.AddHealth(); if (healthfilled) { globalCoolDown = !globalCoolDown; Invoke(MyConst.Cooldown, 10); } } } }
//Main function void Update() { if (open) { transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, openRot, Time.deltaTime * smooth); } else { transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, defaultRot, Time.deltaTime * smooth); } // if(Input.GetKeyDown("f") && enter){ if (enter && MainControls.Check(MainControls.Key.OpenDoor)) { open = !open; HealthController.AddHealth(-5); AudioSource.PlayClipAtPoint(ouchHotDoorAudio, transform.position, 1); } }
void FixedUpdate() { if (fireCounter >= FIRE_THRESHOLD) { // Trigger fire damage HealthController.AddHealth(-5e-2f); // Handle shaking mechanism Quaternion rot = Camera.main.gameObject.transform.rotation; float angle = Mathf.Abs(Quaternion.Angle(rot, lastRotation)); if (angle >= SHAKE_THRESHOLD) { shakeCounter += 1; if (shakeCounter >= SHAKE_TIMES_THRESHOLD) { fireCounter = 0f; shakeCounter = 0f; } } lastRotation = rot; } }
void OnTriggerEnter2D(Collider2D col) { //Debug.Log(col.gameObject.tag); if (col.gameObject.CompareTag("Coin") && !GameManager.inst.coinContainer[col.gameObject].IsTaken) { GameManager.inst.coinContainer[col.gameObject].OnTake(); //Debug.Log("Coin is taken " + col.gameObject.transform.parent.gameObject.name); myCoinsCount++; myUI.SetCoins(myCoinsCount); } if (col.gameObject.CompareTag("AidKit") && !GameManager.inst.healthKitContainer[col.gameObject].IsTaken) { myHealth.AddHealth(GameManager.inst.healthKitContainer[col.gameObject].GetHealth()); } if (col.gameObject.CompareTag("Portal")) { Destroy(col.gameObject); gameObject.GetComponent <PlayerControllerScript>().OnWinLevel(); } }
void OnControllerColliderHit(ControllerColliderHit controllerColliderHit) { GameObject obj = controllerColliderHit.gameObject; if (obj.name == "Door") { AudioSource.PlayClipAtPoint(nextLevelAudio, transform.position, 2.0f); MasterController.endGame(true, null); } else if (obj.name == "Window") { AudioSource.PlayClipAtPoint(gameOverAudio, transform.position, 3.0f); AudioSource.PlayClipAtPoint(stay_away_from_windows, transform.position, 2.0f); MasterController.endGame(false, ""); } else if (obj.name == "tableUnder") { AudioSource.PlayClipAtPoint(successAudio, transform.position); Destroy(obj); AudioSource.PlayClipAtPoint(protected_yourself, transform.position, 3.0f); MasterController.ShowMessage(""); HealthController.AddHealth(10); } }