Roman 032bef564e 任务:搭建基本的系统
1.完成玩家被爱欲品抓住的逻辑
(1.在玩家类已经留下空事件,需要完成逻辑:当被爱欲品抓住,玩家需要:
((1.声明bool新变量isCatching
((2.更改变量isCatching为true
((3.更改inControl变量为false,此时玩家不再能移动
((4.处理伤害,每秒减去爱欲品的atk的血量
(2.在InputSystem的事件OnMove中,触发转身处,添加一处判定,若此时inControl,才能进行转身操作。若isCatching为真,不触发转身,进而触发爱欲品的挣脱事件。
(*:修改爱欲品完全挣脱事件,使其通知玩家已经完全挣脱
(3.当收到完全挣脱的消息,恢复isCatching为false,同时恢复inControl,同时关闭掉血协程,同时删除记录的抓着玩家的爱欲品

*:至此,爱欲品的行动逻辑基本上开发完成

2.修复玩家用锤子攻击会多次判定到怪物身上的Bug
3.修复玩家挥锤子卡手的问题
4.重新匹配锤子挥动判定与动画
5.修改锤子动画速度曲线
6.解决狂按攻击有概率卡死的问题
7.使玩家攻击的时候无法移动
8.解决玩家被缠抱时可以跳跃的问题
9.解决玩家被缠抱时可以发镰刀的问题

攻击手感很怪,还需要细调
🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔
2021-12-03 23:58:34 +08:00

144 lines
4.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 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>
public bool canBeHit = true;
// _____ _ _
// | __ \ (_) | |
// | |__) | __ ___ ____ _| |_ ___
// | ___/ '__| \ \ / / _` | __/ _ \
// | | | | | |\ V / (_| | || __/
// |_| |_| |_| \_/ \__,_|\__\___|
/// <summary>
/// 当前生命值
/// </summary>
[ReadOnly][SerializeField][ProgressBar(0,10,0.15f,0.47f,0.74f)][FoldoutGroup("状态")]
protected float HPLeft;
/// <summary>
/// 当前状态
/// </summary>
[EnumPaging][SerializeField][ReadOnly][Header("当前状态")][FoldoutGroup("状态")]
protected State state;
// ______ _
// | ____| | |
// | |____ _____ _ __ | |_
// | __\ \ / / _ \ '_ \| __|
// | |___\ V / __/ | | | |_
// |______\_/ \___|_| |_|\__|
/// <summary>
/// 当怪物死的时候Call这个函数
/// </summary>
protected 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>
protected virtual void OnFindThePlayer(Transform target){}
/// <summary>
/// 当怪物着地的时候触发一次
/// </summary>
protected virtual void OnRetouchedTheGround(){}
// _ _ _
// | \ | | | |
// | \| | ___ _ __ _ __ ___ __ _| |
// | . ` |/ _ \| '__| '_ ` _ \ / _` | |
// | |\ | (_) | | | | | | | | (_| | |
// |_| \_|\___/|_| |_| |_| |_|\__,_|_|
/// <summary>
/// 看看死了没
/// </summary>
protected 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 void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.TryGetComponent<MyPlayer>(out MyPlayer player))
{OnFindThePlayer(other.transform);}//如果监视范围出现玩家则Call事件
}
}