2.添加了Shader的框架(与屏幕后特效相关) 1)加入了LightController的代码文件,主要控制烛光等灯光的空气扰动现象 2)加入了VolumeController的代码文件,主要与屏幕后特效的控制变量相关 3)在场景中加入了Volume的对象,控制屏幕后特效Shader的运行 3.挪动了场景中煤油灯的位置,并且为煤油灯添加了会产生空气扰动使光范围发生变化的功能 4.为测试场景中的镜子添加了临时提示光边Shader
72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class TelephoneLine : Interactive
|
|
{
|
|
//电话线类,控制每一处断裂的电话线
|
|
// Start is called before the first frame update
|
|
private float allNeedTime;
|
|
private float hasReparedTime = 0f;
|
|
private bool isReparing = false;
|
|
public bool isRepared = false;
|
|
IndexRecoder indexRecoder;
|
|
private float process = 0f;
|
|
|
|
void Start()
|
|
{
|
|
indexRecoder = FindObjectOfType<IndexRecoder>();
|
|
allNeedTime = indexRecoder.TelephoneNeedTime;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if(!isRepared&&isReparing)//如果没有修复并且正在修复
|
|
{
|
|
//在修复的话,每帧累计时间,并更新进度
|
|
hasReparedTime += Time.deltaTime;
|
|
process = hasReparedTime/allNeedTime;
|
|
//检查是否满了
|
|
if(process >= 1f)
|
|
{
|
|
isRepared = true;
|
|
FindObjectOfType<AllLinesInfo>().OKCount++;
|
|
Debug.Log("满了,这个修好了");
|
|
OnStopReparing();
|
|
}
|
|
//还要更新UI上的进度条
|
|
for(int i = 0; i < m_interface.transform.childCount; i++)
|
|
if(m_interface.transform.GetChild(i).tag == "进度条")
|
|
m_interface.transform.GetChild(i).GetComponent<Image>().fillAmount = process;
|
|
}
|
|
}
|
|
|
|
public override void OnCall()
|
|
{
|
|
//象征着按下交互键了,如果这个还没被修改,即刻开始修复电话线
|
|
if(!isRepared)
|
|
{
|
|
m_interface.SetActive(true);
|
|
StartRepareTheTelephoneLine();
|
|
}
|
|
}
|
|
|
|
private void StartRepareTheTelephoneLine()
|
|
{
|
|
isReparing = true;
|
|
}
|
|
|
|
public override void StopRepareTheTelephoneLine()
|
|
{
|
|
isReparing = false;
|
|
OnStopReparing();
|
|
}
|
|
|
|
private void OnStopReparing()
|
|
{
|
|
m_interface.SetActive(false);
|
|
}
|
|
}
|