优化: 1.基督小怪的shader添加完毕,但是小怪的闪电似乎有bug,见末尾bug集合 2.给炸弹爆炸加入了粒子特效 3.优化了死亡的屏幕后特效,现在做到了只有黑白区域才会渲染死亡鬼魂的效果 音效: 1.制作了地藏的全部音效 2.制作了特洛伊木马的全部音效 3.制作了以撒的全部音效 4.制作了玩家 跳跃,挥锤子,扔镰刀,受击,死亡,与击中敌人的音效,目前还缺少交互音效 5.制作了爱欲品的抱人音效 6.制作了所有与爆炸相关的音效 音效大体上已经制作完毕,逻辑也已经写完了 如果有不合适的音效改起来还算容易 问题: 1.目前在交互时(对话,看牌子),玩家可以进行挥砍和跳跃 2.基督石像的雷击效果只有一半不知道是不是bug 3.基督石像我没有找到他的受击函数,所以他的受击音效我没有制作 下班,绷不住了,真就干了后半夜。
143 lines
4.6 KiB
C#
143 lines
4.6 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using Sirenix.OdinInspector;
|
||
|
||
|
||
/// <summary>
|
||
/// 敌人的基类,包含一些基本的功能和事件的虚函数
|
||
/// </summary>
|
||
public class Enemy : MonoBehaviour
|
||
{
|
||
// _____ _ _ _
|
||
// | __ \ | | | (_)
|
||
// | |__) | _| |__ | |_ ___
|
||
// | ___/ | | | '_ \| | |/ __|
|
||
// | | | |_| | |_) | | | (__
|
||
// |_| \__,_|_.__/|_|_|\___|
|
||
|
||
/// <summary>
|
||
/// 生命值上限
|
||
/// </summary>
|
||
[FoldoutGroup("属性")][Header("生命值上限")]
|
||
public float HP;
|
||
|
||
/// <summary>
|
||
/// 攻击力
|
||
/// </summary>
|
||
[FoldoutGroup("属性")][Header("攻击力")]
|
||
public float ATK;
|
||
|
||
/// <summary>
|
||
/// 速度
|
||
/// </summary>
|
||
[FoldoutGroup("属性")][Header("移动速度")]
|
||
public float speed;
|
||
/// <summary>
|
||
/// 打死后掉多少金币
|
||
/// </summary>
|
||
[FoldoutGroup("属性")][Header("掉落金币数")]
|
||
public int coin;
|
||
/// <summary>
|
||
/// 怪物拥有的几种状态
|
||
/// </summary>
|
||
public enum State{wander,seek,atk,dead};
|
||
/// <summary>
|
||
/// 此时怪物能否被攻击
|
||
/// </summary>
|
||
[FoldoutGroup("状态")][Header("当前是否能被攻击")][ReadOnly]
|
||
public bool canBeHit = true;
|
||
/// <summary>
|
||
/// 当前状态
|
||
/// </summary>
|
||
[EnumPaging][SerializeField][Header("当前状态")][FoldoutGroup("状态")]
|
||
public State state;
|
||
[Header("击中音效")] [FoldoutGroup("音效")]
|
||
public AudioSource attackAudio;
|
||
|
||
// _____ _ _
|
||
// | __ \ (_) | |
|
||
// | |__) | __ ___ ____ _| |_ ___
|
||
// | ___/ '__| \ \ / / _` | __/ _ \
|
||
// | | | | | |\ V / (_| | || __/
|
||
// |_| |_| |_| \_/ \__,_|\__\___|
|
||
|
||
/// <summary>
|
||
/// 当前生命值
|
||
/// </summary>
|
||
[ReadOnly][SerializeField][ProgressBar(0,10,0.15f,0.47f,0.74f)][FoldoutGroup("状态")]
|
||
public float HPLeft;
|
||
|
||
|
||
// ______ _
|
||
// | ____| | |
|
||
// | |____ _____ _ __ | |_
|
||
// | __\ \ / / _ \ '_ \| __|
|
||
// | |___\ V / __/ | | | |_
|
||
// |______\_/ \___|_| |_|\__|
|
||
|
||
/// <summary>
|
||
/// 当怪物死的时候Call这个函数
|
||
/// </summary>
|
||
public virtual void OnDead(){}
|
||
|
||
/// <summary>
|
||
/// 当怪物触碰到玩家的时候Call这个
|
||
/// </summary>
|
||
protected virtual void OnTouchThePlayer(MyPlayer player){}
|
||
|
||
/// <summary>
|
||
/// 当怪物被打的时候触发
|
||
/// </summary>
|
||
/// <param name="hitMethod">攻击方式,枚举类型,具体看MyPlayer</param>
|
||
/// <param name="hitDir">受击方向,-1左,1右</param>
|
||
public virtual void OnBeHit(MyPlayer.AtkMethod hitMethod,int hitDir){}
|
||
|
||
/// <summary>
|
||
/// 当怪物发现玩家的时候Call这个
|
||
/// </summary>
|
||
public virtual void OnFindThePlayer(Transform target){}
|
||
/// <summary>
|
||
/// 当怪物着地的时候触发一次
|
||
/// </summary>
|
||
public virtual void OnRetouchedTheGround(){}
|
||
|
||
// _ _ _
|
||
// | \ | | | |
|
||
// | \| | ___ _ __ _ __ ___ __ _| |
|
||
// | . ` |/ _ \| '__| '_ ` _ \ / _` | |
|
||
// | |\ | (_) | | | | | | | | (_| | |
|
||
// |_| \_|\___/|_| |_| |_| |_|\__,_|_|
|
||
|
||
/// <summary>
|
||
/// 看看死了没
|
||
/// </summary>
|
||
public bool CheckDead(){return !(HPLeft > 0);}
|
||
|
||
|
||
// _____ _ _ _ _
|
||
// / ____| | | (_) (_)
|
||
// | | ___ | | |_ ___ _ ___ _ __
|
||
// | | / _ \| | | / __| |/ _ \| '_ \
|
||
// | |___| (_) | | | \__ \ | (_) | | | |
|
||
// \_____\___/|_|_|_|___/_|\___/|_| |_|
|
||
protected void OnCollisionEnter2D(Collision2D other)//当有物体碰上
|
||
{
|
||
if(other.collider.gameObject.TryGetComponent<MyPlayer>(out MyPlayer player))
|
||
{OnTouchThePlayer(player);}//如果创到的是玩家,则Call事件
|
||
//如果被镰刀创到,Call一下OnBeHit事件,传入攻击方式和攻击来袭方向
|
||
else if(other.collider.gameObject.TryGetComponent<Sickle>(out Sickle sickle))
|
||
{OnBeHit(MyPlayer.AtkMethod.镰刀,
|
||
(transform.position.x -
|
||
sickle.transform.position.x > 0) ? -1 : 1);
|
||
Destroy(sickle.gameObject);}
|
||
else if(other.gameObject.tag == "地面")
|
||
{OnRetouchedTheGround();}
|
||
}
|
||
protected virtual void OnTriggerEnter2D(Collider2D other)
|
||
{
|
||
if(other.gameObject.TryGetComponent<MyPlayer>(out MyPlayer player))
|
||
{OnFindThePlayer(other.transform);}//如果监视范围出现玩家,则Call事件
|
||
}
|
||
}
|