Roman ca1cc0162d 任务:编写留言系统、替换和实装美术素材
1.编写留言系统
(1.当玩家无Catch的时候,记录长按Y的时间,若时间大于两秒,呼唤UI,触发相应事件

*.编写撰写留言板逻辑
(*.清空操作地图
(1.呼出留言板UI
(2.当按下确认键,确认建立一个本地留言板,并初始化该本地留言板,恢复操作地图
(3.将留言板数据传向云端

*.编写留言板逻辑
(1.内含BoardInfo内的信息
(2.继承于可交互物体
(3.当交互,呼出留言板UI,显示内容、UID等信息
(4.当按下返回键,关闭UI

*.编写拉取留言板系统
(1.加在开幕演出中,开幕时呼叫sql上的脚本,拉取若干条留言板
(2.在场景内创建留言板,并初始化信息

*.替换和实装美术素材,增加部分动画
1.增加村内上树动画
2.更新村场景,使得玩家可以走到村下
3.制作以撒闪电攻击动画
4.制作以撒冲撞攻击动画
5.制作以撒雕像碎裂动画
6.贴上对话框
7.制作以撒闪电攻击动画
8.制作村民和贵族的待机角色
9.制作特洛伊木马死亡动画
10.制作特洛伊木马的喷射动画

*优化和修复
1.修复佛教前置关掉怪陷阱有时不会触发的问题
2.重做渲染层,避免出现覆盖问题
3.修复玩家会卡在村里桥上的问题
4.解决了屎山代码的warming问题
5.删除了子弹时间,效果太差

建议:
1.给击中添加一些效果,目前还是打击感太弱
2.目前木马死后,灰尘不会消失

*.至此,留言系统全部完成

下班
2021-12-25 00:37:29 +08:00

265 lines
8.7 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 DG.Tweening;
using Sirenix.OdinInspector;
/// <summary>
/// 撞钟类,控制地藏头上的钟
/// </summary>
public class Bell : MonoBehaviour
{
// _____ _ _ _
// | __ \ | | | (_)
// | |__) | _| |__ | |_ ___
// | ___/ | | | '_ \| | |/ __|
// | | | |_| | |_) | | | (__
// |_| \__,_|_.__/|_|_|\___|
/// <summary>
/// 攻击前置动作钟上浮多少距离
/// </summary>
[Header("攻击前置动作钟上浮多少距离")]
public float upDistance;
/// <summary>
/// 攻击将会持续多长时间
/// </summary>
[Header("攻击将会持续多长时间")]
public float atkTime;
/// <summary>
/// 主人也就是地藏Boss
/// </summary>
[HideInInspector]
public DiZang owner;
/// <summary>
/// 钟飞上去将要花费多少时间(降下来也是这个值)
/// </summary>
[Header("钟飞上去将要花费多少时间(降下来也是这个值)")]
public float upTime;
/// <summary>
/// 干扰多长时间能造成伤害和击飞?
/// </summary>
[Header("干扰多长时间能造成伤害和击飞?")]
public float annoyingToHitTime;
[Header("声波Shader")]
public BellShader bellShader;
[Header("声波受击粒子")]
public List<ParticleSystem> particleObjs;
// _____ _ _
// | __ \ (_) | |
// | |__) | __ ___ ____ _| |_ ___
// | ___/ '__| \ \ / / _` | __/ _ \
// | | | | | |\ V / (_| | || __/
// |_| |_| |_| \_/ \__,_|\__\___|
/// <summary>
/// 当前正在攻击吗
/// </summary>
[SerializeField][Button][ReadOnly][Header("当前正在攻击吗(不包括钟上下过程))")]
private bool isAtking = false;
private MyPlayer player;
/// <summary>
/// 浮动动画,用来重启浮动动画解决Tween的一些局限性问题
/// </summary>
public Tweener floatTweener;
private float annoyingToHitTimeLeft;
/// <summary>
/// 此时是否在干扰玩家
/// </summary>
[SerializeField]
private bool isAnnoyingPlayer;
/// <summary>
/// 钟的初始位置
/// </summary>
private Vector3 startPositon;
// _____ _ _ ____ _
// / ____| | | | _ \ | |
// | | __ _| | | |_) | __ _ ___| | __
// | | / _` | | | _ < / _` |/ __| |/ /
// | |___| (_| | | | |_) | (_| | (__| <
// \_____\__,_|_|_|____/ \__,_|\___|_|\_\
void Start(){
annoyingToHitTimeLeft = annoyingToHitTime;
startPositon = transform.position;
//启动浮动动画
RestartFloat();
}
void Update(){
//如果钟正在攻击
if(isAtking)
{
bellShader.isBell = true;
for (int i = 0; i < particleObjs.Count; i++)
{
StartCoroutine(SetParticleColor(particleObjs[i], 1f, 1f));
}
if(!player.isAnnoying){
player.OnInAnnoying();
}
//创建一条从钟射向玩家的射线
Ray2D ray = new Ray2D(
(Vector2)transform.position,
(Vector2)(player.transform.position - transform.position)
);
Debug.DrawRay(ray.origin,ray.direction * 1500,Color.red);
//获取射线的碰撞结果
RaycastHit2D hit2D;
hit2D = Physics2D.Raycast(ray.origin,ray.direction);
if(hit2D){
Debug.Log(hit2D.collider.name);
}
//如果射线击中玩家并且玩家未处于被攻击状态,说明刚被击中,触发玩家的被干扰事件
if(hit2D.collider.TryGetComponent<MyPlayer>(out MyPlayer trash) ){
// player.OnInAnnoying();
isAnnoyingPlayer = true;
}
//如果没有击中玩家,但是玩家处于被攻击状态,说明玩家脱离了攻击,触发玩家解除干扰事件
else if(!hit2D.collider.TryGetComponent<MyPlayer>(out MyPlayer trash1)){
//player.OnOutAnnoying();
isAnnoyingPlayer = false;
annoyingToHitTimeLeft = annoyingToHitTime;
}
}
if(isAnnoyingPlayer){
annoyingToHitTimeLeft -= Time.deltaTime;
if(annoyingToHitTimeLeft <= 0){
//告诉玩家,你被攻击了
player.OnBeHit(owner.ATK,
((transform.position.x -
player.transform.position.x)
> 0) ? 1 : -1);//通过自身位置和玩家位置的比较来返回玩家本次的受击方向
//恢复CD
annoyingToHitTimeLeft = annoyingToHitTime;
}
}
}
// _ _ _
// | \ | | | |
// | \| | ___ _ __ _ __ ___ __ _| |
// | . ` |/ _ \| '__| '_ ` _ \ / _` | |
// | |\ | (_) | | | | | | | | (_| | |
// |_| \_|\___/|_| |_| |_| |_|\__,_|_|
/// <summary>
/// 介于Tweener的特性经常需要重新创建钟浮动的动画
/// </summary>
private void RestartFloat(){
if(floatTweener != null){
floatTweener.Kill();
}
Tweener tweener = transform.DOShakePosition(5f,0.3f,1,90,false,false);
tweener.SetLoops(-1);
tweener.SetEase(Ease.InQuad);
floatTweener = tweener;
}
// ______ _
// | ____| | |
// | |____ _____ _ __ | |_
// | __\ \ / / _ \ '_ \| __|
// | |___\ V / __/ | | | |_
// |______\_/ \___|_| |_|\__|
/// <summary>
/// 从主人那里得到攻击指令后触发
/// </summary>
public void ATK(MyPlayer player){
//指定一下攻击目标
this.player = player;
//创建和执行上浮动画
Tweener tweener = transform.DOLocalMoveY(
transform.position.y + upDistance,
upTime
);
//创建并加入上浮动画结束事件
TweenCallback action = () => {
//标记自己开始攻击
isAtking = true;
//重启浮动动画
RestartFloat();
//等待攻击结束
StartCoroutine(WaitAndTurnDownThebutton());
};
tweener.OnComplete(action);
}
/// <summary>
/// 上浮动画结束的时候触发
/// </summary>
/// <returns></returns>
private IEnumerator WaitAndTurnDownThebutton(){
//等待攻击时长结束
yield return new WaitForSeconds(atkTime);
//标记攻击结束
isAtking = false;
//触发自身攻击结束功能
ATKEnd();
}
/// <summary>
/// 攻击结束的时候触发
/// </summary>
private void ATKEnd()
{
bellShader.isBell = false;
bellShader.Remake = true;
for (int i = 0; i < particleObjs.Count; i++)
{
StartCoroutine(SetParticleColor(particleObjs[i], 0, 1f));
}
//如果玩家仍处于被干扰状态,解除干扰
if(player.isAnnoying) player.OnOutAnnoying();
annoyingToHitTimeLeft = annoyingToHitTime;
isAnnoyingPlayer = false;
//创建动画让钟回去
Tweener tweener =
//transform.DOMoveY(transform.position.y - upDistance,upTime);
transform.DOMove(startPositon,upTime);
//创建和添加结束事件
TweenCallback action = () => {
//重启浮动动画
RestartFloat();
//告诉主人,攻击结束,开始下一个轮回
owner.ATKEnd();
};
tweener.OnComplete(action);
}
//修改粒子,使粒子淡出
private IEnumerator SetParticleColor(ParticleSystem particleSystem,float endValue,float speed)
{
Color color = particleSystem.main.startColor.color;
if (color.a > endValue)
{
while (particleSystem.main.startColor.color.a>endValue)
{
yield return new WaitForSeconds(0.1f);
color.a -= 0.1f;
//解决warming
#pragma warning disable 0618
particleSystem.startColor = color;
}
}
else
{
while (particleSystem.main.startColor.color.a<endValue)
{
yield return new WaitForSeconds(0.1f);
color.a += 0.1f;
//解决warming
#pragma warning disable 0618
particleSystem.startColor = color;
}
}
}
}