Roman 42b2c05a02 任务:替换现有美术素材和动画、完善游戏的流程化
*合并SAIPOVer
场景【序章-家中】
1.解决非对应多态和门互动报错的Bug

场景【第一关】
1.放上天空素材
2.放上投掷物的美术素材
3.目前投掷物不会旋转,写了方法让投出的石块随着速度的方向而旋转
4.修改了动画文件的链接方式,优化操作手感
5.放置了电火花粒子系统,适配到6处断裂
6.修改屎山代码,能够自己找到的子物体为什么要public?
7.现在似乎太难了,我降低了导弹的生成频率
8.完善修完第一个电话线后的事件,使特殊的导弹没有阴影
9.将投掷行为绑定到新骨骼
10.修改地形使其匹配电报线的凹凸
11.修复了删不掉落地后的投掷物的碰撞体的Bug
12.修改了抛物线材质使其更加显眼
13.添加投掷系统动画
14.使得地雷爆炸的时候会产生一个爆炸动画
15.修复了投掷点不跟随玩家骨骼移动的Bug
2021-08-30 01:55:39 +08:00

108 lines
3.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
public class TelephoneLine : Interactive
{
//电话线类,控制每一处断裂的电话线
// Start is called before the first frame update
private float allNeedTime;
private float hasReparedTime = 0f;
private bool isReparing = false;
[SerializeField][ReadOnly]
private bool isRepared = false;
IndexRecoder indexRecoder;
private float process = 0f;
[Tooltip("特殊电话线用,拖入这个电话线修好后的事件")]
public Event endEvent;
private GameObject spark;//获取火花的对象
void Start()
{
indexRecoder = FindObjectOfType<IndexRecoder>();
allNeedTime = indexRecoder.TelephoneNeedTime;
m_interface = GameObject.Find("Canvas").transform.Find("修电话线界面").gameObject;
spark = transform.GetChild(0).gameObject;
}
// Update is called once per frame
void Update()
{
if(!isRepared&&isReparing)//如果没有修复并且正在修复
{
//在修复的话,每帧累计时间,并更新进度
hasReparedTime += Time.deltaTime;
process = hasReparedTime/allNeedTime;
//检查是否满了
if(process >= 1f)
{
spark.SetActive(false);//将火花对象隐藏
isRepared = true;//标记自己已经被修好
FindObjectOfType<AllLinesInfo>().OKCount++;//找到总线信息,给好了的电话线+1
Debug.Log("满了,这个修好了");
OnStopReparing();//关下UI
GetComponent<SpriteRenderer>().enabled = true;//打开修好的的图片素材
FindObjectOfType<M_Player>().HasReparedATelephone();//告诉玩家自己被修好,打断修理动画
if(endEvent != null) endEvent.OnCall();//如果有结束事件,那触发一下结束事件
}
//还要更新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);//打开UI
m_interface.transform.position = Camera.main.WorldToScreenPoint(transform.position);
StartRepareTheTelephoneLine();
}
}
private void StartRepareTheTelephoneLine()
{
isReparing = true;
}
public override void StopRepareTheTelephoneLine()
{
isReparing = false;
OnStopReparing();
}
//当此电话线修好了
private void OnStopReparing()
{
m_interface.SetActive(false);//关闭修电话线的UI
}
public bool HasTheBePrepared(){return isRepared;}
//制造一个只读的变量,不要动这些
public class ReadOnlyAttribute : PropertyAttribute{}
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
}
}
//
}