TheMuseumProject/Assets/Scripts/ConstructSystem/ConstructArea.cs

28 lines
783 B
C#
Raw Normal View History

using Player.Information;
using UnityEngine;
public class ConstructArea : ConstructBase
{
[SerializeField] private string resourceName = "";
[SerializeField] private float resourceRate;
[SerializeField] private float radiusEffect;
private GameObject player;
private PlayerStats playerStats;
// Start is called before the first frame update
private void Start()
{
player = GameObject.FindGameObjectWithTag("Player");
playerStats = player.GetComponent<PlayerStats>();
}
// Update is called once per frame
private void Update()
{
if (Vector3.Distance(player.transform.position, transform.position) <= radiusEffect)
playerStats.ConsumeResource(resourceRate * Time.deltaTime, resourceName);
}
}