天津23维预案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

140 lines
3.9 KiB

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using AX.MessageSystem;
using AX.TrackRecord;
using UnityEngine.SceneManagement;
public class FengXiangControl : MonoBehaviour {
private string FengXiangText;
private Dropdown FengXiangDropdown;
private Dropdown FengLiDropdown;
private Text ShowFengXiangText;
GameObject Wind;
int x, y, z;
float speed = 5f;
void Start ()
{
SetAttri();
}
public void SetAttri()
{
Wind = GameObject.Find("Wind");
FengXiangDropdown = this.gameObject.GetComponent<Dropdown>();
ShowFengXiangText = transform.parent.parent.transform.Find("ShowWeather/FengXiangText").GetComponent<Text>();
FengLiDropdown = transform.parent.transform.Find("FengLiDropdown").GetComponent<Dropdown>();
}
public void Check(int Num)
{
if (Num == 0 || Num == 2|| Num == 3 || Num == 5)
{
int Rote = 180;
switch (FengXiangText)
{
case "东风":
y = -90+ Rote;
break;
case "南风":
y = 0 + Rote;
break;
case "西风":
y = 90 + Rote;
break;
case "北风":
y = -180 + Rote;
break;
case "东北风":
y = -135 + Rote;
break;
case "西南风":
y = 45 + Rote;
break;
case "东南风":
y = -45 + Rote;
break;
case "西北风":
y = 135 + Rote;
break;
default:
break;
}
}
else
{
switch (FengXiangText)
{
case "东风":
y = -90;
break;
case "南风":
y = 0;
break;
case "西风":
y = 90;
break;
case "北风":
y = -180;
break;
case "东北风":
y = -135;
break;
case "西南风":
y = 45;
break;
case "东南风":
y = -45;
break;
case "西北风":
y = 135;
break;
default:
break;
}
}
}
public void OnValueChanged()
{
if (Wind == null || FengXiangDropdown==null || ShowFengXiangText==null || FengLiDropdown==null)
{
SetAttri();
}
FengXiangText = FengXiangDropdown.options[FengXiangDropdown.value].text.ToString();
if (FengXiangText == "无风")
{
FengLiDropdown.value = 0;
FengLiDropdown.interactable = false;
}
else
{
FengLiDropdown.interactable = true;
}
int SceneName =int.Parse( SceneManager.GetActiveScene().name);
Check(SceneName);
ShowFengXiangText.text = FengXiangText;
if (RecordManager.Instance.IsRecording)
{
MessageDispatcher.SendMessage("RecordEditWeatherEvent");
}
if (GameObject.Find("AllParent/pfire").transform.childCount>0)
{//预防场景里没火,修改天气,消息系统报错
MessageDispatcher.SendMessage("ChangeSomkeDir");
MessageDispatcher.SendMessage("ChangeWindLevel");
}
}
void Update ()
{
if (this.gameObject.activeInHierarchy == true)
{
Wind.transform.rotation = Quaternion.Lerp(Wind.transform.rotation, Quaternion.Euler(0, y, 0), Time.deltaTime * speed);
}
}
}