
*.编写黑块逻辑 (*.具有状态in、all、out (1.当被呼出,执行呼出事件 ((1.分type执行“入”的Tween动画 ((2.入动画结束后,修改自身状态至all ((3.等待一定的加载时间后,修改自身状态为out,并开始出动画 ((4.出动画结束后,找到“开幕演出”游戏物体,找到它的Stage并触发 ((5.完成善后工作,将块移回原来的位置 (2.start时,检查场景内是否有其他转场块。若有,删除自己 1.制作转场 (1.触发转移 (2.关闭操作地图 (4.令玩家一直向右移动 (3.呼出黑块 (4.等待、直到黑块进入全覆盖状态 (5.根据字典经行场景转移 (6.黑块内部协程级时结束后,揭开黑幕 (7.揭开动画结束后 (8.找到“开幕演出”游戏物体,找到它的Stage并触发 3.流程化游戏 (1.将各个场景简单连接 4.修改各场景开幕演出,使开幕演出时修改玩家位置至指定位置 5.制作和替换美术素材,增加部分动画 (1.制作地藏石像动画 *优化和修复 1.修复佛教前置关陷阱小怪抽动的问题 2.修复佛教前置关掉怪陷阱下落太慢的问题 建议: 1.给普通关卡和村也加上类似Boos的全局shader,目前从关卡间过度的时候能够看出明显的区别 2.建议给地藏敲钟攻击的灰尘加上渐隐,目前是瞬间消失的,十分违和 3.建议给普通的炸弹也加上拖尾,很酷 4.以撒发怒时变红太快了,消散得也太快了 5.以撒鬼魂的粒子也建议加上淡入和淡出 *.至此,已经基本完成了游戏的流程化,已经能够顺利地连成一条线了,并且可以在关卡失败的时候在当前场景重生 *.接下来就是填充剧情和美化场景,明天应该能把数据库互动做好 下班
141 lines
4.5 KiB
C#
141 lines
4.5 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][ReadOnly][Header("当前状态")][FoldoutGroup("状态")]
|
||
public State state;
|
||
|
||
// _____ _ _
|
||
// | __ \ (_) | |
|
||
// | |__) | __ ___ ____ _| |_ ___
|
||
// | ___/ '__| \ \ / / _` | __/ _ \
|
||
// | | | | | |\ 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事件
|
||
}
|
||
}
|