添加高粱生长阶段
This commit is contained in:
parent
b73f6d51a2
commit
37741b3b20
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -7,26 +7,41 @@ using UnityEngine.SocialPlatforms;
|
|||
|
||||
public enum SorghumState
|
||||
{
|
||||
Healthy,
|
||||
Diseased
|
||||
Diseased,//病株成熟
|
||||
Healthy,//健康成熟
|
||||
}
|
||||
|
||||
public enum SorghumPeriod
|
||||
{
|
||||
Mature,//成熟
|
||||
Seedling//幼苗
|
||||
}
|
||||
|
||||
public class SorghumController : PermanentTriggerBase
|
||||
{
|
||||
public GameObject DiseasedStrain;
|
||||
public GameObject HealthyStrain;
|
||||
public GameObject Diseased_Mature;//病株成熟
|
||||
public GameObject Healthy_Mature;//健康成熟
|
||||
public GameObject Diseased_Seedling;//病株成熟
|
||||
public GameObject Healthy_Seedling;//健康幼苗
|
||||
|
||||
public SorghumState State = SorghumState.Healthy;
|
||||
public SorghumPeriod Period = SorghumPeriod.Mature;
|
||||
|
||||
public bool RandomRotate = true;
|
||||
|
||||
|
||||
//LODGroup lodGroup = null;
|
||||
public void Init(SorghumState _state = SorghumState.Healthy, bool _rand = false)
|
||||
public void Init(SorghumState _state = SorghumState.Healthy, SorghumPeriod _period = SorghumPeriod.Mature, bool _rand = false)
|
||||
{
|
||||
State = _state;
|
||||
DiseasedStrain.SetActive(State == SorghumState.Diseased);
|
||||
HealthyStrain.SetActive(State == SorghumState.Healthy);
|
||||
Period = _period;
|
||||
//DiseasedStrain.SetActive(State == SorghumState.Diseased);
|
||||
//HealthyStrain.SetActive(State == SorghumState.Healthy);
|
||||
|
||||
Diseased_Mature.SetActive(State == SorghumState.Diseased && Period == SorghumPeriod.Mature);//病株成熟
|
||||
Healthy_Mature.SetActive(State == SorghumState.Healthy && Period == SorghumPeriod.Mature); //健康成熟
|
||||
Diseased_Seedling.SetActive(State == SorghumState.Diseased && Period == SorghumPeriod.Seedling);//病株成熟
|
||||
Healthy_Seedling.SetActive(State == SorghumState.Healthy && Period == SorghumPeriod.Seedling); //健康幼苗
|
||||
|
||||
RandomRotate = _rand;
|
||||
if (RandomRotate)
|
||||
|
|
@ -52,23 +67,41 @@ public class SorghumController : PermanentTriggerBase
|
|||
case SorghumState.Healthy:
|
||||
triggerName = "¸ßÁ»_Õý³£";
|
||||
this.gameObject.name = "¸ßÁ»_Õý³£";
|
||||
//lodGroup = HealthyStrain.GetComponent<LODGroup>();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
switch (Period)
|
||||
{
|
||||
//lodGroup = HealthyStrain.GetComponent<LODGroup>();
|
||||
case SorghumPeriod.Seedling:
|
||||
triggerName += "幼苗";
|
||||
this.gameObject.name += "幼苗";
|
||||
break;
|
||||
case SorghumPeriod.Mature:
|
||||
triggerName += "成熟";
|
||||
this.gameObject.name += "成熟";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject GetCurrentSorghum()
|
||||
{
|
||||
if (State == SorghumState.Diseased)
|
||||
if (Period == SorghumPeriod.Mature)
|
||||
{
|
||||
return DiseasedStrain;
|
||||
if (State == SorghumState.Diseased)
|
||||
return Diseased_Mature;
|
||||
else
|
||||
return Healthy_Mature;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return HealthyStrain;
|
||||
if (State == SorghumState.Diseased)
|
||||
return Diseased_Seedling;
|
||||
else
|
||||
return Healthy_Seedling;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void OnMDown()
|
||||
|
|
@ -82,8 +115,10 @@ public class SorghumController : PermanentTriggerBase
|
|||
|
||||
GameObject targetObj = GameObject.Find("Split_Obj");
|
||||
|
||||
GameObject targetHD = targetObj.transform.GetChild(0).gameObject;
|
||||
GameObject targetSD = targetObj.transform.GetChild(1).gameObject;
|
||||
GameObject targetHD_M = targetObj.transform.GetChild(0).gameObject;
|
||||
GameObject targetSC_M = targetObj.transform.GetChild(1).gameObject;
|
||||
GameObject targetHD_S = targetObj.transform.GetChild(2).gameObject;
|
||||
GameObject targetSC_S = targetObj.transform.GetChild(3).gameObject;
|
||||
|
||||
GameObject SplitCamera = GameObject.Find("SplitCamera");
|
||||
foreach (Transform item in SplitCamera.transform)
|
||||
|
|
@ -91,17 +126,26 @@ public class SorghumController : PermanentTriggerBase
|
|||
item.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
targetHD_M.SetActive(false);
|
||||
targetHD_S.SetActive(false);
|
||||
targetSC_M.SetActive(false);
|
||||
targetSC_S.SetActive(false);
|
||||
|
||||
if (State == SorghumState.Diseased)
|
||||
{
|
||||
targetHD.SetActive(true);
|
||||
targetSD.SetActive(false);
|
||||
if (Period == SorghumPeriod.Seedling)
|
||||
targetHD_S.SetActive(true);
|
||||
else
|
||||
targetHD_M.SetActive(true);
|
||||
GameManager.UIMgr.ShowPanel<UI_BGPanel>(E_UI_Layer.Top);
|
||||
GameManager.UIMgr.ShowPanel<UI_GraphicRextualPanel>(E_UI_Layer.Top, (p) => { p.Init(); });
|
||||
}
|
||||
else
|
||||
{
|
||||
targetHD.SetActive(false);
|
||||
targetSD.SetActive(true);
|
||||
if (Period == SorghumPeriod.Seedling)
|
||||
targetSC_S.SetActive(true);
|
||||
else
|
||||
targetSC_M.SetActive(true);
|
||||
GameManager.UIMgr.ShowPanel<UI_BGPanel>(E_UI_Layer.Top);
|
||||
GameManager.UIMgr.ShowPanel<UI_PlantComparisonPanel>(E_UI_Layer.Top, (p) => { p.Init(); });
|
||||
}
|
||||
|
|
@ -113,7 +157,7 @@ public class SorghumController : PermanentTriggerBase
|
|||
//if (GameManager.RunModelMgr?.ModeType != E_ModeType.Study)
|
||||
//{
|
||||
|
||||
_highlight = GetComponentInChildren<HighlightEffect>();
|
||||
//_highlight = GetComponentInChildren<HighlightEffect>();
|
||||
if (_highlight != null)
|
||||
_highlight.SetHighlighted(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ public class SorghumFieldController : MonoBehaviour
|
|||
public float strainDistance = 1;
|
||||
public float diseasedRate = 0;
|
||||
|
||||
public SorghumPeriod sorghumPeriod = SorghumPeriod.Mature;
|
||||
|
||||
// 新增动态渲染相关字段
|
||||
[Header("Dynamic Rendering")]
|
||||
public int chunksPerAxis = 10; // 每轴区块数量
|
||||
|
|
@ -41,7 +43,7 @@ public class SorghumFieldController : MonoBehaviour
|
|||
|
||||
// 预生成所有高粱并分配到区块
|
||||
GenerateSorghumGrid(sorghumPrefab, rowDistance, strainDistance);
|
||||
ProcessDiseasedPlants(diseasedRate, randomRotate);
|
||||
ProcessDiseasedPlants(diseasedRate, randomRotate, sorghumPeriod);
|
||||
|
||||
// 初始隐藏所有高粱
|
||||
SetAllChunksVisibility(true);
|
||||
|
|
@ -76,7 +78,7 @@ public class SorghumFieldController : MonoBehaviour
|
|||
chunkMap[chunkCoord].Add(sorghum);
|
||||
}
|
||||
|
||||
void ProcessDiseasedPlants(float diseasedRate, bool randomRotate)
|
||||
void ProcessDiseasedPlants(float diseasedRate, bool randomRotate, SorghumPeriod period)
|
||||
{
|
||||
SorghumController[] sorghumControllers = FindObjectsOfType<SorghumController>();
|
||||
int DisCount = (int)(sorghumControllers.Length * diseasedRate);
|
||||
|
|
@ -85,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.Diseased, randomRotate);
|
||||
sorghumControllers[iter].Init(SorghumState.Healthy, SorghumPeriod.Mature, randomRotate);
|
||||
sorghumControllers[iter] = sorghumControllers[sorghumControllers.Length - 1];
|
||||
SorghumController[] newArry = new SorghumController[sorghumControllers.Length - 1];
|
||||
Array.Copy(sorghumControllers, newArry, sorghumControllers.Length - 1);
|
||||
|
|
@ -93,7 +95,7 @@ public class SorghumFieldController : MonoBehaviour
|
|||
|
||||
foreach (var item in sorghumControllers)
|
||||
{
|
||||
item.Init(SorghumState.Healthy, randomRotate);
|
||||
item.Init(SorghumState.Healthy, period, randomRotate);
|
||||
SetRenderersEnabled(false, item.gameObject);
|
||||
//item.gameObject.GetComponentInChildren<Renderer>().enabled = false; // 初始隐藏
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue