
1.编写以撒逻辑 (1.继承于Enemy (2.编写OnSave(男童)事件,当有男童被解救,会触发以撒的这个事件,后续逻辑等待讨论 (3.具有冲撞和闪电两种攻击方式,通过类似地藏的方式轮回随机决定攻击方式 (4.编写冲撞攻击逻辑 ((*.创建鬼魂脚本 ((*.创建鬼魂预制体,需要内含触发器 ((1.当执行,以玩家为中心向周围一圈固定距离随机方向的某处召唤鬼魂,并记录下此时自身到玩家的方向 ((2.等待一小段时间,令鬼魂以记录方向冲撞出去,利用Tweener动画营造一种先抖一下然后猛地创过来的感觉 ((3.动画结束后,鬼魂逐渐消隐 ((4.消隐结束后,删除游戏物体 ((5.冲撞过程中具有攻击判定,若创到玩家,触发玩家的受击事件,同时获取主人的攻击力传给玩家 (3.编写闪电攻击逻辑 ((1.当执行,在玩家头顶一定距离处生成鬼魂 ((2.淡入显示鬼魂,一小段时间后,命令鬼魂发动落雷攻击 ((3.发动时,激活场景内的巨型落雷,同时更改落雷的x位置到鬼魂的x,子物体具有触发器,(每帧)检测到玩家在内则对玩家造成伤害 ((4.在极短的时间后关闭落雷同时开始淡出鬼魂 ((5.淡出结束后删除游戏物体 2.编写男童逻辑 (1.继承于Interactive (2.编写解救男童逻辑 ((*.修改Interactive基类,新增OnCallCancel事件,当交互键抬起时触发一次 ((*.新增男童状态的枚举类型,包含:wait、saving、OK三个状态 ((*:新增一个变量记录男童状态 ((1.重写OnCall事件,当OnCall,修改状态至saving ((2.Update回调中,若处于saving状态,则开始减少CDLeft,同时判断CDLeft是否耗尽,若耗尽,触发OnSave ((3.编写OnSave函数,修改状态至OK,通知owner自己已经OnSave ((4.重写OnCallCancel事件,当触发,判定状态,若处于saving状态,则修改状态至wait,恢复CDLeft ((*.使得玩家救人的时候无法移动,而当交互键抬起,重新获得移动能力 ((*.修改可交互基类,当玩家交互过程中丢失catching,触发可交互物体的中断,同时告知玩家交互中断,触发中断事件 ((5.解救结束后,通知玩家解救结束 至此,以撒的Boss逻辑还差首尾部分 加速吧
209 lines
7.3 KiB
C#
209 lines
7.3 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using Sirenix.OdinInspector;
|
||
|
||
/// <summary>
|
||
/// 地藏Boss类,继承于Enemy
|
||
/// </summary>
|
||
public class DiZang : Enemy
|
||
{
|
||
// _____ _ _ _
|
||
// | __ \ | | | (_)
|
||
// | |__) | _| |__ | |_ ___
|
||
// | ___/ | | | '_ \| | |/ __|
|
||
// | | | |_| | |_) | | | (__
|
||
// |_| \__,_|_.__/|_|_|\___|
|
||
|
||
/// <summary>
|
||
/// 攻击之间的间隔时间
|
||
/// </summary>
|
||
[Header("攻击之间的间隔时间")][FoldoutGroup("地藏")]
|
||
public float timeBetweenAttacks;
|
||
/// <summary>
|
||
/// 到底在上面还是下面生成爱欲品的玩家位置Y轴的界限
|
||
/// </summary>
|
||
[Header("到底在上面还是下面生成爱欲品的玩家位置Y轴的界限")][FoldoutGroup("地藏")]
|
||
public float aiYuPinBuildLimit;
|
||
[Header("爱欲品怪物预制体")][FoldoutGroup("地藏")]
|
||
public GameObject aiYuPin;
|
||
/// <summary>
|
||
/// 场景上方的落怪点组,用来召唤爱欲品
|
||
/// </summary>
|
||
[Header("场景上方的落怪点组")][ListDrawerSettings][FoldoutGroup("地藏")]
|
||
public List<ThrowingPoint> throwingPointGroupUp;
|
||
/// <summary>
|
||
/// 场景下方的落怪点组,用来召唤爱欲品
|
||
/// </summary>
|
||
[Header("场景下方的落怪点组")][ListDrawerSettings][FoldoutGroup("地藏")]
|
||
public List<ThrowingPoint> throwingPointGroupDown;
|
||
/// <summary>
|
||
/// 使用召唤爱欲品后有多少时间的后摇
|
||
/// </summary>
|
||
[Header("使用召唤爱欲品后有多少时间的后摇")][FoldoutGroup("地藏")]
|
||
public float CallAiYuPinEndTime;
|
||
|
||
|
||
// _____ _ _
|
||
// | __ \ (_) | |
|
||
// | |__) | __ ___ ____ _| |_ ___
|
||
// | ___/ '__| \ \ / / _` | __/ _ \
|
||
// | | | | | |\ V / (_| | || __/
|
||
// |_| |_| |_| \_/ \__,_|\__\___|
|
||
|
||
private MoneyBox moneyBox;
|
||
private delegate IEnumerator Action();
|
||
private enum PlayerState{上半,下半};
|
||
private MyPlayer player;
|
||
/// <summary>
|
||
/// 本次使用的落怪点位置组
|
||
/// </summary>
|
||
[Header("本次使用的落怪点位置组")][ListDrawerSettings][FoldoutGroup("地藏")]
|
||
[SerializeField][ListDrawerSettings][ReadOnly]
|
||
private List<ThrowingPoint> throwingPointGroupUse;
|
||
private Bell myBell;
|
||
private DiZangsHadn myHand;
|
||
public VibrationManager vibrationManager;
|
||
/// <summary>
|
||
/// 现在正在敲钟攻击吗?(包括上下浮)
|
||
/// </summary>
|
||
public bool inBell = false;
|
||
|
||
// _____ _ _ ____ _
|
||
// / ____| | | | _ \ | |
|
||
// | | __ _| | | |_) | __ _ ___| | __
|
||
// | | / _` | | | _ < / _` |/ __| |/ /
|
||
// | |___| (_| | | | |_) | (_| | (__| <
|
||
// \_____\__,_|_|_|____/ \__,_|\___|_|\_\
|
||
|
||
void Start(){
|
||
Init();
|
||
}
|
||
|
||
// _ _ _
|
||
// | \ | | | |
|
||
// | \| | ___ _ __ _ __ ___ __ _| |
|
||
// | . ` |/ _ \| '__| '_ ` _ \ / _` | |
|
||
// | |\ | (_) | | | | | | | | (_| | |
|
||
// |_| \_|\___/|_| |_| |_| |_|\__,_|_|
|
||
private void Init(){
|
||
//找到组件和物体
|
||
moneyBox = FindObjectOfType<MoneyBox>();
|
||
player = FindObjectOfType<MyPlayer>();
|
||
myBell = transform.Find("钟").GetComponent<Bell>();
|
||
myHand = transform.Find("手").GetComponent<DiZangsHadn>();
|
||
vibrationManager = FindObjectOfType<VibrationManager>();
|
||
//告诉钟自己是主人
|
||
myBell.owner = this;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 执行一次攻击
|
||
/// </summary>
|
||
private new IEnumerator ATK(){
|
||
//等待攻击间隔
|
||
yield return new WaitForSeconds(timeBetweenAttacks);
|
||
//决定行动
|
||
//如果有钱,则执行拿钱
|
||
if(moneyBox.hasMoney)StartCoroutine(TakeTheMoney());
|
||
else{
|
||
//否则,随机执行召唤或者敲钟
|
||
Action action =
|
||
((Random.Range(-1f,1f) > 0) ? (Action)RingTheBell : (Action)CallAiYuPin);
|
||
StartCoroutine(action());
|
||
}
|
||
// //
|
||
// yield return new WaitForEndOfFrame();
|
||
// StartCoroutine(RingTheBell());
|
||
// //
|
||
}
|
||
|
||
/// <summary>
|
||
/// 召唤爱欲品的时候Call这个
|
||
/// </summary>
|
||
private IEnumerator CallAiYuPin(){
|
||
Debug.Log("正在使用:召唤");
|
||
//确定玩家在上半边还是下半边
|
||
PlayerState playerState =
|
||
((player.transform.position.y > aiYuPinBuildLimit) ? PlayerState.上半: PlayerState.下半);
|
||
//根据玩家位置状态确定所用落怪位置组
|
||
throwingPointGroupUse =
|
||
((playerState == PlayerState.上半) ?
|
||
throwingPointGroupUp : throwingPointGroupDown);
|
||
//创建一个储存生成的爱欲品的列表,用于使他们在一段时间后开始Seek
|
||
List<AiYuPin> aiYuPins = new List<AiYuPin>();
|
||
//遍历位置组
|
||
foreach(ThrowingPoint t in throwingPointGroupUse){
|
||
//生成一个爱欲品
|
||
AiYuPin temp =Instantiate(
|
||
aiYuPin,
|
||
t.transform.position,//在位置组中元素的位置
|
||
Quaternion.identity
|
||
).GetComponent<AiYuPin>();
|
||
//初始化爱欲品
|
||
//该状态为wander使其先保持不动
|
||
temp.state = State.wander;
|
||
//修改爱欲品面部朝向
|
||
if(t.dir.x == -1) temp.transform.rotation = Quaternion.Euler(
|
||
temp.transform.rotation.x,
|
||
-180f,
|
||
temp.transform.localScale.z
|
||
);
|
||
//根据投掷点内信息给予爱欲品投掷速度
|
||
temp.GetComponent<Rigidbody2D>().velocity = t.dir * t.strength;
|
||
//把这个爱欲品加入列表
|
||
aiYuPins.Add(temp);
|
||
}
|
||
//一段时间后,使他们开始Seek
|
||
yield return new WaitForSeconds(0.8f);
|
||
foreach(AiYuPin a in aiYuPins){
|
||
a.state = State.seek;
|
||
}
|
||
//等待攻击后摇结束
|
||
yield return new WaitForSeconds(CallAiYuPinEndTime);
|
||
//发送信号,本次攻击宣告结束
|
||
ATKEnd();
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 敲钟的时候Call这个
|
||
/// </summary>
|
||
private IEnumerator RingTheBell(){
|
||
Debug.Log("正在使用:敲钟");
|
||
inBell = true;
|
||
StartCoroutine(vibrationManager.ShakePad(0.5f,0.2f,6f,VibrationManager.PadShakeitem.撞钟攻击));
|
||
yield return new WaitForEndOfFrame();
|
||
myBell.ATK(player);
|
||
//开始震动屏幕
|
||
vibrationManager.BellShakeScream();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 拿钱的时候Call这个
|
||
/// </summary>
|
||
private IEnumerator TakeTheMoney(){
|
||
yield return new WaitForEndOfFrame();
|
||
Debug.Log("正在使用:拿钱");
|
||
myHand.ATK();
|
||
}
|
||
|
||
// ______ _
|
||
// | ____| | |
|
||
// | |____ _____ _ __ | |_
|
||
// | __\ \ / / _ \ '_ \| __|
|
||
// | |___\ V / __/ | | | |_
|
||
// |______\_/ \___|_| |_|\__|
|
||
protected override void OnFindThePlayer(Transform target){
|
||
if(state == State.wander){
|
||
state = State.atk;
|
||
StartCoroutine(ATK());
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 攻击结束的时候触发,重新开始新一轮攻击
|
||
/// </summary>
|
||
public void ATKEnd(){StartCoroutine(ATK());inBell = false;}
|
||
}
|