2.18
This commit is contained in:
parent
4e6dfd8be1
commit
56ea9b8674
File diff suppressed because it is too large
Load Diff
|
@ -2,6 +2,9 @@ using System.Collections;
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Playables;
|
||||
using HighlightPlus;
|
||||
using System.Collections.Generic;
|
||||
using static UnityEditor.PlayerSettings;
|
||||
|
||||
/// <summary>
|
||||
/// 开始选择界面
|
||||
|
@ -27,7 +30,9 @@ public enum KangYangDevice
|
|||
}
|
||||
public class ClickKangYangdevice : MonoBehaviour
|
||||
{
|
||||
public Transform PlayerTrans;//玩家
|
||||
public static ClickKangYangdevice Instance;
|
||||
public HighlightEffect StartBtn_highlight;
|
||||
public KangYangDevice kangYangDevice = KangYangDevice.None;
|
||||
public SkinnedMeshRenderer XueYaYiSMR;//血压计动画
|
||||
public GameObject XYPXObj;//血压计屏幕显示
|
||||
|
@ -35,15 +40,26 @@ public class ClickKangYangdevice : MonoBehaviour
|
|||
public Animator OldManAni;//NPC动画
|
||||
public PlayableDirector playableDirector;//timeline动画
|
||||
public Button EmergencyCallBtn;//右下角紧急呼叫按钮
|
||||
|
||||
public GameObject oldman;//紧急呼叫演练
|
||||
public Image treadmillIamge;//跑步机
|
||||
public Button BraceletIamge;//手环
|
||||
|
||||
public Button lightBtn;//灯光按钮
|
||||
public Button Open;// 开灯/关灯
|
||||
private bool Is_Open = true;// 开灯还是关灯 默认为开灯
|
||||
private float lightsildervalue;//灯光强度滑动条
|
||||
|
||||
public Slider Lightbrightness;//控制灯光强度、亮度
|
||||
private Color InitColor = new Color(1, 1, 1);// 初始发散颜色
|
||||
public Toggle cool;
|
||||
public Toggle warm;
|
||||
public Toggle Incandescent;
|
||||
public Button YWGLBtn;//药物管理按钮
|
||||
public Button JKJCBtn;//健康检测按钮
|
||||
public Button MNJKGLBtn;//模拟健康管理
|
||||
public List<Transform> Point;//场景中的点位
|
||||
|
||||
|
||||
public List<Transform> LightsModel = new List<Transform>();//所有灯模型
|
||||
public GameObject treadmillmaterial;
|
||||
private void Awake()
|
||||
{
|
||||
|
@ -61,6 +77,31 @@ public class ClickKangYangdevice : MonoBehaviour
|
|||
playableDirector.Pause();
|
||||
YWGLBtn.gameObject.SetActive(false);
|
||||
JKJCBtn.gameObject.SetActive(false);
|
||||
Open.onClick.AddListener(() =>
|
||||
{
|
||||
Is_Open = !Is_Open;
|
||||
OpenorCloseLight(Is_Open);
|
||||
});
|
||||
lightsildervalue = Lightbrightness.value;
|
||||
Lightbrightness.onValueChanged.AddListener((value) =>
|
||||
{
|
||||
for (int i = 0; i < LightsModel.Count; i++)
|
||||
{
|
||||
if (lightsildervalue > value)
|
||||
{
|
||||
Debug.Log("----");
|
||||
SetEmissionIntensity(LightsModel[i].GetComponent<MeshRenderer>(), value);
|
||||
LightsModel[i].GetChild(0).GetComponent<Light>().intensity = value;
|
||||
}
|
||||
else if (lightsildervalue < value)
|
||||
{
|
||||
Debug.Log("+++++++++");
|
||||
SetEmissionIntensity(LightsModel[i].GetComponent<MeshRenderer>(), value);
|
||||
LightsModel[i].GetChild(0).GetComponent<Light>().intensity = value;
|
||||
}
|
||||
}
|
||||
lightsildervalue = Lightbrightness.value;
|
||||
});
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
|
@ -82,16 +123,22 @@ public class ClickKangYangdevice : MonoBehaviour
|
|||
switch (KangYangMangner.Instance.kangYangregion)
|
||||
{
|
||||
case kangYangRegion.健康管理与检测:
|
||||
|
||||
if (hit.collider.gameObject.name == "血压计")
|
||||
{
|
||||
|
||||
StartCoroutine(Sphygmomanometer());
|
||||
float weigh = XueYaYiSMR.GetBlendShapeWeight(100);
|
||||
if (weigh == 100)
|
||||
XueYaYiSMR.GetComponent<BoxCollider>().enabled = false;
|
||||
|
||||
|
||||
}
|
||||
float weigh = XueYaYiSMR.GetBlendShapeWeight(0);
|
||||
if (weigh == 100)
|
||||
{
|
||||
if (hit.collider.gameObject.name == "血压仪开始/停止按钮")
|
||||
{
|
||||
if (hit.collider.gameObject.name == "血压仪开始/停止按钮")
|
||||
{
|
||||
XYPXObj.gameObject.SetActive(true);
|
||||
}
|
||||
StartBtn_highlight.highlighted = false;//血压计开关按钮
|
||||
XYPXObj.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -109,14 +156,48 @@ public class ClickKangYangdevice : MonoBehaviour
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 药物检测
|
||||
/// </summary>
|
||||
public void YWJC()
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 开灯或关灯
|
||||
/// </summary>
|
||||
private void OpenorCloseLight(bool IsOpen)
|
||||
{
|
||||
if (IsOpen)
|
||||
{
|
||||
//Open.transform.GetComponentInChildren<TextMeshProUGUI>().text = "关";
|
||||
for (int i = 0; i < LightsModel.Count; i++)
|
||||
{
|
||||
Material material = LightsModel[i].GetComponent<MeshRenderer>().materials[0];
|
||||
material.EnableKeyword("_EMISSION");
|
||||
//material.SetColor("_EmissionColor", Color.HSVToRGB(0, 0, 1));
|
||||
LightsModel[i].GetChild(0).gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Open.transform.GetComponentInChildren<TextMeshProUGUI>().text = "开";
|
||||
for (int i = 0; i < LightsModel.Count; i++)
|
||||
{
|
||||
Material material = LightsModel[i].GetComponent<MeshRenderer>().materials[0];
|
||||
material.DisableKeyword("_EMISSION");
|
||||
//material.SetColor("_EmissionColor", Color.HSVToRGB(5, 5, 1));
|
||||
LightsModel[i].GetChild(0).gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据强度调整发光
|
||||
/// </summary>
|
||||
/// <param name="rend"></param>
|
||||
/// <param name="intensity"></param>
|
||||
void SetEmissionIntensity(Renderer rend, float intensity)
|
||||
{
|
||||
// 更新材质的发光颜色
|
||||
rend.material.SetColor("_EmissionColor", new Color(InitColor.r * intensity, InitColor.g * intensity, InitColor.b * intensity));
|
||||
Debug.Log(rend.material.GetColor("_EmissionColor"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 血压仪动画
|
||||
/// </summary>
|
||||
|
@ -124,11 +205,18 @@ public class ClickKangYangdevice : MonoBehaviour
|
|||
IEnumerator Sphygmomanometer()
|
||||
{
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
for (int i = 0; i < 100; i++)
|
||||
for (int i = 0; i <=100; i++)
|
||||
{
|
||||
yield return new WaitForSeconds(0.01f);
|
||||
XueYaYiSMR.SetBlendShapeWeight(0, i);
|
||||
}
|
||||
float weigh = XueYaYiSMR.GetBlendShapeWeight(0);
|
||||
//if (weigh > 0 )
|
||||
//{
|
||||
// XueYaYiSMR.GetComponent<BoxCollider>().enabled = false;
|
||||
//}
|
||||
yield return new WaitForSeconds(1f);
|
||||
StartBtn_highlight.highlighted = true;//血压计开关按钮
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -164,31 +252,100 @@ public class ClickKangYangdevice : MonoBehaviour
|
|||
treadmillmaterial.GetComponent<MeshRenderer>().materials[0].DisableKeyword("_EMISSION");
|
||||
}
|
||||
|
||||
//public void OnMouseDown()
|
||||
//{
|
||||
// if (EventSystem.current.IsPointerOverGameObject())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// if (/*KangYangMangner.Instance.kangYangregion == kangYangRegion.血压测量启动 &&*/ kangYangDevice == KangYangDevice.血压计)
|
||||
// {
|
||||
// if (show == false)
|
||||
// return;
|
||||
// if (weight < 100f)
|
||||
// {
|
||||
// weight += 1.8f;
|
||||
// XueYaYiSMR.SetBlendShapeWeight(0, weight);
|
||||
// Debug.Log(show);
|
||||
// }
|
||||
// }
|
||||
// else if (KangYangMangner.Instance.kangYangregion == kangYangRegion.健康数据查看 && kangYangDevice == KangYangDevice.手环)
|
||||
// {
|
||||
|
||||
// }
|
||||
// else if (KangYangMangner.Instance.kangYangregion == kangYangRegion.健康数据查看 && kangYangDevice == KangYangDevice.跑步机)
|
||||
// {
|
||||
|
||||
// }
|
||||
//}
|
||||
/// <summary>
|
||||
/// 语音控制
|
||||
/// </summary>
|
||||
public void AudiosContorl(string str)
|
||||
{
|
||||
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("暖光"))
|
||||
{
|
||||
warm.isOn = true;
|
||||
Warmlight();
|
||||
}
|
||||
else if (str.Contains("冷光"))
|
||||
{
|
||||
cool.isOn = true;
|
||||
Coollight();
|
||||
}
|
||||
else if (str.Contains("白光"))
|
||||
{
|
||||
Incandescent.isOn = true;
|
||||
Incandescentlight();
|
||||
}
|
||||
else if (str.Contains("灯光调暗"))
|
||||
{
|
||||
Lightbrightness.value = 1.5f;
|
||||
for (int i = 0; i < LightsModel.Count; i++)
|
||||
{
|
||||
Debug.Log("----");
|
||||
SetEmissionIntensity(LightsModel[i].GetComponent<MeshRenderer>(), 0);
|
||||
LightsModel[i].GetChild(0).GetComponent<Light>().intensity = 1;
|
||||
}
|
||||
}
|
||||
else if (str.Contains("灯光调亮"))
|
||||
{
|
||||
Lightbrightness.value = 2;
|
||||
for (int i = 0; i < LightsModel.Count; i++)
|
||||
{
|
||||
SetEmissionIntensity(LightsModel[i].GetComponent<MeshRenderer>(), 10);
|
||||
LightsModel[i].GetChild(0).GetComponent<Light>().intensity = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
void IsClick(bool isclick)
|
||||
{
|
||||
Incandescent.interactable = isclick;
|
||||
cool.interactable = isclick;
|
||||
warm.interactable = isclick;
|
||||
Lightbrightness.interactable = isclick;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 白炽光
|
||||
/// </summary>
|
||||
public void Incandescentlight()
|
||||
{
|
||||
InitColor = new Color(1, 1, 1);
|
||||
for (int i = 0; i < LightsModel.Count; i++)
|
||||
{
|
||||
LightsModel[i].GetChild(0).GetComponent<Light>().color = new Color(1, 1, 1);
|
||||
LightsModel[i].GetComponentInParent<MeshRenderer>().material.SetColor("_EmissionColor", new Color(1, 1, 1));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 冷灯光
|
||||
/// </summary>
|
||||
public void Coollight()
|
||||
{
|
||||
InitColor = new Color(0, 0.6145419f, 0.9433962f);
|
||||
for (int i = 0; i < LightsModel.Count; i++)
|
||||
{
|
||||
LightsModel[i].GetChild(0).GetComponent<Light>().color = new Color(0, 0.6145419f, 0.9433962f);
|
||||
LightsModel[i].GetComponentInParent<MeshRenderer>().material.SetColor("_EmissionColor", new Color(0, 0.6145419f, 0.9433962f));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 暖灯光
|
||||
/// </summary>
|
||||
public void Warmlight()
|
||||
{
|
||||
InitColor = new Color(1, 0.6831585f, 0);
|
||||
for (int i = 0; i < LightsModel.Count; i++)
|
||||
{
|
||||
LightsModel[i].GetChild(0).GetComponent<Light>().color = new Color(1, 0.6831585f, 0);
|
||||
LightsModel[i].GetComponentInParent<MeshRenderer>().material.SetColor("_EmissionColor", new Color(1, 0.6831585f, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,24 +23,30 @@ public class KangYangMangner : MonoBehaviour
|
|||
kangYangregion = kangYangRegion.健康管理与检测;
|
||||
ClickKangYangdevice.Instance.YWGLBtn.gameObject.SetActive(true);
|
||||
ClickKangYangdevice.Instance.JKJCBtn.gameObject.SetActive(true);
|
||||
ClickKangYangdevice.Instance.PlayerTrans.position = ClickKangYangdevice.Instance.Point[0].position;
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
RehabilitationAndAuxiliary.onClick.AddListener(() =>
|
||||
{
|
||||
kangYangregion = kangYangRegion.康复与辅助设备;
|
||||
ClickKangYangdevice.Instance.MNJKGLBtn.gameObject.SetActive(true);
|
||||
ClickKangYangdevice.Instance.PlayerTrans.position = ClickKangYangdevice.Instance.Point[1].position;
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
EnvironmentAndInteraction.onClick.AddListener(() =>
|
||||
{
|
||||
kangYangregion = kangYangRegion.环境与交互;
|
||||
gameObject.SetActive(false);
|
||||
ClickKangYangdevice.Instance.oldman.gameObject.SetActive(false);
|
||||
ClickKangYangdevice.Instance.lightBtn.gameObject.SetActive(true);
|
||||
ClickKangYangdevice.Instance.PlayerTrans.position = ClickKangYangdevice.Instance.Point[2].position;
|
||||
});
|
||||
EmergencyResponseAndSafety.onClick.AddListener(() =>
|
||||
{
|
||||
kangYangregion = kangYangRegion.紧急响应与安全;
|
||||
gameObject.SetActive(false);
|
||||
ClickKangYangdevice.Instance.EmergencyResponse();
|
||||
//ClickKangYangdevice.Instance.PlayerTrans.position = ClickKangYangdevice.Instance.Point[2].position;
|
||||
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue