CultivationOfBrewing-2/Assets/Scripts/HQB/SorghumController.cs

136 lines
3.6 KiB
C#
Raw 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 HighlightPlus;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.SocialPlatforms;
public enum SorghumState
{
Healthy,
Diseased
}
public class SorghumController : PermanentTriggerBase
{
public GameObject DiseasedStrain;
public GameObject HealthyStrain;
public SorghumState State = SorghumState.Healthy;
public bool RandomRotate = true;
//LODGroup lodGroup = null;
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;
}
switch (State)
{
case SorghumState.Diseased:
triggerName = "高粱_病株";
this.gameObject.name = "高粱_病株";
//lodGroup = DiseasedStrain.GetComponent<LODGroup>();
break;
case SorghumState.Healthy:
triggerName = "高粱_正常";
this.gameObject.name = "高粱_正常";
//lodGroup = HealthyStrain.GetComponent<LODGroup>();
break;
}
}
public GameObject GetCurrentSorghum()
{
if (State == SorghumState.Diseased)
{
return DiseasedStrain;
}
else
{
return HealthyStrain;
}
}
protected override void OnMDown()
{
RangeFinding rf = OfficeManager.Instance.gameObject.GetComponent<RangeFinding>();
if (rf != null && rf.enabled)
{
return;
}
GameObject targetObj = GameObject.Find("Split_Obj");
GameObject targetHD = targetObj.transform.GetChild(0).gameObject;
GameObject targetSD = targetObj.transform.GetChild(1).gameObject;
GameObject SplitCamera = GameObject.Find("SplitCamera");
foreach (Transform item in SplitCamera.transform)
{
item.gameObject.SetActive(true);
}
if (State == SorghumState.Diseased)
{
targetHD.SetActive(true);
targetSD.SetActive(false);
GameManager.UIMgr.ShowPanel<UI_BGPanel>(E_UI_Layer.Bot);
GameManager.UIMgr.ShowPanel<UI_GraphicRextualPanel>(E_UI_Layer.Top, (p) => { p.Init(); });
}
else
{
targetHD.SetActive(false);
targetSD.SetActive(true);
GameManager.UIMgr.ShowPanel<UI_BGPanel>(E_UI_Layer.Bot);
GameManager.UIMgr.ShowPanel<UI_PlantComparisonPanel>(E_UI_Layer.Top, (p) => { p.Init(); });
}
}
protected override void OnMEnter()
{
base.OnMEnter();
//if (GameManager.RunModelMgr?.ModeType != E_ModeType.Study)
//{
_highlight = GetComponentInChildren<HighlightEffect>();
if (_highlight != null)
_highlight.SetHighlighted(true);
//Debug.Log("当前渲染:" + GetLODCurShowLevel(Camera.main, lodGroup));
//}
}
protected override void OnMExit()
{
if (_highlight != null)
_highlight.SetHighlighted(false);
base.OnMExit();
}
protected override void OnAwake()
{
base.OnAwake();
}
}