Skip to content

Instantly share code, notes, and snippets.

@SenpaiRar
Created May 2, 2019 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SenpaiRar/009bd3b93f48506ad795c796cced0387 to your computer and use it in GitHub Desktop.
Save SenpaiRar/009bd3b93f48506ad795c796cced0387 to your computer and use it in GitHub Desktop.
This script is similar to the food script. It replenishes the player's water stat and then it deletes itself.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WaterScript : ClickableParent {
public string Name;
public float water_Value;
public float MinimumDistance;
private Player_Manager Master_Manager;
public AudioClip Clip;
public AudioSource Source;
void Start () {
Master_Manager = GameObject.Find("Player").GetComponent<Player_Manager>();
Source = GameObject.Find("Player").GetComponent<AudioSource>();
}
public override void OnClick(Vector3 ClickPosition)
{
if(Vector3.Distance(ClickPosition, transform.position) <= MinimumDistance){
Master_Manager.current_Water_Level += water_Value;
Source.PlayOneShot(Clip);
Destroy(gameObject);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment