Roman c9a4456308 任务:推进游戏的流程化
场景:【序章-家中】
1.创建游戏物体【多态管理员】
*:修改脚本文件夹名称至中文
*:修复若干Bug
2.创建脚本【PolymorphicAdministrator】
3.编写【PolymorphicAdministrator】的基本逻辑
4.为数值记录者添加变量【stageName】,用来识作为多态的识别标志
5.完成了多态系统,现在同一个场景可以根据目前的【演出名】进行不同的初始化以节省空间。

后续的流程化明天继续开发,下班
加油吧🙏
2021-08-11 02:17:57 +08:00

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);
}
}