This commit is contained in:
parent
3981b4930c
commit
754c0c46e6
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -2,6 +2,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UIElements;
|
||||
/// <summary>
|
||||
/// 当前选择的区域
|
||||
|
@ -22,7 +23,8 @@ public enum Typeoffurniture
|
|||
灯,//灯
|
||||
窗帘,//窗帘
|
||||
空调,//空调
|
||||
窗户//窗户
|
||||
窗户,//窗户
|
||||
电视//电视
|
||||
}
|
||||
/// <summary>
|
||||
/// 点击后显示对应的UI
|
||||
|
@ -54,6 +56,10 @@ public class ClickModelType : MonoBehaviour
|
|||
/// </summary>
|
||||
public GameObject AirPanel;
|
||||
/// <summary>
|
||||
/// 电视控制面板
|
||||
/// </summary>
|
||||
public GameObject TvPanel;
|
||||
/// <summary>
|
||||
/// 当前区域类型
|
||||
/// </summary>
|
||||
public Transform regionType;
|
||||
|
@ -82,13 +88,18 @@ public class ClickModelType : MonoBehaviour
|
|||
}
|
||||
public void OnMouseDown()
|
||||
{
|
||||
if (EventSystem.current.IsPointerOverGameObject())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (SelectModel.Instance.region == region && typeoffurniture == Typeoffurniture.灯)
|
||||
{
|
||||
Control_Light.Instance.LightsModel = new List<Transform>();
|
||||
windowPanel.SetActive(false);
|
||||
curtainPanel.SetActive(false);
|
||||
LightPanel.SetActive(true);
|
||||
AirPanel.SetActive(false);
|
||||
TvPanel.SetActive(false);
|
||||
Control_Light.Instance.LightsModel = new List<Transform>();
|
||||
List<ClickModelType> clickModelTypes = FindObjectsOfType<ClickModelType>().ToList();
|
||||
for (int i = 0; i < clickModelTypes.Count; i++)
|
||||
{
|
||||
|
@ -98,29 +109,41 @@ public class ClickModelType : MonoBehaviour
|
|||
}
|
||||
}
|
||||
}
|
||||
if (SelectModel.Instance.region == region && typeoffurniture == Typeoffurniture.窗帘)
|
||||
else if (SelectModel.Instance.region == region && typeoffurniture == Typeoffurniture.窗帘)
|
||||
{
|
||||
windowPanel.SetActive(false);
|
||||
curtainPanel.SetActive(true);
|
||||
LightPanel.SetActive(false);
|
||||
AirPanel.SetActive(false);
|
||||
TvPanel.SetActive(false);
|
||||
Control_Curtain.Instance.curtain = transform;
|
||||
}
|
||||
if (SelectModel.Instance.region == region && typeoffurniture == Typeoffurniture.窗户)
|
||||
else if (SelectModel.Instance.region == region && typeoffurniture == Typeoffurniture.窗户)
|
||||
{
|
||||
Control_Windows.Instance.window = transform;
|
||||
windowPanel.SetActive(true);
|
||||
curtainPanel.SetActive(false);
|
||||
LightPanel.SetActive(false);
|
||||
AirPanel.SetActive(false);
|
||||
Control_Windows.Instance.window = transform;
|
||||
TvPanel.SetActive(false);
|
||||
}
|
||||
if (SelectModel.Instance.region == region && typeoffurniture == Typeoffurniture.空调)
|
||||
else if (SelectModel.Instance.region == region && typeoffurniture == Typeoffurniture.空调)
|
||||
{
|
||||
windowPanel.SetActive(false);
|
||||
curtainPanel.SetActive(false);
|
||||
LightPanel.SetActive(false);
|
||||
AirPanel.SetActive(true);
|
||||
TvPanel.SetActive(false);
|
||||
Control_Air.Instance.airobject = transform;
|
||||
}
|
||||
else if (SelectModel.Instance.region == region && typeoffurniture == Typeoffurniture.电视)
|
||||
{
|
||||
windowPanel.SetActive(false);
|
||||
curtainPanel.SetActive(false);
|
||||
LightPanel.SetActive(false);
|
||||
AirPanel.SetActive(false);
|
||||
TvPanel.SetActive(true);
|
||||
Control_Tv.Instance.Tv = transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ public class Control_Air : MonoBehaviour
|
|||
/// <summary>
|
||||
/// 制冷按钮
|
||||
/// </summary>
|
||||
public Button Cool;
|
||||
public Toggle Cool;
|
||||
/// <summary>
|
||||
/// 制热按钮
|
||||
/// </summary>
|
||||
public Button Warm;
|
||||
public Toggle Warm;
|
||||
/// <summary>
|
||||
/// 温度+
|
||||
/// </summary>
|
||||
|
@ -42,12 +42,34 @@ public class Control_Air : MonoBehaviour
|
|||
/// <summary>
|
||||
/// 是否开启空调
|
||||
/// </summary>
|
||||
bool isOpen;
|
||||
bool isOpen = false;
|
||||
/// <summary>
|
||||
/// 点击的空调
|
||||
/// </summary>
|
||||
public Transform airobject;
|
||||
/// <summary>
|
||||
/// 空调的温度
|
||||
/// </summary>
|
||||
public TextMeshProUGUI airnumber;
|
||||
/// <summary>
|
||||
/// 空调模式
|
||||
/// </summary>
|
||||
public Toggle airwarmModel;
|
||||
/// <summary>
|
||||
/// 空调模式
|
||||
/// </summary>
|
||||
public Toggle airwcoolModel;
|
||||
/// <summary>
|
||||
/// 所有风速图片
|
||||
/// </summary>
|
||||
public List<Sprite> flyspeeds = new List<Sprite>();
|
||||
/// <summary>
|
||||
/// UI风速图片
|
||||
/// </summary>
|
||||
public Image flyspeed;
|
||||
|
||||
|
||||
int indextflyspeed;
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
|
@ -56,17 +78,18 @@ public class Control_Air : MonoBehaviour
|
|||
{
|
||||
Open.onClick.AddListener(() =>
|
||||
{
|
||||
Cool.isOn = true;
|
||||
isOpen = !isOpen;
|
||||
OpenAir(isOpen);
|
||||
});
|
||||
Cool.onClick.AddListener(() =>
|
||||
{
|
||||
OpenAir(true);
|
||||
});
|
||||
Warm.onClick.AddListener(() =>
|
||||
{
|
||||
SetWarm();
|
||||
});
|
||||
//Cool.onValueChanged.AddListener((a) =>
|
||||
//{
|
||||
// OpenAir(true);
|
||||
//});
|
||||
//Warm.onValueChanged.AddListener((a) =>
|
||||
//{
|
||||
// SetWarm();
|
||||
//});
|
||||
TempAdd.onClick.AddListener(() =>
|
||||
{
|
||||
AddTemp();
|
||||
|
@ -84,41 +107,91 @@ public class Control_Air : MonoBehaviour
|
|||
SubWind();
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 打开空调 默认为制冷
|
||||
/// </summary>
|
||||
private void OpenAir(bool isopen)
|
||||
private void Update()
|
||||
{
|
||||
if (isopen)
|
||||
if (!isOpen)
|
||||
{
|
||||
Canvas chirendcanvas = airobject.GetComponentInChildren<Canvas>();
|
||||
Open.GetComponentInChildren<TextMeshProUGUI>().text = "关闭空调";
|
||||
chirendcanvas.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
|
||||
List<TextMeshProUGUI> chirendmessage = chirendcanvas.GetComponentsInChildren<TextMeshProUGUI>().ToList();
|
||||
airobject.GetChild(0).GetComponentInChildren<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
||||
chirendmessage[0].text = "16";//温度
|
||||
chirendmessage[2].text = ">";//风速
|
||||
chirendmessage[3].text = "制冷";//温度
|
||||
SetButtonClick(isOpen);
|
||||
}
|
||||
else
|
||||
{
|
||||
Canvas chirendcanvas = airobject.GetComponentInChildren<Canvas>();
|
||||
Open.GetComponentInChildren<TextMeshProUGUI>().text = "打开空调";
|
||||
chirendcanvas.transform.localScale = new Vector3(0, 0, 0);
|
||||
airobject.GetChild(0).GetComponentInChildren<MeshRenderer>().material.DisableKeyword("_EMISSION");
|
||||
SetButtonClick(isOpen);
|
||||
}
|
||||
}
|
||||
public void AudiosTalk(string Talk)
|
||||
{
|
||||
if (Talk.Contains("打开空调"))
|
||||
{
|
||||
isOpen = true;
|
||||
OpenAir(isOpen);
|
||||
}
|
||||
else if (Talk.Contains("空调制冷"))
|
||||
{
|
||||
airwcoolModel.isOn = true;
|
||||
OpenAir(true);
|
||||
}
|
||||
else if (Talk.Contains("空调制暖"))
|
||||
{
|
||||
airwarmModel.isOn = true;
|
||||
SetWarm();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置按钮是否可点
|
||||
/// </summary>
|
||||
void SetButtonClick(bool isclick)
|
||||
{
|
||||
Warm.interactable = isclick;
|
||||
Cool.interactable = isclick;
|
||||
TempAdd.interactable = isclick;
|
||||
TempSub.interactable = isclick;
|
||||
WindAdd.interactable = isclick;
|
||||
WindSub.interactable = isclick;
|
||||
}
|
||||
/// <summary>
|
||||
/// 打开空调 默认为制冷
|
||||
/// </summary>
|
||||
public void OpenAir(bool isopen)
|
||||
{
|
||||
if (airobject != null)
|
||||
{
|
||||
Canvas chirendcanvas = airobject.GetComponentInChildren<Canvas>();
|
||||
if (isopen)
|
||||
{
|
||||
//Open.GetComponentInChildren<TextMeshProUGUI>().text = "关闭空调";
|
||||
chirendcanvas.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
|
||||
List<TextMeshProUGUI> chirendmessage = chirendcanvas.GetComponentsInChildren<TextMeshProUGUI>().ToList();
|
||||
airobject.GetChild(0).GetComponentInChildren<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
||||
chirendmessage[0].text = "16";//温度
|
||||
//chirendmessage[2].text = ">";//风速
|
||||
chirendmessage[2].text = "制冷";//温度
|
||||
airnumber.text = "16";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//Open.GetComponentInChildren<TextMeshProUGUI>().text = "打开空调";
|
||||
chirendcanvas.transform.localScale = new Vector3(0, 0, 0);
|
||||
airobject.GetChild(0).GetComponentInChildren<MeshRenderer>().material.DisableKeyword("_EMISSION");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置制暖
|
||||
/// </summary>
|
||||
private void SetWarm()
|
||||
public void SetWarm()
|
||||
{
|
||||
Canvas chirendcanvas = airobject.GetComponentInChildren<Canvas>();
|
||||
List<TextMeshProUGUI> chirendmessage = chirendcanvas.GetComponentsInChildren<TextMeshProUGUI>().ToList();
|
||||
airobject.GetChild(0).GetComponentInChildren<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
||||
chirendmessage[0].text = "26";
|
||||
chirendmessage[2].text = ">";//风速
|
||||
chirendmessage[3].text = "制热";//模式
|
||||
if (airobject != null)
|
||||
{
|
||||
Canvas chirendcanvas = airobject.GetComponentInChildren<Canvas>();
|
||||
List<TextMeshProUGUI> chirendmessage = chirendcanvas.GetComponentsInChildren<TextMeshProUGUI>().ToList();
|
||||
airobject.GetChild(0).GetComponentInChildren<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
||||
chirendmessage[0].text = "26";
|
||||
airnumber.text = "26";
|
||||
//chirendmessage[2].text = ">";//风速
|
||||
chirendmessage[2].text = "制热";//模式
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 温度+
|
||||
|
@ -131,6 +204,7 @@ public class Control_Air : MonoBehaviour
|
|||
{
|
||||
chirendmessage[0].text = (int.Parse(chirendmessage[0].text) + 1).ToString();
|
||||
}
|
||||
airnumber.text = chirendmessage[0].text;
|
||||
}
|
||||
/// <summary>
|
||||
/// 温度-
|
||||
|
@ -143,6 +217,7 @@ public class Control_Air : MonoBehaviour
|
|||
{
|
||||
chirendmessage[0].text = (int.Parse(chirendmessage[0].text) - 1).ToString();
|
||||
}
|
||||
airnumber.text = chirendmessage[0].text;
|
||||
}
|
||||
/// <summary>
|
||||
/// 风速+
|
||||
|
@ -150,11 +225,19 @@ public class Control_Air : MonoBehaviour
|
|||
private void AddWind()
|
||||
{
|
||||
Canvas chirendcanvas = airobject.GetComponentInChildren<Canvas>();
|
||||
List<TextMeshProUGUI> chirendmessage = chirendcanvas.GetComponentsInChildren<TextMeshProUGUI>().ToList();
|
||||
if (chirendmessage[2].text.Length < 3)
|
||||
Image chirendmessage = chirendcanvas.GetComponentInChildren<Image>();
|
||||
|
||||
if (indextflyspeed < 2)
|
||||
{
|
||||
chirendmessage[2].text += ">";
|
||||
indextflyspeed++;
|
||||
flyspeed.sprite = flyspeeds[indextflyspeed];
|
||||
chirendmessage.sprite = flyspeeds[indextflyspeed];
|
||||
}
|
||||
//List<TextMeshProUGUI> chirendmessage = chirendcanvas.GetComponentsInChildren<TextMeshProUGUI>().ToList();
|
||||
//if (chirendmessage[2].text.Length < 3)
|
||||
//{
|
||||
// chirendmessage[2].text += ">";
|
||||
//}
|
||||
}
|
||||
/// <summary>
|
||||
/// 风速-
|
||||
|
@ -162,10 +245,16 @@ public class Control_Air : MonoBehaviour
|
|||
private void SubWind()
|
||||
{
|
||||
Canvas chirendcanvas = airobject.GetComponentInChildren<Canvas>();
|
||||
List<TextMeshProUGUI> chirendmessage = chirendcanvas.GetComponentsInChildren<TextMeshProUGUI>().ToList();
|
||||
if (chirendmessage[2].text.Length > 1)
|
||||
Image chirendmessage = chirendcanvas.GetComponentInChildren<Image>();
|
||||
//if (chirendmessage[2].text.Length > 1)
|
||||
//{
|
||||
// chirendmessage[2].text = chirendmessage[2].text.Substring(0, chirendmessage[2].text.Length - 1);
|
||||
//}
|
||||
if (indextflyspeed > 0)
|
||||
{
|
||||
chirendmessage[2].text = chirendmessage[2].text.Substring(0, chirendmessage[2].text.Length - 1);
|
||||
indextflyspeed--;
|
||||
flyspeed.sprite = flyspeeds[indextflyspeed];
|
||||
chirendmessage.sprite = flyspeeds[indextflyspeed];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,25 +31,34 @@ public class Control_Curtain : MonoBehaviour
|
|||
// Opencurtains();
|
||||
//});
|
||||
}
|
||||
public void Opencurtains()
|
||||
private void Update()
|
||||
{
|
||||
Opencurtain();
|
||||
//如果没在播放动画 则可以继续点击按钮
|
||||
if (curtain != null && !curtain.GetComponent<Animation>().isPlaying)
|
||||
{
|
||||
Open.interactable = true;
|
||||
Close.interactable = true;
|
||||
}
|
||||
}
|
||||
public void Opencurtains(bool isopen)
|
||||
{
|
||||
Open.interactable = false;
|
||||
Close.interactable = false;
|
||||
Opencurtain(isopen);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开关窗帘
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
void Opencurtain()
|
||||
void Opencurtain(bool isopen)
|
||||
{
|
||||
if (curtain.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 0)
|
||||
if (curtain.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 0&& !isopen)
|
||||
{
|
||||
Open.isOn = false;
|
||||
curtain.GetComponent<Animation>().Play("窗帘开");
|
||||
}
|
||||
else if (curtain.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 100)
|
||||
else if (curtain.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 100&& isopen)
|
||||
{
|
||||
Open.isOn = true;
|
||||
curtain.GetComponent<Animation>().Play("窗帘关");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,25 @@ public class Control_Light : MonoBehaviour
|
|||
// AudiosContorl(listenFeild.text);
|
||||
//});
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Is_Open)
|
||||
{
|
||||
IsClick(Is_Open);
|
||||
}
|
||||
else
|
||||
{
|
||||
IsClick(Is_Open);
|
||||
}
|
||||
}
|
||||
void IsClick(bool isclick)
|
||||
{
|
||||
Incandescent.interactable = isclick;
|
||||
cool.interactable = isclick;
|
||||
warm.interactable = isclick;
|
||||
Lightbrightness.interactable = isclick;
|
||||
}
|
||||
/// <summary>
|
||||
/// 语音控制
|
||||
/// </summary>
|
||||
|
@ -83,10 +102,14 @@ public class Control_Light : MonoBehaviour
|
|||
{
|
||||
if (str.Contains("开灯"))
|
||||
{
|
||||
Is_Open = true;
|
||||
IsClick(Is_Open);
|
||||
OpenorCloseLight(true);
|
||||
}
|
||||
else if (str.Contains("关灯"))
|
||||
{
|
||||
Is_Open = false;
|
||||
IsClick(Is_Open);
|
||||
OpenorCloseLight(false);
|
||||
}
|
||||
else if (str.Contains("暖光"))
|
||||
|
|
|
@ -31,21 +31,30 @@ public class Control_Windows : MonoBehaviour
|
|||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (window != null )
|
||||
{
|
||||
if (window.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 0 || window.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 100)
|
||||
{
|
||||
open.interactable = true;
|
||||
close.interactable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Openwindows()
|
||||
public void Openwindows(bool isopen)
|
||||
{
|
||||
StartCoroutine(Openwindow());
|
||||
open.interactable = false;
|
||||
close.interactable = false;
|
||||
StartCoroutine(Openwindow(isopen));
|
||||
}
|
||||
/// <summary>
|
||||
/// ¿ª¹Ø´°»§
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerator Openwindow()
|
||||
IEnumerator Openwindow(bool isopen)
|
||||
{
|
||||
if (window.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 0)
|
||||
|
||||
if (window.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 0 && isopen)
|
||||
{
|
||||
close.isOn = false;
|
||||
//openwindows.GetComponentInChildren<TextMeshProUGUI>().text = "¹Ø´°";
|
||||
for (int i = 1; i < 101; i++)
|
||||
{
|
||||
|
@ -53,9 +62,8 @@ public class Control_Windows : MonoBehaviour
|
|||
yield return new WaitForSeconds(0.025f);
|
||||
}
|
||||
}
|
||||
else if (window.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 100)
|
||||
else if (window.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 100 && !isopen)
|
||||
{
|
||||
open.isOn = false;
|
||||
//openwindows.GetComponentInChildren<TextMeshProUGUI>().text = "¿ª´°";
|
||||
for (int i = 100; i >= 0; i--)
|
||||
{
|
||||
|
|
|
@ -63,6 +63,7 @@ public class SpeechToText : MonoBehaviour
|
|||
Debug.Log($"讯飞语音转文本成功!文本为:{text}");
|
||||
//GetSpeechText = text;
|
||||
Control_Light.Instance.AudiosContorl(text);
|
||||
Control_Air.Instance.AudiosTalk(text);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue