religion/Assets/Scripts/Boss/地藏/DiZangsHadn.cs
Roman 96843244ae 任务:流程化游戏
*.编写黑块逻辑
(*.具有状态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.以撒鬼魂的粒子也建议加上淡入和淡出

*.至此,已经基本完成了游戏的流程化,已经能够顺利地连成一条线了,并且可以在关卡失败的时候在当前场景重生
*.接下来就是填充剧情和美化场景,明天应该能把数据库互动做好

下班
2021-12-23 01:19:03 +08:00

220 lines
7.9 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 DiZangsHadn : MonoBehaviour
{
// _____ _ _ _
// | __ \ | | | (_)
// | |__) | _| |__ | |_ ___
// | ___/ | | | '_ \| | |/ __|
// | | | |_| | |_) | | | (__
// |_| \__,_|_.__/|_|_|\___|
[HideInInspector]
public DiZang owner;
/// <summary>
/// 手下落到目标点后会停留多长时间
/// </summary>
public float TakeMoneyTime;
// _____ _ _
// | __ \ (_) | |
// | |__) | __ ___ ____ _| |_ ___
// | ___/ '__| \ \ / / _` | __/ _ \
// | | | | | |\ V / (_| | || __/
// |_| |_| |_| \_/ \__,_|\__\___|
/// <summary>
/// 手拿钱移动到的目标点位
/// </summary>
private Transform target;
/// <summary>
/// 浮动动画,用来重启浮动动画解决Tween的一些局限性问题
/// </summary>
private Tweener floatTweener;
/// <summary>
/// 手在屏幕外的起点
/// </summary>
private Vector3 start;
/// <summary>
/// 此时是否可被攻击
/// </summary>
[Header("此时能否被攻击")][SerializeField]
private bool canBeHit = false;
/// <summary>
/// 是否被玩家的攻击打断了?
/// </summary>
[Header("此时是否被打断")][SerializeField]
private bool wasInteruput;
private VibrationManager vibrationManager;
private Animator animator;
// _____ _ _ ____ _
// / ____| | | | _ \ | |
// | | __ _| | | |_) | __ _ ___| | __
// | | / _` | | | _ < / _` |/ __| |/ /
// | |___| (_| | | | |_) | (_| | (__| <
// \_____\__,_|_|_|____/ \__,_|\___|_|\_\
void Start(){Init();}
// _ _ _
// | \ | | | |
// | \| | ___ _ __ _ __ ___ __ _| |
// | . ` |/ _ \| '__| '_ ` _ \ / _` | |
// | |\ | (_) | | | | | | | | (_| | |
// |_| \_|\___/|_| |_| |_| |_|\__,_|_|
private void Init(){
//找到需要的物体和组件
owner = FindObjectOfType<DiZang>();
target = owner.transform.Find("手的终点位置");
start = transform.position;
vibrationManager = FindObjectOfType<VibrationManager>();
animator = GetComponent<Animator>();
}
/// <summary>
/// 主人发命令拿钱时触发
/// </summary>
public void ATK(){
//创建、播放并记录一个抖动动画
Tweener floatTweener = transform.DOShakePosition(2f,0.05f,50,90,false,false);
this.floatTweener = floatTweener;
//创建、播放并记录一个下移动画
Tweener tweener = transform.DOMoveY(
target.position.y,
2f
);
//震动手柄和屏幕
vibrationManager.ShakeScream(Vector2.up,1f);
StartCoroutine(vibrationManager.ShakePad(0.4f,0.2f,2f,VibrationManager.PadShakeitem.));
//创建并给予下移动画结束事件
TweenCallback action = () =>{
//下移结束,标记为可被攻击
canBeHit = true;
//删掉正在播放的抖动动画
floatTweener.Kill();
//拿走钱
FindObjectOfType<MoneyBox>().OnBeTakeMoney();
//开始协程,等待拿钱时间结束后上移回去手
Invoke("TakeMoneyAndRun",TakeMoneyTime);
//开始抓握动画
animator.SetBool("isTaking",true);
};
tweener.OnComplete(action);
}
/// <summary>
/// 手到塞钱箱后触发,执行等待和返回操作
/// </summary>
private void TakeMoneyAndRun(){
//如果没有被打断,才会执行正常的上移
if(!wasInteruput){
//创建、播放并记录一个抖动动画
Tweener floatTweener = transform.DOShakePosition(2f,0.05f,50,90,false,false);
this.floatTweener = floatTweener;
//创建、播放并记录一个上移动画
Tweener tweener = transform.DOMoveY(
start.y,
2f
);
//创建并给予下移动画结束事件
TweenCallback action = () =>{
//为下一次下移做准备,标记自身不可再被击中
canBeHit = false;
//删掉抖动动画
floatTweener.Kill();
//通知主人,攻击结束
owner.ATKEnd();
//重置一下自己的状态
transform.position = start;
GetComponent<Rigidbody2D>().velocity = Vector2.zero;
animator.SetBool("isTaking",false);
};
tweener.OnComplete(action);
//震动手柄和屏幕
vibrationManager.ShakeScream(Vector2.up,1f);
StartCoroutine(vibrationManager.ShakePad(0.4f,0.2f,2f,VibrationManager.PadShakeitem.));
}
}
// ______ _
// | ____| | |
// | |____ _____ _ __ | |_
// | __\ \ / / _ \ '_ \| __|
// | |___\ V / __/ | | | |_
// |______\_/ \___|_| |_|\__|
/// <summary>
/// 当创到玩家触发,触发玩家的被击功能
/// </summary>
private void OnTouchThePlayer(MyPlayer player){
//告诉玩家,你被攻击了
player.OnBeHit(owner.ATK,
((transform.position.x -
player.transform.position.x)
> 0) ? 1 : -1);//通过自身位置和玩家位置的比较来返回玩家本次的受击方向
}
/// <summary>
/// 当手被攻击触发
/// </summary>
public void OnBeHit(MyPlayer.AtkMethod hitMethod, int hitDir){
//标记此时被打断
wasInteruput = true;
CancelInvoke("TakeMoneyAndRun");
//突然抬起一段,伴随着剧烈的震动
//创建、播放并记录一个抖动动画
Tweener floatTweener = transform.DOShakePosition(0.5f,0.5f,50,90,false,false);
this.floatTweener = floatTweener;
//创建一个猛烈上移动画
Tweener tweener = transform.DOMoveY(
transform.position.y + 2f,
0.5f
);
//给猛烈上移动画添加结束事件
TweenCallback action = () =>{
floatTweener.Kill();
canBeHit = false;
wasInteruput = false;
Invoke("TakeMoneyAndRun",TakeMoneyTime);
};
tweener.OnComplete(action);
//结算生命值
owner.HPLeft -= MyPlayer.atkMethodMagnification[hitMethod];
//看下死了没
if(owner.CheckDead()){
owner.OnDead();
}
//震动手柄和屏幕
vibrationManager.ShakeScream(Vector2.up,1f);
StartCoroutine(vibrationManager.ShakePad(0.4f,0.2f,0.2f,VibrationManager.PadShakeitem.));
}
// _____ _ _ _ _
// / ____| | | (_) (_)
// | | ___ | | |_ ___ _ ___ _ __
// | | / _ \| | | / __| |/ _ \| '_ \
// | |___| (_) | | | \__ \ | (_) | | | |
// \_____\___/|_|_|_|___/_|\___/|_| |_|
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)){
if(canBeHit)
OnBeHit(MyPlayer.AtkMethod.,
(transform.position.x - sickle.transform.position.x > 0) ? -1 : 1);
Destroy(sickle.gameObject);}
}
}