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.
191 lines
5.3 KiB
191 lines
5.3 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using UnityEngine.UI;
|
||
|
using AX.TrackRecord;
|
||
|
|
||
|
public class TianQi : MonoBehaviour
|
||
|
{
|
||
|
public static TianQi Instance;
|
||
|
|
||
|
[HideInInspector]
|
||
|
public GameObject ShowTianQi_,QiWen,FengLi;//气象图集
|
||
|
public GameObject Snow, Rain;//预制体粒子效果
|
||
|
public Image TianQiSprite;//天气图集动态更换
|
||
|
[HideInInspector]
|
||
|
public InputField Input_WenDu,Input_FengLi,Input_FengXiang;//输入框
|
||
|
public Text WenDu_Text,FengXiang_Text,FengLi_Text,weather_text;//温度风向风力文字修改
|
||
|
[HideInInspector]
|
||
|
public string tq = "qing";
|
||
|
public Dropdown poplist;
|
||
|
public GameObject light_;
|
||
|
private GameObject camera_;
|
||
|
public Material BaiTian;
|
||
|
public Material YuYe;
|
||
|
private WeatherAttribute weatherAttri;
|
||
|
public WeatherAttribute WeatherAttribute
|
||
|
{
|
||
|
set
|
||
|
{
|
||
|
weatherAttri = new WeatherAttribute();
|
||
|
weatherAttri = value;
|
||
|
//TianQiSprite.sprite = weatherAttri.TheWeather;
|
||
|
WenDu_Text.text = weatherAttri.TheTemperature;
|
||
|
FengLi_Text.text = weatherAttri.TheWindPower;
|
||
|
FengXiang_Text.text = weatherAttri.TheWindDirection;
|
||
|
weather_text.text = weatherAttri.TheWeathertext;
|
||
|
SetWeather(weather_text.text);
|
||
|
}
|
||
|
get
|
||
|
{
|
||
|
weatherAttri = new WeatherAttribute();
|
||
|
//weatherAttri.TheWeather = TianQiSprite.spriteName;
|
||
|
weatherAttri.TheTemperature = WenDu_Text.text;
|
||
|
weatherAttri.TheWindPower = FengLi_Text.text;
|
||
|
weatherAttri.TheWindDirection = FengXiang_Text.text;
|
||
|
weatherAttri.TheWeathertext = weather_text.text;
|
||
|
return weatherAttri;
|
||
|
}
|
||
|
}
|
||
|
public void SetWeather(string weather)
|
||
|
{
|
||
|
switch (weather)
|
||
|
{
|
||
|
case "qing":
|
||
|
QingTian();
|
||
|
break;
|
||
|
case "xiaoyu":
|
||
|
XiaoYu();
|
||
|
break;
|
||
|
case "xiaoxue":
|
||
|
XiaoXue();
|
||
|
break;
|
||
|
case "Yin":
|
||
|
Yin();
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Awake()
|
||
|
{
|
||
|
if (Instance == null)
|
||
|
{
|
||
|
Instance = this;
|
||
|
}
|
||
|
}
|
||
|
//天气显示面板
|
||
|
public void ShowTianQi()
|
||
|
{
|
||
|
Debug.Log("ShowTianQi");
|
||
|
Allfalse();
|
||
|
ShowTianQi_.SetActive(true);
|
||
|
}
|
||
|
public void Allfalse (){
|
||
|
ShowTianQi_.SetActive(false);
|
||
|
QiWen.SetActive(false);
|
||
|
FengLi.SetActive(false);
|
||
|
}
|
||
|
public void CloseTianQi()
|
||
|
{
|
||
|
ShowTianQi_.SetActive(false);
|
||
|
}
|
||
|
//温度面板
|
||
|
public void ShowWenDu()
|
||
|
{
|
||
|
Allfalse();
|
||
|
QiWen.SetActive(true);
|
||
|
|
||
|
}
|
||
|
public void CloseWenDu()
|
||
|
{
|
||
|
QiWen.SetActive(false);
|
||
|
}
|
||
|
//温度
|
||
|
public void WenDuWin()
|
||
|
{
|
||
|
WenDu_Text.text = Input_WenDu.onValidateInput.ToString();
|
||
|
}
|
||
|
//风力
|
||
|
public void ShowFengLi()
|
||
|
{
|
||
|
Allfalse();
|
||
|
FengLi.SetActive(true);
|
||
|
}
|
||
|
public void CloseFengLi()
|
||
|
{
|
||
|
FengLi.SetActive(false);
|
||
|
}
|
||
|
public void ShowFengLiWin()
|
||
|
{
|
||
|
FengXiang_Text.text = poplist.value.ToString();
|
||
|
FengLi_Text.text = Input_FengLi.onValidateInput.ToString();
|
||
|
}
|
||
|
|
||
|
//晴
|
||
|
public void QingTian()
|
||
|
{
|
||
|
Snow.SetActive(false);
|
||
|
Rain.SetActive(false);
|
||
|
//TianQiSprite.spriteName = "晴";
|
||
|
camera_.GetComponent<Skybox>().material = BaiTian;
|
||
|
|
||
|
light_.GetComponent<Light>().color = new Color(1,0.943f,0.757f,1);
|
||
|
tq = "qing";
|
||
|
}
|
||
|
//雪
|
||
|
public void XiaoXue()
|
||
|
{
|
||
|
Snow.SetActive(true);
|
||
|
Rain.SetActive(false);
|
||
|
//TianQiSprite.spriteName = "小雪";
|
||
|
camera_.GetComponent<Skybox>().material =YuYe;
|
||
|
light_.GetComponent<Light>().color = new Color(0,0,0,1);
|
||
|
tq = "xiaoxue";
|
||
|
}
|
||
|
public void Yin()
|
||
|
{
|
||
|
Snow.SetActive(false);
|
||
|
Rain.SetActive(false);
|
||
|
camera_.GetComponent<Skybox>().material = YuYe;
|
||
|
light_.GetComponent<Light>().color = new Color(0, 0, 0, 1);
|
||
|
}
|
||
|
//小雨
|
||
|
public void XiaoYu()
|
||
|
{
|
||
|
Snow.SetActive(false);
|
||
|
Rain.SetActive(true);
|
||
|
camera_.GetComponent<Skybox>().material = YuYe;
|
||
|
light_.GetComponent<Light>().color = new Color(0, 0, 0, 1);
|
||
|
//TianQiSprite.spriteName = "小雨";
|
||
|
tq = "xiaoyu";
|
||
|
}
|
||
|
void Start ()
|
||
|
{
|
||
|
//Input_WenDu.value=WenDu_Text.text ;
|
||
|
//Input_FengLi.value = FengLi_Text.text;
|
||
|
//Input_FengXiang.value = FengXiang_Text.text;
|
||
|
Rain = GameObject.Find("RainSnow Prefab").transform.Find("Rain").gameObject;
|
||
|
Snow = GameObject.Find("RainSnow Prefab").transform.Find("Snow").gameObject;
|
||
|
camera_ = GameObject.Find("Main Camera");
|
||
|
//light = GameObject.Find("Directional light");
|
||
|
}
|
||
|
public void SetWeather(string weather,string tempreture, string fengLi, string fengXiang )
|
||
|
{
|
||
|
WenDu_Text.text = tempreture;
|
||
|
FengXiang_Text.text = fengXiang;
|
||
|
FengLi_Text.text = fengLi;
|
||
|
switch (weather)
|
||
|
{
|
||
|
case "qing":
|
||
|
QingTian();
|
||
|
break;
|
||
|
case "xiaoyu":
|
||
|
XiaoYu();
|
||
|
break;
|
||
|
case "xiaoxue":
|
||
|
XiaoXue();
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|