CultivationOfBrewing-2/Assets/Scripts/SorghumController.cs

67 lines
1.8 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
Bootstrap.Instance.uiManager.ShowPanel<UI_GraphicRextualPanel>(this, E_UI_Layer.Top, (panel) =>
{
Debug.Log("UI_GraphicRextualPanel");
});
}
else
{
targetHD.SetActive(false);
targetSD.SetActive(true);
Bootstrap.Instance.uiManager.ShowPanel<UI_GraphicRextualPanel>( this, E_UI_Layer.Top, (panel) =>
{
Debug.Log("UI_GraphicRextualPanel");
});
}
}
}