religion/Assets/Scripts/Interactive.cs
Roman 37ccc08c85 任务:搭建基本的系统
1.编写塞钱箱逻辑
(1.初始为有钱
(2.创建事件,当被塞钱,修改塞钱箱状态
(3.创建事件,当被拿钱,修改塞钱箱状态
(*:修改塞钱箱继承自普通可交互物体

2.编写玩家塞钱逻辑
(1.创建交互按键,当检测到交互执行,执行所catch物体的OnCall,根据所catch物体不同触发不同的动作。当catch到的是塞钱箱,执行塞钱功能
(2.创建塞钱功能,持有特殊金币-1

3.修改爱欲品掉钱逻辑
(1.修改死亡事件,当检测到主人为地藏并且玩家身上已经没钱了的时候,生成一个特殊硬币

4.编写特殊硬币逻辑
(1.继承于可交互物体(×)
(2.OnCall的时候触发玩家加钱功能
(3.物理层上不与除地面以外的其他东西碰撞
(4.捡拾上,给硬币添加一个子物体,通过子物体上的触发器和攻击类来判断捡拾与否

5.编写地藏拿钱攻击逻辑
(*.参照钟的逻辑
(1.新建地藏手
(2.新建组件:地藏手
(3.收到攻击信号后,从外部从上至下伸入一只手,伴随抖动,到一定位置后停止
(4.手有碰撞体,触碰到玩家时,对玩家造成伤害
(5.抄一段普通怪物的受击逻辑,当手被攻击了,触发动画,稍微抬起一小段,并且剧烈震动,同时通知主人被打

6.整理脚本

至此,关卡已经能按照正常的逻辑跑起来了
2021-12-11 02:12:12 +08:00

38 lines
1.1 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;
/// <summary>
/// 可交互物体基类
/// </summary>
public class Interactive : MonoBehaviour
{
/// <summary>
/// 这个是什么东西
/// </summary>
public enum ItemName{
,
};
public ItemName itemName;
//这是一对碰撞检测代码。当玩家进入将自身传给玩家。当玩家退出把玩家的catch清空
void OnTriggerEnter2D(Collider2D other){
if(other.TryGetComponent<MyPlayer>(out MyPlayer player))
player.catching = this;
}
void OnTriggerExit2D(Collider2D other)
{
if(other.TryGetComponent<MyPlayer>(out MyPlayer player)){
//如果目前退出当前交互区域的时候,玩家的捕捉物体是自己,才把玩家的捕捉清空。否则说明玩家在推出前就捕捉到了新的
//对象。这样是用来解决排布密集的可交互物体的问题
if(player.catching == this)player.catching = null;
}
}
public virtual void OnCall(){}
public virtual void OnBeGaveMoney(){}
}