60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
public enum SorghumState
|
||
{
|
||
Healthy,
|
||
Diseased
|
||
}
|
||
|
||
public class SorghumController : PermanentTriggerBase
|
||
{
|
||
public GameObject DiseasedStrain;
|
||
public GameObject HealthyStrain;
|
||
|
||
public SorghumState State = SorghumState.Healthy;
|
||
|
||
public bool RandomRotate = true;
|
||
|
||
public void Init(SorghumState _state = SorghumState.Healthy, bool _rand = false)
|
||
{
|
||
State = _state;
|
||
DiseasedStrain.SetActive(State == SorghumState.Diseased);
|
||
HealthyStrain.SetActive(State == SorghumState.Healthy);
|
||
|
||
RandomRotate = _rand;
|
||
if (RandomRotate)
|
||
{
|
||
// 获取当前旋转角度
|
||
Vector3 currentRotation = transform.eulerAngles;
|
||
|
||
// 设置Y轴为随机角度(0到360度)
|
||
currentRotation.y = Random.Range(0f, 360f);
|
||
|
||
// 应用新的旋转角度
|
||
transform.eulerAngles = currentRotation;
|
||
}
|
||
}
|
||
|
||
protected override void OnMDown()
|
||
{
|
||
GameObject targetObj = GameObject.Find("Split_Obj");
|
||
|
||
GameObject targetHD = targetObj.transform.GetChild(0).gameObject;
|
||
GameObject targetSD = targetObj.transform.GetChild(1).gameObject;
|
||
if (State == SorghumState.Diseased)
|
||
{
|
||
targetHD.SetActive(true);
|
||
targetSD.SetActive(false);
|
||
GameManager.UIMgr.ShowPanel<UI_GraphicRextualPanel>();
|
||
}
|
||
else
|
||
{
|
||
targetHD.SetActive(false);
|
||
targetSD.SetActive(true);
|
||
GameManager.UIMgr.ShowPanel<UI_GraphicRextualPanel>();
|
||
}
|
||
}
|
||
}
|