上节讲到警铃:
当走到12 继续往下走,走到洗手间:
走到洗手间,提示UI,第9个
显示第9 的panel,然后显示到第14步,水龙头位置:
等于14的时候,创建新方法:
靠近水龙头的时候,
1.打开panel,
开水龙,拿毛巾 当点击一个物体的时候,让它高亮,就哟啊修改材质吗,因为以后也会用到,就创建一个新的脚本,专门做哟啊点击的物体的高亮显示的管理器
控制高亮-》控制物体材质球,为了外面的好调用,把这个脚本写成一个单列,不需要挂在任何物体上,
当调用单列的时候,就是调用一个对象:
单列创建一个对象,不声明
一个构造函数里,一个属性,
1.创建一个打开高亮的方法
2.,创建一个关闭高亮的方法
控制物体是否高亮的:
是要让物体高亮,所以给他传一个gameobjet
//如果物体为空,不能设置高亮//一个物体可以有多个材质球,所以要找到所以的
拿到之后,foreach遍历
//要先勾上:
,打开后 可以写具体显示什么颜色 的高亮,设置成一个蓝色,
关闭高亮,关掉勾:
拿到水龙头开关:
拿到水龙头:
初始化水龙头开关:
拿到头显,拿到水的动画,水流特效,毛巾,手模型
因为毛巾放手上,和放下的时候 创建毛巾父物体;
毛巾的位置,没有 的时候,毛巾和水接触的颜色
总的部分
在start()里面初始化:
1水龙头
2.水龙头开关播放的动画,在水龙头身上tap
3.水流的特效:开始的时候水不流水 单独,先关闭。4.拿到毛巾和手:开始的时候毛巾的父物体,就是毛巾所在 的位置:
5.模型手 毛巾位置
6.手:
7.毛巾颜色:
靠近水龙头的时候,把9的panel关闭,再把10打开,显示高亮(水龙头的高亮)
把水龙头开关高亮,
在头上添加boxcollider 还有righbodry
,打开boxcollider:
点击到水龙头:
新方法,处理水龙头的点击事件:
把10UIpanel关闭:水龙头高亮关闭:
毛巾的boxcollider打开:
避免再次点击到水龙头,把碰重体关闭
水龙头旋转动画的播放,水的粒子效果播放:
提示拿毛巾,所以毛巾高亮打开:
下一步点击毛巾:
点击毛巾的一个新方法 :
毛巾被点击后,毛巾的高亮关闭:
毛巾的父物体,拿到手上
所以的获取右手炳
初始化:
把毛巾放手上
手模型显示“”
毛巾在手的位置:
把毛巾放水上。怎么检测毛巾与手发生碰撞,粒子也是有碰撞体
所以添加一个新的脚本,专门处理物体与粒子效果的碰撞,这个脚本挂在毛巾身上
拿到gamemain:
新方法,粒子击中 到时候就调用这个方法:碰到的是谁
如果碰撞水柱,并且是它是干毛巾:调用gamemain毛巾沾水的方法:
添加一个bool值的属性 存放当前毛巾是否已经沾水了
新方法:检测毛巾碰水的方法 毛巾
毛巾碰水了 等于true,
改变毛巾颜色
检测头和毛巾的碰撞
再写一个脚本,简单的碰撞,:这个脚本要挂在头上,只要获得父物体就可以了
,先拿到gamemain;
,检测碰撞的方法:
先把这个勾上
检测碰着的是不是毛巾:碰着的是毛巾,毛巾是沾水了的,才固定在头上
再添加一个新方法,毛巾固定到头上
,毛巾已经固定头上了
//就不用手了,
//毛巾的父物体就是头了,
//位置就在头上,
角度就为零:
到15步;
这个方法的总,
位置:
让父物体真的是父物体的值
方便测试开动的位置:10的位置
修改部分 手不见的i情况:
毛巾不能勾上触发
毛巾到头上的时候 水关了
显示这个
***********************************************下午******************
从洗手间出来
到16地标的时候 显示17的地标,和11个的UI界面显示
如果抬头 就提示不能抬起头:走到
永远低头,从现在开始:写在Update();所以添加一个开关,走到低头地方才低头走
如果为真,就把数组里的2打开,当y的值大于0就是真的
再把12打开,并且显示下一步:
21的地标是电梯口的地标:电梯打开的动画:
把22地标显示出来:
把12关闭
拿到电梯:
打开开电梯门动画的方法:
如果你点击了地标等于22,告诉他电梯里面不能走:显示14界面,走到18地标
位置:
结果:
到18步:
到19步:前边爆炸:
先找到爆炸的粒子效果:
找到粒子特效:
找到里面的爆炸
得到门的动画:
当iddnegyu19,播放动画
播放动画后,,延迟调用panel远离化学物品:又显示下一地标
远离方法:
去测试写 东西是不是正确 从10步开始走
电梯到化学室的效果演示
*************************************************
接下来是灭火器的时候了
到20地标了关掉13panel
24灭火器位置
到24地标,关闭15UI;
灭火器高亮,先去获得灭火器:
找到单独的灭火器:
实例化:
找到拉环
得到拉
Start()l里面灭火器总的:
左手
右手
干粉的粒子效果
火焰动画
灭火器的父物体,
灭火器的位置
灭火器 的旋转
灭火时候的动画(灭火器上下动)
动画长度
灭火器是否在手上
干面粉是否碰到火
灭火器高亮
点击灭火器
灭火器事件
先关闭手
取消高亮的灭火器:
把拉环隐藏:
灭火器boxclooer关闭
拉环的处理新方法:
显示UI方法
显示箭头:
用左手拉环,把左手改成红色:
右手碰撞体打开:
检测点击到右手:
手的点击:
关闭箭头,两只手的模型关闭:
把灭火器绑定在手柄上:
手的父物体为右手炳
位置
旋转角度(竖着)
显示灭火气:
灭火栓关闭:
按下touchpad键,就调用下边这个方
调用新方法,碰出来干粉
检测灭火器是不是在手上:错误不是 真 就碰干粉
检测纸箱,干粉有没有碰着纸箱 碰着挂粒子的脚本(物体有没有碰到粒子)
粒子特效脚本里,有没有碰到干粉并且是不是已经碰着火了
先去gameamin里添加一个bool值 ctrl+r+e 属性
碰着火以后的事情,方法:
调用
让火变得雨来越小
火被扑灭以后的方法:
已经碰着了 播放火焰的动画: 火焰越来越小
火被扑灭以后:灭火器放回去;
干粉粒子效果关闭
灭火器的父物体等于
灭火器位置为原来的位置:
显示下一步:
测试灭火的功能:
修改部分
烟灭成功
********************************************走到25地标了,到大楼梯门口的UI
点击16UI的okbutton
添加一个关闭OK 的方法
UImain里的方法不用了
喷干粉的脚本调用
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 public class GameMain : MonoBehaviour { 6 public UIMain m_UIMain; 7 public GameObject m_ClassRoom; 8 public GameObject m_PassageWay; 9 public Transform m_PositionMarket;//地标 10 private int m_nCurTransID; 11 private int m_nPosCount; 12 private float m_Height = 1.4f; 13 private Vector3 m_largeScale = new Vector3(0.8f, 0.8f, 0.8f); 14 private Vector3 m_normalScale = new Vector3(0.5f, 0.5f, 0.5f); 15 16 private GameObject m_classroomSmoke;//烟雾粒子特效 17 private GameObject m_waringPanel;//警告 18 private GameObject[] m_waringPanels;//所有警告Panel 19 private Material m_brake;//开关的材质球 20 private GameObject m_classroomLights; 21 private Light[] m_emergencylamp; 22 23 private GameObject m_watertap;//水龙头开关 24 private Transform m_head;//头显 25 private Animation m_waterTapAni;//水龙头打开 动画 26 private GameObject m_waterEffect;//水流特效 27 private Transform m_towel;//毛巾 28 private Transform m_towelParent;//毛巾父物体 29 private GameObject m_towelHand;//拿着毛巾的手 30 private Vector3 m_towelPos; 31 private Quaternion m_towelRot; 32 private Color m_towelInitColor;//毛巾颜色 33 34 private Transform m_rightHand; 35 private bool m_bTowelWet; 36 private bool m_bNeedBend; 37 38 private Animation m_elevator; 39 40 private GameObject m_boomEffect;//爆炸粒子效果 41 private Animation m_boomDoorBreak; 42 43 private Transform m_extinguisher;//灭火器 44 private Transform m_fireplug;//拉环 45 private Transform m_fireRightHand; 46 private Transform m_fireLeftHand; 47 private GameObject m_ganfenEffect; 48 private Animation m_fireAni; 49 private Transform m_extinguisherParent; 50 private Vector3 m_extinguisherPos; 51 private Quaternion m_extinguisherRot; 52 private Animation m_extinguisherAni; 53 private float m_fExAniLength; 54 private bool m_bUseExtinguisher; 55 private bool m_bTouchedFire; 56 57 58 59 private Vector3[] m_markPosition = new Vector3[] 60 { 61 new Vector3(-4.7f,2.02f,-60f),//0 楼道里 62 new Vector3(16.2f,0.01f,-3.5f),//1 教室门口 63 new Vector3(17.2f,0.01f,-2.5f),//2 64 new Vector3(18f,0.01f,-1.4f),//3 课桌前 65 new Vector3(19.4f,0.01f,-2.4f),// 4 66 new Vector3(21.9f,0.01f,-3.6f),//5 电闸位置 67 new Vector3(20f,0.01f,-2.4f),//6 68 new Vector3(17.5f,0.01f,-2.5f),// 7 69 new Vector3(16f,0.01f,-3.5f),//8 前门 70 new Vector3(15.5f,0.01f,0f),//9 前后门中间 71 new Vector3(16f,0.01f,3.9f),//10 后门位置 72 new Vector3(-3.8f,2.02f,-57.6f),//11 73 new Vector3(-4.7f,2.02f,-53f),//12 74 new Vector3(-4.7f,2.02f,-47.2f),//13 75 new Vector3(-6.9f,2.02f,-45.1f),//14 76 new Vector3(-4.8f,2.02f,-43f),//15 77 new Vector3(-4.8f,2.02f,-38f),//16 78 new Vector3(-4.8f,2.02f,-33f),//17 79 new Vector3(-4.8f,2.02f,-23f),//18 80 new Vector3(-4.8f,2.02f,-17.5f),//19 81 new Vector3(-4.8f,2.02f,-11.3f),//20 82 new Vector3(-5.3f, 2.02f, -29f), //21 电梯门口 83 new Vector3(-7.3f, 2.02f, -29f), //22 电梯内 84 new Vector3(-4.8f, 2.02f, -6.5f), //23 85 new Vector3(-4.8f, 2.02f, -0.1f), //24 灭火器处 86 new Vector3(-4.8f, 2.02f, 3.3f), //25 走廊尽头 87 new Vector3(-4.8f, 2.02f, 6.7f), //26 逃生通道 88 new Vector3(-9.9f, 0.4f, 6.8f), //27 89 new Vector3(-9.6f, 0.4f, 8.3f), //28 90 new Vector3(-4.4f, -1.2f, 7.9f), //29 91 }; 92 // Use this for initialization 93 void Start () { //加载 94 95 96 //爆炸 97 Transform allEffect = m_PassageWay.transform.Find("Effects"); 98 m_boomEffect = allEffect.Find("boom").gameObject; 99 m_boomEffect.SetActive(false);100 m_boomDoorBreak = m_PassageWay.transform.Find("Model/door break").GetComponent();101 102 m_elevator = m_PassageWay.transform.Find("Model/elevatorOpen").GetComponent ();103 104 m_rightHand = transform.Find("vr_controller_tank_0_8_MC_R");105 106 Transform tap = m_PassageWay.transform.Find("Model/ShuiLongTou");//水龙头107 m_watertap = tap.Find("GameObject/WaterTap").gameObject;//水龙头开关108 m_head = transform.Find("head");109 m_waterTapAni = tap.GetComponent ();110 m_waterEffect = m_PassageWay.transform.Find("Effects/water").gameObject;//水流特效111 m_waterEffect.SetActive(false);112 113 m_towel = m_PassageWay.transform.Find("Model/Towel");114 m_towelParent = m_towel.parent;115 m_towelPos = m_towel.localPosition;116 m_towelRot = m_towel.localRotation;117 m_towelHand = m_towel.Find("shou").gameObject;//手118 m_towelInitColor = m_towel.GetComponent ().material.color;119 120 121 m_classroomLights = m_ClassRoom.transform.Find("light").gameObject;122 m_emergencylamp = new Light[2];123 for (int i = 0; i < 2; i++)124 {125 m_emergencylamp[i] = m_classroomLights.transform.Find("DirectionalLight" + i).GetComponent ();126 }127 128 m_brake = m_ClassRoom.transform.Find("model/Brake").GetComponent ().material;129 130 m_waringPanel = transform.Find("head/Canvas").gameObject;131 m_waringPanels = new GameObject[3];132 //0 火灾突发 1 离开洗手间 2 弯腰提示133 for (int i = 0; i < m_waringPanels.Length; i++)134 {135 m_waringPanels[i] = m_waringPanel.transform.Find("Panel"+i).gameObject;136 m_waringPanels[i].SetActive(false);137 }138 m_classroomSmoke = m_ClassRoom.transform.Find("smoke").gameObject;139 m_nPosCount = m_markPosition.Length;140 141 //灭火器142 Transform mhq = m_PassageWay.transform.Find("Model/miehuoqi_dh_01");143 m_extinguisher = mhq.Find("loidao_dong_03");144 m_fireplug = m_extinguisher.Find("Dummy001/loidao_dong_02");145 m_fireplug.gameObject.SetActive(false);146 m_fireRightHand = mhq.Find("body002");//灭火器上方的手147 m_fireLeftHand = mhq.Find("body");//灭火器下方的手148 m_fireRightHand.gameObject.SetActive(false);149 m_fireLeftHand.gameObject.SetActive(false);150 m_ganfenEffect = m_extinguisher.Find("MieHuoQiSmoke").gameObject;//灭火器喷出的粒子效果151 m_fireAni = allEffect.Find("fire/Fire_v1 (4)").GetComponent ();//火焰动画152 m_ganfenEffect.SetActive(false);//灭火去特效关闭153 m_extinguisherParent = m_extinguisher.parent;154 m_extinguisherPos = m_extinguisher.localPosition;155 m_extinguisherRot = m_extinguisher.localRotation;156 157 m_extinguisherAni = mhq.GetComponent ();//灭火器动画158 m_fExAniLength = m_extinguisherAni.clip.length;//动画片段长度159 m_bUseExtinguisher = false;//设置灭火器是否在手上为false160 m_bTouchedFire = false;//粉末是否触碰到了火为false161 162 163 ShowEnterSystem();164 165 }166 167 public bool IsTouchedFire168 {169 get { return m_bTouchedFire; }170 set { m_bTouchedFire = value; }171 }172 public void ShowEnterSystem()//初始化数据173 {174 m_classroomSmoke.SetActive(false);175 m_towel.parent = m_towelParent;176 177 ShowWelcomeEnter();178 }179 void ShowWelcomeEnter()//显示欢迎界面180 {181 m_UIMain.ShowPanel(17, true);182 }183 // Update is called once per frame184 void Update () {185 if (m_bNeedBend)186 {187 m_waringPanels[2].SetActive((m_head.localPosition.y>0)?true:false);188 }189 }190 public void OnConfirmButtonClicked(string sName)191 {192 m_UIMain.UIConfirmBtnClick(sName);193 194 }195 public void OnChoseButtonClicked(string sName)196 {197 m_UIMain.UIChoseBtnClick(sName);198 }199 public void TransportToClassRoom()//传送到教室200 {201 m_ClassRoom.gameObject.SetActive(true);202 m_PassageWay.gameObject.SetActive(false);203 m_nCurTransID = 10;//!!!!!!!!!!!!!!!!!204 TransPort();205 }206 public void TransportToPassageWay()//传送到楼道207 {208 m_ClassRoom.gameObject.SetActive(false);209 m_PassageWay.gameObject.SetActive(true);210 m_nCurTransID = 11;211 TransPort();212 }213 public void TransPort()//传送214 {215 if (m_nCurTransID>=m_nPosCount)//ID越界216 {217 m_PositionMarket.gameObject.SetActive(false);218 return;219 }220 if (m_nCurTransID!=22)//不是电梯221 {222 Vector3 pos = new Vector3(m_markPosition[m_nCurTransID].x,m_markPosition[m_nCurTransID].y+m_Height,m_markPosition[m_nCurTransID].z);223 transform.position = pos;224 }225 m_PositionMarket.gameObject.SetActive(false);226 if (m_nCurTransID==1)//教室门口227 {228 ShowMark(2);229 }230 else if (m_nCurTransID==2)231 {232 ShowMark(3);233 }234 else if (m_nCurTransID==3)235 {236 Invoke("ShowFireWaring",3f);237 }238 else if (m_nCurTransID==4)239 {240 ShowMark(5);241 }242 else if (m_nCurTransID==5)243 {244 TrunOffBrake();245 }246 else if (m_nCurTransID==6)//拨打火警电话247 {248 m_UIMain.ShowPanel(1, true);249 }250 else if (m_nCurTransID==7)251 {252 ShowMark(8);253 }254 else if (m_nCurTransID==8)//测试前门温度255 {256 m_UIMain.TestDoorTemp();257 }258 else if(m_nCurTransID==9)259 {260 ShowMark(10);261 }262 else if (m_nCurTransID==10)//测试后门温度263 {264 m_UIMain.ShowTestBehindDoor();265 }266 else if (m_nCurTransID==11)//按响警铃267 {268 transform.localEulerAngles = new Vector3(0, 180, 0);269 m_UIMain.ShowPanel(8,true);270 }271 else if (m_nCurTransID==12)272 {273 ShowMark(13);274 }275 else if (m_nCurTransID==13)276 {277 m_UIMain.ShowPanel(9, true);278 ShowMark(14);279 }280 else if (m_nCurTransID==14)281 {282 NearWaterTap();283 }284 else if (m_nCurTransID==15)285 {286 ShowMark(16);287 m_head.GetComponent ().enabled = false;288 }289 else if (m_nCurTransID==16)290 {291 ShowMark(17);292 m_UIMain.ShowPanel(11, true);293 }294 else if (m_nCurTransID==17)295 {296 m_waringPanels[2].SetActive(true);297 m_bNeedBend = true;298 m_UIMain.ShowPanel(11, false);299 m_UIMain.ShowPanel(12, true);300 ShowMark(21);301 }302 else if (m_nCurTransID==21)//电梯门口303 {304 Invoke("OpenElevator",3f);305 ShowMark(22);306 m_UIMain.ShowPanel(12, false);307 }308 else if (m_nCurTransID==22)309 {310 m_UIMain.ShowPanel(14, true);311 ShowMark(18);312 }313 else if (m_nCurTransID==18)314 {315 ShowMark(19);316 }317 else if (m_nCurTransID==19)318 {319 m_boomEffect.SetActive(true);320 m_boomDoorBreak.Play();321 Invoke("LeaveExperimentUI",2f);322 ShowMark(20);323 }324 else if (m_nCurTransID==20)325 {326 ShowMark(23);327 m_UIMain.ShowPanel(13, false);328 m_UIMain.ShowPanel(14, false);329 }330 else if (m_nCurTransID==23)331 {332 m_UIMain.ShowPanel(15, true);333 ShowMark(24);334 }335 else if (m_nCurTransID==24)336 {337 m_UIMain.ShowPanel(15, false);338 HightlightManager.Instance.MaskEffectOn(m_extinguisher.gameObject);339 }340 else if (m_nCurTransID==25)341 {342 m_UIMain.ShowPanel(16, true);343 }344 else if (m_nCurTransID==26)345 {346 m_UIMain.ShowPanel(18, true);347 ShowMark(27);348 }349 else if (m_nCurTransID==27)350 {351 m_UIMain.ShowPanel(18, false);352 ShowMark(28);353 }354 else if (m_nCurTransID==28)355 {356 ShowMark(29);357 }358 else if (m_nCurTransID==29)359 {360 m_UIMain.ShowPanel(19, true);361 }362 363 }364 void LeaveExperimentUI()365 {366 m_UIMain.ShowPanel(13, true);367 }368 void OpenElevator()369 {370 m_elevator.Play();371 }372 public void ShowMark(int nindex)//显示地标位置373 {374 m_nCurTransID = nindex;375 if (m_nCurTransID>=m_nPosCount)376 {377 m_PositionMarket.gameObject.SetActive(false);378 return;379 }380 m_PositionMarket.position = m_markPosition[m_nCurTransID];381 m_PositionMarket.gameObject.SetActive(true);382 }383 public void HitPositionMarket(bool bhit)384 {385 if (!m_PositionMarket.gameObject.activeSelf)386 {387 return;388 }389 if (bhit)390 {391 m_PositionMarket.localScale = m_largeScale;392 }393 else394 {395 m_PositionMarket.localScale = m_normalScale;396 }397 }398 void ShowFireWaring()//火灾预警399 {400 m_classroomSmoke.SetActive(true);401 m_waringPanels[0].SetActive(true);402 Invoke("ShowTurnOffBrake",2f);403 }404 void ShowTurnOffBrake()//关闭电闸UI 显示下一个地标405 {406 m_UIMain.ShowPanel(0, true);407 ShowMark(4);408 }409 void TrunOffBrake()410 {411 m_UIMain.ShowPanel(0,false);412 m_brake.color = Color.red;413 m_UIMain.ShowBreakArrow(true);414 }415 public void OnBrakeClicked()//当电闸被关闭416 {417 m_UIMain.ShowBreakArrow(false);418 m_brake.color = Color.white;419 m_classroomLights.SetActive(false);//灯光关掉420 Invoke("EmergencyLamp",2f);421 }422 void EmergencyLamp()//应急灯423 {424 for (int i = 0; i < 2; i++)425 {426 m_emergencylamp[i].intensity = 0.4f;427 m_classroomLights.SetActive(true);428 ShowMark(6);429 }430 }431 public void OnTouchFrontDoor(bool bTouch)432 {433 m_UIMain.UITouchFrontDoor(bTouch);434 }435 public void OnTouchBehindDoor(bool bTouch)436 {437 m_UIMain.UITouchBehindDoor(bTouch);438 }439 public void OnAlarmBellClick()440 {441 m_UIMain.UIAlarmBellClicked();442 }443 void NearWaterTap()//靠近水龙头444 {445 m_UIMain.ShowPanel(9,false);446 m_UIMain.ShowPanel(10, true);447 m_head.GetComponent ().enabled = true;448 HightlightManager.Instance.MaskEffectOn(m_watertap);449 }450 public void OnWtarteTapClicked()451 {452 m_UIMain.ShowPanel(10, false);453 HightlightManager.Instance.MaskEffectOff(m_watertap);454 m_towel.GetComponent ().enabled = true;455 m_watertap.GetComponent ().enabled = false;456 m_waterTapAni.Play();457 m_waterEffect.SetActive(true);458 459 HightlightManager.Instance.MaskEffectOn(m_towel.gameObject);460 }461 public void OnTowelClicked()462 {463 HightlightManager.Instance.MaskEffectOff(m_towel.gameObject);464 m_towel.parent = m_rightHand;465 m_towelHand.SetActive(true);466 m_towel.localPosition = new Vector3(0, 0,0.5f);467 }468 public bool IsTowelWet469 {470 get { return m_bTowelWet; }471 set { m_bTowelWet = value; }472 }473 public void SetTowelWet()474 {475 m_bTowelWet = true;476 m_towel.GetComponent ().material.color = Color.white;477 }478 public void PickUpTowel()479 {480 m_towelHand.SetActive(false);481 m_towel.parent = transform.Find("head");482 m_towel.localPosition = new Vector3(0,-0.2f,0.2f);483 m_towel.localEulerAngles = Vector3.zero;484 m_waringPanels[1].SetActive(true);485 m_waterEffect.SetActive(false);486 ShowMark(15);487 }488 public void OnExtinguisherClicked()489 { //灭火器被点击490 m_fireRightHand.gameObject.SetActive(true);491 m_fireLeftHand.gameObject.SetActive(true);492 m_extinguisherAni.Play();493 494 HightlightManager.Instance.MaskEffectOff(m_extinguisher.gameObject);495 m_fireplug.gameObject.SetActive(true);496 m_extinguisher.GetComponent ().enabled = false;497 498 OnFireplugCicked();499 }500 void OnFireplugCicked()501 {502 m_UIMain.ShowHandArrow(true);503 m_fireLeftHand.GetComponent ().material.color = Color.red;504 m_fireRightHand.GetComponent ().enabled = true;505 }506 public void OnHandClicked()507 {508 m_UIMain.ShowHandArrow(false);509 m_fireLeftHand.gameObject.SetActive(false);510 m_fireRightHand.gameObject.SetActive(false);511 512 m_extinguisher.parent = m_rightHand;513 m_extinguisher.localPosition = new Vector3(0, 0, 0.08f);514 m_extinguisher.localEulerAngles = new Vector3(-90,90,0);515 516 m_extinguisher.gameObject.SetActive(true);517 m_bUseExtinguisher = true;518 m_fireplug.gameObject.SetActive(false);519 }520 public void TurnExtingulsher()521 {522 if (!m_bUseExtinguisher)523 {524 return;525 }526 m_ganfenEffect.SetActive(true);527 }528 public void TouchedFire()529 {530 m_bTouchedFire = true;531 m_fireAni.Play();532 }533 public void PutOutFire()534 {535 m_bUseExtinguisher = false;536 m_ganfenEffect.SetActive(false);537 m_extinguisher.parent = m_extinguisherParent;538 m_extinguisher.localPosition = m_extinguisherPos;539 m_extinguisher.localRotation = m_extinguisherRot;540 ShowMark(25);541 }542 public void OnLeaveConfirmClicked()543 {544 m_UIMain.ShowPanel(16, false);545 m_nCurTransID = 25;546 TransPort();547 }548 }
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 public class UIMain : MonoBehaviour { 6 private GameMain m_gameMain; 7 private GameObject[] m_Panels;//面板数组 8 private int m_nPanelCount=20;//面板数量 9 private GameObject m_brakeArrow; 10 private Vector3 m_testDoorPos0=new Vector3(3007f,267f,-2829.6f);//前门位置 11 private Vector3 m_testDoorPos1 = new Vector3(3007f, 267f, -1371f);//后门位置 12 private GameObject m_panelRedHand; 13 private GameObject m_panelGrayHand; 14 private bool m_bTestFrontDoorTemp=false; 15 private bool m_bTestBehindDoorTemp = false; 16 17 private GameObject m_handArrow; 18 19 public bool BTestFrontDoorTemp 20 { 21 get 22 { 23 return m_bTestFrontDoorTemp; 24 } 25 26 set 27 { 28 m_bTestFrontDoorTemp = value; 29 } 30 } 31 32 public bool BTestBehindDoorTemp 33 { 34 get 35 { 36 return m_bTestBehindDoorTemp; 37 } 38 39 set 40 { 41 m_bTestBehindDoorTemp = value; 42 } 43 } 44 45 private void Start() 46 { 47 m_brakeArrow = transform.Find("BrakeArrow").gameObject; 48 m_handArrow = transform.Find("HandArrow").gameObject; 49 m_handArrow.SetActive(false); 50 m_brakeArrow.SetActive(false); 51 } 52 private void OnEnable() 53 { 54 m_gameMain = GameObject.Find("WaveVR").GetComponent(); 55 m_Panels = new GameObject[m_nPanelCount]; 56 for (int i = 0; i < m_nPanelCount; i++) 57 { 58 m_Panels[i]= transform.Find("Panel" + i).gameObject; 59 m_Panels[i].SetActive(false); 60 } 61 m_panelRedHand = transform.Find("PanelRedHand").gameObject; 62 m_panelRedHand.SetActive(false); 63 m_panelGrayHand = transform.Find("PanelGrayHand").gameObject; 64 m_panelGrayHand.SetActive(false); 65 } 66 public void ShowPanel(int index,bool bShow)//显示面板 67 { 68 m_Panels[index].SetActive(bShow); 69 } 70 public void UIConfirmBtnClick(string sName) 71 { 72 int index=int.Parse(sName.Substring(sName.Length - 1));//找到最后一位数字 73 if (index == 8) 74 { 75 ShowPanel(17, false); 76 m_gameMain.TransportToClassRoom(); 77 } 78 if (index==1)//确认拨打电话 79 { 80 ShowPanel(1,false); 81 ShowPanel(2, true); 82 } 83 if (index==3) 84 { 85 ShowPanel(4, true); 86 ShowPanel(3, false); 87 Invoke("HideCallSuccess", 2f); 88 } 89 if (index==6) 90 { 91 m_bTestFrontDoorTemp = false; 92 m_panelRedHand.SetActive(false); 93 m_panelGrayHand.SetActive(false); 94 ShowPanel(6, false); 95 m_gameMain.ShowMark(9); 96 } 97 if (index==7) 98 { 99 m_bTestBehindDoorTemp = false;100 m_panelGrayHand.SetActive(false);101 m_panelRedHand.SetActive(false);102 ShowPanel(7, false);103 m_gameMain.TransportToPassageWay();104 }105 }106 public void UIChoseBtnClick(string sName)107 {108 int index = int.Parse(sName.Substring(sName.Length - 1));109 if (index==1)//选择正确110 {111 ShowPanel(4, true);112 Invoke("HideCallSuccess",2f);113 }114 else115 {116 ShowPanel(3, true);117 }118 ShowPanel(2, false);119 }120 public void ShowBreakArrow(bool bshow)121 {122 m_brakeArrow.SetActive(bshow);123 }124 void HideCallSuccess()125 {126 ShowPanel(4, false);127 m_gameMain.ShowMark(7);128 }129 public void TestDoorTemp()130 {131 m_Panels[5].transform.localPosition = m_testDoorPos0;132 ShowPanel(5, true);133 m_panelRedHand.SetActive(true);134 BeginTestFrontDoorTemp();135 }136 void BeginTestFrontDoorTemp()//开始测试前门温度137 {138 BTestFrontDoorTemp = true;139 }140 public void UITouchFrontDoor(bool bTouch)141 {142 if (!BTestFrontDoorTemp)143 {144 return;145 }146 m_panelRedHand.transform.localPosition = m_testDoorPos0;147 m_panelGrayHand.transform.localPosition = m_testDoorPos0;148 m_panelRedHand.SetActive(!bTouch);149 m_panelGrayHand.SetActive(bTouch);150 if (bTouch)151 {152 ShowPanel(5, false);153 ShowPanel(6, true);154 }155 }156 public void UITouchBehindDoor(bool bTouch)157 {158 if (!m_bTestBehindDoorTemp)159 {160 return;161 }162 m_panelRedHand.transform.localPosition = m_testDoorPos1;163 m_panelGrayHand.transform.localPosition = m_testDoorPos1;164 m_panelRedHand.SetActive(!bTouch);165 m_panelGrayHand.SetActive(bTouch);166 if (bTouch)167 {168 ShowPanel(5, false);169 ShowPanel(7, true);170 }171 }172 173 public void ShowTestBehindDoor()174 {175 m_Panels[5].transform.localPosition = m_testDoorPos1;176 ShowPanel(5, true);177 m_panelRedHand.SetActive(true);178 Invoke("BeginTestBehindDoorTemp",1f);179 }180 void BeginTestBehindDoorTemp()//开始测试后门温度181 {182 m_bTestBehindDoorTemp = true;183 }184 public void UIAlarmBellClicked()185 {186 ShowPanel(8, false);187 m_gameMain.ShowMark(12);188 }189 public void ShowHandArrow(bool bShow)190 {191 m_handArrow.SetActive(bShow);192 }193 194 }
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 using wvr; 5 6 public class Teleport : MonoBehaviour { 7 private GameMain m_Main; 8 private GameObject m_WaveVR; 9 private WaveVR_SimplePointer m_pointer;10 // Use this for initialization11 void Start () {12 m_pointer = transform.GetComponent();13 m_Main = transform.parent.GetComponent ();14 }15 16 // Update is called once per frame17 void Update () {18 if (WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Right).GetPressDown(wvr.WVR_InputId.WVR_InputId_Alias1_Menu))19 {20 Application.Quit();21 }22 if (!m_pointer||!m_pointer.GetHitTrans())23 {24 return;25 }26 GameObject hititem=m_pointer.GetHitTrans().gameObject;27 if (hititem.name == "PositionMarker")//将地标放大28 {29 m_Main.HitPositionMarket(true);30 if (WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Right).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Touchpad))31 {32 m_Main.TransPort();33 }34 }35 else36 {37 m_Main.HitPositionMarket(false);38 }39 if (WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Right).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Touchpad))40 {41 m_Main.TurnExtingulsher();42 if (hititem.name.Contains("ConfirmButton"))//点到按钮43 {44 m_Main.OnConfirmButtonClicked(hititem.name);45 }46 if (hititem.name== "Brake")47 {48 m_Main.OnBrakeClicked();49 }50 if (hititem.name.Contains("ChoseButton"))51 {52 m_Main.OnChoseButtonClicked(hititem.name);53 }54 if (hititem.name== "AlarmBell")//点击警铃55 {56 m_Main.OnAlarmBellClick();57 }58 if (hititem.name.Equals("WaterTap"))59 {60 m_Main.OnWtarteTapClicked();61 }62 if (hititem.name.Equals("Towel"))63 {64 m_Main.OnTowelClicked();65 }66 if (hititem.name.Equals("loidao_dong_03"))67 {68 m_Main.OnExtinguisherClicked();69 }70 if (hititem.name.Equals("body002"))71 {72 m_Main.OnHandClicked();73 }74 if (hititem.name.Equals("OkButton"))75 {76 m_Main.OnLeaveConfirmClicked();77 }78 79 }80 if (hititem.name.Equals("FrontDoor"))//前门81 {82 m_Main.OnTouchFrontDoor(true);83 }84 else85 {86 m_Main.OnTouchFrontDoor(false);87 }88 if (hititem.name.Equals("BehindDoor"))89 {90 m_Main.OnTouchBehindDoor(true);91 }92 else93 {94 m_Main.OnTouchBehindDoor(false);95 }96 }97 }
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 public class ParticleCollosion : MonoBehaviour { 6 public GameMain m_WaveVR; 7 // Use this for initialization 8 private void OnParticleCollision(GameObject other) 9 {10 if (other.name.Equals("Waterfall_Emitter_1")&&!m_WaveVR.IsTowelWet)11 {12 m_WaveVR.SetTowelWet();13 }14 if (other.name.Equals("MieHuoQiSmoke")&&!m_WaveVR .IsTouchedFire)15 {16 m_WaveVR.TouchedFire();17 Invoke("OnFirePutOut",5f);18 }19 }20 private void OnFirePutOut()21 {22 m_WaveVR.PutOutFire();23 }24 }
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 ///6 /// 这个脚本要挂在头上,只要获得父物体就可以了 7 /// 8 public class ColliderManager : MonoBehaviour { 9 GameMain gameMain;10 11 // Use this for initialization12 void Start () {13 gameMain = transform.parent.GetComponent();//它的父物体加上这个脚本???14 }15 16 private void OnTriggerEnter(Collider other)//碰撞17 {18 if (other.name.Equals("Towel")&&gameMain.IsTowelWet)//碰着的是毛巾,毛巾是沾水了的,才固定在头上19 {20 gameMain.PickUpTowel();21 }22 }23 24 }
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 ///6 /// 控制高亮-》控制物体材质球,为了外面的好调用,把这个脚本写成一个单列,不需要挂在任何物体上, 7 /// 8 public class HightlightManager { //做成单利 9 private static HightlightManager _instance = null; //单列创建一个对象,不声明10 public static HightlightManager Instance11 {12 get13 {14 if (_instance==null)15 {16 _instance = new HightlightManager();17 }18 return _instance;19 }20 }21 public void MaskEffectOn(GameObject gameObject)//打开高亮22 {23 if (gameObject==null)//如果物体为空,不能设置高亮24 {25 26 }27 Material[] material= gameObject.GetComponent().materials; ;//一个物体可以有多个材质球,所以要找到所以的28 foreach (var item in material)29 {30 item.EnableKeyword("_EMISSION");//打开高亮 选择这个?EnableKeyword????????31 item.SetColor("_EmissionColor", new Color(0, 0.4568f, 0.7297f));32 }33 }34 public void MaskEffectOff(GameObject gameObject)//关闭高亮35 {36 if (gameObject == null)//如果物体为空,不能设置高亮37 {38 39 }40 Material[] material = gameObject.GetComponent ().materials; ;//一个物体可以有多个材质球,所以要找到所以的41 foreach (var item in material)42 {43 item.DisableKeyword("_EMISSION");//关闭高亮,关掉勾44 item.SetColor("_EmissionColor", new Color(0, 0.4568f, 0.7297f));45 }46 47 }48 }