94 lines
2.6 KiB
C#
94 lines
2.6 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>
|
|||
|
/// 塞钱箱
|
|||
|
/// </summary>
|
|||
|
private MoneyBox moneyBox;
|
|||
|
private delegate IEnumerator Action();
|
|||
|
private enum PlayerState{上半,下半};
|
|||
|
private MyPlayer player;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 到底在上面还是下面生成爱欲品的玩家位置Y轴的界限
|
|||
|
/// </summary>
|
|||
|
[Header("到底在上面还是下面生成爱欲品的玩家位置Y轴的界限")]
|
|||
|
public float aiYuPinBuildLimit;
|
|||
|
|
|||
|
private void Init(){
|
|||
|
moneyBox = FindObjectOfType<MoneyBox>();
|
|||
|
player = FindObjectOfType<MyPlayer>();
|
|||
|
}
|
|||
|
|
|||
|
protected override void OnFindThePlayer(Transform target){
|
|||
|
if(state == State.wander){
|
|||
|
state = State.atk;
|
|||
|
StartCoroutine("ATK");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void Start(){
|
|||
|
Init();
|
|||
|
}
|
|||
|
|
|||
|
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());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 召唤爱欲品的时候Call这个
|
|||
|
/// </summary>
|
|||
|
private IEnumerator CallAiYuPin(){
|
|||
|
yield return new WaitForEndOfFrame();
|
|||
|
//确定玩家在上半边还是下半边
|
|||
|
PlayerState playerState =
|
|||
|
((player.transform.position.y > aiYuPinBuildLimit) ? PlayerState.上半: PlayerState.下半);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 敲钟的时候Call这个
|
|||
|
/// </summary>
|
|||
|
private IEnumerator RingTheBell(){
|
|||
|
yield return new WaitForEndOfFrame();
|
|||
|
Debug.Log("地藏正在敲钟");
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 拿钱的时候Call这个
|
|||
|
/// </summary>
|
|||
|
private IEnumerator TakeTheMoney(){
|
|||
|
yield return new WaitForEndOfFrame();
|
|||
|
Debug.Log("地藏正在拿钱");
|
|||
|
}
|
|||
|
}
|