mirror of
				https://github.com/DerTyp7/harvestdale-unity.git
				synced 2025-10-31 05:27:07 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			45 lines
		
	
	
		
			793 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			793 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using UnityEngine;
 | |
| using UnityEngine.Tilemaps;
 | |
| 
 | |
| public class Field : Building
 | |
| {
 | |
|   public Crop TESTCROP;
 | |
|   public Crop crop;
 | |
| 
 | |
|   public SpriteRenderer currentCropSprite;
 | |
|   public int daysSincePlanted;
 | |
|   public bool isWatered;
 | |
|   public bool isDead = false;
 | |
|   private void Start()
 | |
|   {
 | |
|     TimeManager.OnDayChanged += AddDay;
 | |
|   }
 | |
|   private void AddDay()
 | |
|   {
 | |
|     if (crop && isPlaced && !isDead)
 | |
|     {
 | |
|       if (!isWatered)
 | |
|         isDead = true;
 | |
|       else
 | |
|       {
 | |
|         daysSincePlanted++;
 | |
|         currentCropSprite.sprite = crop.sprites[daysSincePlanted];
 | |
|       }
 | |
| 
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   public void Plant(Crop newCrop)
 | |
|   {
 | |
|     daysSincePlanted = 0;
 | |
|     isDead = false;
 | |
|     crop = newCrop;
 | |
|   }
 | |
| 
 | |
|   public override void OnPlace()
 | |
|   {
 | |
|     daysSincePlanted = 0;
 | |
|     isDead = false;
 | |
|     Plant(TESTCROP);
 | |
|   }
 | |
| } | 
