Roman 3c682117f3 任务:搭建第一关的框架
场景【第一关】
1.加入任务书的交互,交互键打开任务书,键盘【K】退出、手柄【B】退出
2.加入轰炸区、并做好适配。
3.啧,由于轰炸区的高度写了屎山代码,现在只能把对高度的适配这个参数还给轰炸区,再在场景中的轰炸区进行适配。
4.布置电话线断处(共六处)
5.优化电话线断除脚本,使其能够自己找到修电话线的UI
6.给电话线断处加上结束事件,因为有一条电话线修好后需要炸毁前面的石头
7.创建游戏物体【石头】
8.给石头添加控制脚本。
9.创建并编写事件【当修好第一个电话线】,召唤一枚炮弹砸向石头,石头检测到炮弹后销毁自己和炮弹,并在原地生成一个投掷物堆。
10.给炮弹加上标识,不是特殊的炮弹砸不烂石头。

下班,就剩9天了……😔
2021-08-18 00:50:19 +08:00

40 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Interactive : MonoBehaviour
{
//这是所有可交互物体的基类
public GameObject m_interface;//可交互物体一般都和一个UI界面挂钩这就是那个UI界面
//这是一对碰撞检测代码。当玩家进入将自身传给玩家。当玩家退出把玩家的catch清空
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
other.GetComponent<M_Player>().catched = this;
}
}
void OnTriggerExit2D(Collider2D other)
{
if(other.tag == "Player")
{
//如果目前退出当前交互区域的时候,玩家的捕捉物体是自己,才把玩家的捕捉清空。否则说明玩家在推出前就捕捉到了新的
//对象。这样是用来解决排布密集的可交互物体的问题
if(other.GetComponent<M_Player>().catched == this) other.GetComponent<M_Player>().catched = null;
}
}
//
//当这个可交互物体被玩家交互。一般需要重写这个函数。
public virtual void OnCall(){}
//
//以下为针对各具体可交互对象的虚拟函数,在具体物体中重写
public virtual void Coding(string temp){}//电报机的打码
public virtual void StopRepareTheTelephoneLine(){}//电话线的停止修复(松开按键检测
public virtual void Quit(){}//任务书的关闭
//
}