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.
175 lines
5.6 KiB
175 lines
5.6 KiB
4 years ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using AX.MessageSystem;
|
||
|
using AX.NetworkSystem;
|
||
|
|
||
|
public class WindTitle : MonoBehaviour {
|
||
|
public float AdjuctAng=0;
|
||
|
public Transform DirectinDropDown;
|
||
|
public Transform ForceDropDown;
|
||
|
public Transform WindZone;
|
||
|
private float rotation_Y;
|
||
|
private string windDirection;
|
||
|
private float windForce;
|
||
|
// Use this for initialization
|
||
|
void Awake () {
|
||
|
WindZone = GameObject.Find("WindZone").transform;
|
||
|
DirectinDropDown.GetComponent<DropDownRecordByAC>().OutInterFaceDropDown = DirectinDropDownValueChange;
|
||
|
ForceDropDown.GetComponent<DropDownRecordByAC>().OutInterFaceDropDown = ForceDropDownValueChange;
|
||
|
WindZone.transform.rotation = Quaternion.Euler(0,AdjuctAng,0);
|
||
|
|
||
|
MessageDispatcher.AddListener("LOAD_UIDISASTER", LoadUIDisaster);
|
||
|
}
|
||
|
|
||
|
private void OnDestroy()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("LOAD_UIDISASTER", LoadUIDisaster);
|
||
|
}
|
||
|
|
||
|
private void LoadUIDisaster(IMessage obj)
|
||
|
{
|
||
|
if (GameSettings.othersSettings.isSelectedDisaster)
|
||
|
{
|
||
|
DataBind();
|
||
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement)
|
||
|
{//若是练习或演习模式进入导调组界面,则不可以修改
|
||
|
DirectinDropDown.GetComponent<Dropdown>().interactable = false;
|
||
|
ForceDropDown.GetComponent<Dropdown>().interactable = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (!GameSettings.disasterSetting.isEdit)
|
||
|
{//若是灾情库设置模式的查看,则不可以修改
|
||
|
DirectinDropDown.GetComponent<Dropdown>().interactable = false;
|
||
|
ForceDropDown.GetComponent<Dropdown>().interactable = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//若是灾情库设置模式的编辑,则可以修改
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void DataBind()
|
||
|
{
|
||
|
// rotation_Y = ClampAngle(Mathf.Ceil(WindZone.rotation.eulerAngles.y));
|
||
|
// Debug.Log(WindZone.rotation.eulerAngles);
|
||
|
//int dir = (int)(rotation_Y / 45);
|
||
|
windDirection = WindDir(WindZone.rotation.eulerAngles.y);
|
||
|
|
||
|
var windDirOptions = DirectinDropDown.GetComponent<Dropdown>().options;
|
||
|
for (int i = 0; i < windDirOptions.Count; i++)
|
||
|
{
|
||
|
if (windDirOptions[i].text == windDirection)
|
||
|
{
|
||
|
DirectinDropDown.GetComponent<Dropdown>().value = i;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
windForce = WindZone.GetComponent<WindZone>().windMain;
|
||
|
var windFceOptions = ForceDropDown.GetComponent<Dropdown>().options;
|
||
|
for (int i = 0; i < windFceOptions.Count; i++)
|
||
|
{
|
||
|
if (windFceOptions[i].text == windForce.ToString() + "级")
|
||
|
{
|
||
|
ForceDropDown.GetComponent<Dropdown>().value = i;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private string WindDir(float dir)
|
||
|
{
|
||
|
string windDir = "";
|
||
|
if (Mathf.Abs(270 - dir)<1)
|
||
|
{
|
||
|
windDir = "东";
|
||
|
}
|
||
|
else if (Mathf.Abs(90 - dir)<1)
|
||
|
{
|
||
|
windDir = "西";
|
||
|
}
|
||
|
else if (Mathf.Abs(dir - 0)<1)
|
||
|
{
|
||
|
windDir = "南";
|
||
|
}
|
||
|
else if (Mathf.Abs (dir - 180)<1)
|
||
|
{
|
||
|
windDir = "北";
|
||
|
}
|
||
|
else if (Mathf.Abs(dir -315)<1)
|
||
|
{
|
||
|
windDir = "东南";
|
||
|
}
|
||
|
else if (Mathf.Abs(dir - 225)<1)
|
||
|
{
|
||
|
windDir = "东北";
|
||
|
}
|
||
|
else if (Mathf.Abs(dir - 45)<1)
|
||
|
{
|
||
|
windDir = "西南";
|
||
|
}
|
||
|
else if (Mathf.Abs(dir - 135)<1)
|
||
|
{
|
||
|
windDir = "西北";
|
||
|
}
|
||
|
|
||
|
return windDir;
|
||
|
}
|
||
|
|
||
|
private float ClampAngle(float angle)
|
||
|
{
|
||
|
if (angle < -180)
|
||
|
angle += 360;
|
||
|
if (angle > 180)
|
||
|
angle -= 360;
|
||
|
return angle;
|
||
|
}
|
||
|
|
||
|
private void DirectinDropDownValueChange(int value)
|
||
|
{
|
||
|
float argue = (float)value*45;
|
||
|
WindZone.transform.rotation = Quaternion.Euler(0, AdjuctAng+ argue, 0);
|
||
|
Debug.Log(WindZone.transform.rotation.eulerAngles);
|
||
|
MessageDispatcher.SendMessage("SET_SMOKE_DIRECTION");
|
||
|
|
||
|
//风力风向设置同步
|
||
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement)
|
||
|
{
|
||
|
WindZoneSyncData arg = new WindZoneSyncData();
|
||
|
arg.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
arg.gameObjID = WindZone.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
arg.Rotation = WindZone.transform.rotation;
|
||
|
arg.windMain = WindZone.GetComponent<WindZone>().windMain;
|
||
|
NetworkManager.Default.SendAsync("WIND_ZONE_SYNC", arg);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
private void ForceDropDownValueChange(int value)
|
||
|
{
|
||
|
WindZone.GetComponent<WindZone>().windMain = value;
|
||
|
MessageDispatcher.SendMessage("SET_SMOKE_DIRECTION");
|
||
|
//风力风向设置同步
|
||
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement)
|
||
|
{
|
||
|
WindZoneSyncData arg = new WindZoneSyncData();
|
||
|
arg.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
arg.gameObjID = WindZone.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
arg.Rotation = WindZone.transform.rotation;
|
||
|
arg.windMain = WindZone.GetComponent<WindZone>().windMain;
|
||
|
NetworkManager.Default.SendAsync("WIND_ZONE_SYNC", arg);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update () {
|
||
|
// WindZone.transform.rotation = Quaternion.Euler(0, AdjuctAng, 0);
|
||
|
}
|
||
|
}
|