Created
May 2, 2019 04:28
-
-
Save SenpaiRar/f814790eee55f9f9e0fa0f9c100f1db2 to your computer and use it in GitHub Desktop.
This script is an item script that replenishes the player's food and then deletes itself.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
[System.Serializable] | |
public class FoodScript : ClickableParent { | |
public string Name; | |
public float food_Value; | |
public float MMinimumDistance; | |
private Player_Manager Master_Manager; | |
public AudioSource Source; | |
public AudioClip Clip; | |
void Start () { | |
Master_Manager = GameObject.Find("Player").GetComponent<Player_Manager>(); | |
Source = GameObject.Find("Player").GetComponent<AudioSource>(); | |
} | |
public override void OnClick(Vector3 Clickposition) | |
{ | |
Debug.Log("Clicked " + Name + ", Distance: " + Vector3.Distance(Clickposition, transform.position)); | |
if(Vector3.Distance(Clickposition, transform.position) <= MMinimumDistance){ | |
Master_Manager.current_Hunger_Level += food_Value; | |
Source.PlayOneShot(Clip); | |
Destroy(gameObject); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment