Advertisement
evelynshilosky

Soil - Part 37

Apr 18th, 2024
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. public class Soil : MonoBehaviour
  7. {
  8.     public bool isEmpty = true;
  9.  
  10.     public bool playerInRange;
  11.     public string plantName;
  12.  
  13.     private void Update()
  14.     {
  15.         float distance = Vector3.Distance(PlayerState.Instance.playerBody.transform.position, transform.position);
  16.  
  17.         if (distance < 10f)
  18.         {
  19.             playerInRange = true;
  20.         }
  21.         else
  22.         {
  23.             playerInRange = false;
  24.         }
  25.     }
  26.    
  27.     internal void PlantSeed()
  28.     {
  29.         InventoryItem selectedSeed = EquipSystem.Instance.selectedItem.GetComponent<InventoryItem>();
  30.         isEmpty = false;
  31.  
  32.  
  33.         string onlyPlantName = selectedSeed.thisName.Split(new string[] { " Seed" }, StringSplitOptions.None)[0];
  34.         plantName = onlyPlantName;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement