病株就近生成

This commit is contained in:
huqibin 2025-06-03 16:51:19 +08:00
parent 5585f90ff1
commit bd5e2d6038
2 changed files with 14 additions and 10 deletions

View File

@ -46,7 +46,6 @@ public class StepState_2002 : StepState
}
else if (num == 2)
{
//工作预约
float disSorg = 100000000;
SorghumController targetSorg = null;
SorghumController[] sorghumControllers = GameObject.FindObjectsOfType<SorghumController>();
@ -60,8 +59,6 @@ public class StepState_2002 : StepState
targetSorg = item;
disSorg = dis;
}
//item.triggerName = "高粱_正常1";
//break;
}
}
@ -69,23 +66,30 @@ public class StepState_2002 : StepState
{
targetSorg.triggerName = "¸ßÁ»_Õý³£1";
}
//OfficeManager.Instance.mobileController.downIndex = 1;
}
else if (num == 3)
{
//工作预约
//OfficeManager.Instance.mobileController.downIndex = 1;
float disSorg = 100000000;
SorghumController targetSorg = null;
SorghumController[] sorghumControllers = GameObject.FindObjectsOfType<SorghumController>();
foreach (var item in sorghumControllers)
{
if (item.State == SorghumState.Diseased)
{
item.triggerName = "高粱_病株1";
break;
float dis = Vector3.Distance(OfficeManager.Instance.firstPersonController.transform.position, item.transform.position);
if (dis < disSorg)
{
targetSorg = item;
disSorg = dis;
}
}
}
if (targetSorg != null)
{
targetSorg.triggerName = "¸ßÁ»_²¡Öê1";
}
}
}
}

View File

@ -87,7 +87,7 @@ public class SorghumFieldController : MonoBehaviour
int iter = (int)(sorghumControllers.Length * UnityEngine.Random.value);
if (iter >= sorghumControllers.Length) iter = sorghumControllers.Length - 1;
if (iter < 0) iter = 0;
sorghumControllers[iter].Init(SorghumState.Healthy, SorghumPeriod.Mature, randomRotate);
sorghumControllers[iter].Init(SorghumState.Diseased, SorghumPeriod.Mature, randomRotate);
sorghumControllers[iter] = sorghumControllers[sorghumControllers.Length - 1];
SorghumController[] newArry = new SorghumController[sorghumControllers.Length - 1];
Array.Copy(sorghumControllers, newArry, sorghumControllers.Length - 1);