Hi, I am asking just for curiosity. If i need use farmsoil timer in growingCrops constructor instead of growingcrops timer in line 39 what should i do.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class farmSoil : MonoBehaviour
{
float timer;
public List<growingCrops> currentCrops = new List<growingCrops>();
public Transform[] cropLoc;
public GameObject crop;
public GameObject cropHarvested;
float step= 16.53816f- 14.667f;
private void FixedUpdate()
{
for(int i = 0; i < currentCrops.Count; i++)
{
currentCrops[i].timer -= Time.deltaTime;
}
}
public void addCropsTilesToList()
{
foreach (Transform emptCropTile in cropLoc)
{
allObjects.emptyCropTiles.Add(emptCropTile);
}
}
public class growingCrops
{
public float timer;
public objectInfo myInfo;
public Vector3 loc;
public growingCrops(float timer,objectInfo myInfo,Vector3 loc)
{
this.timer = timer; //this one i want to use farmsoil timer here
this.myInfo = myInfo;
this.loc = loc;
}
}
void createWithRotation()
{
float angle = transform.rotation.eulerAngles.y; // Get rotation angle in radians
Vector3 loc = Vector3.zero;
Quaternion rot = Quaternion.Euler(0f, angle, 0f);
for (int i = 0; i < 5; i++)
{
for (int a = 0; a < 5; a++)
{
Vector3 dist = new Vector3(i, 0f, a) * step;
dist = rot * dist;
float z = Mathf.Sin(angle);
float x = Mathf.Cos(angle);
// loc = initialPoint.position + dist;
Instantiate(crop, loc, rot);
}
}
}
// Update is called once per frame
}